Skip to content

Commit 34a3aa8

Browse files
committed
Removes _type, cleans whitespace in elasticsearch-model
1 parent 2ef285a commit 34a3aa8

File tree

4 files changed

+6
-16
lines changed

4 files changed

+6
-16
lines changed

elasticsearch-model/README.md

+6-8
Original file line numberDiff line numberDiff line change
@@ -269,8 +269,8 @@ It is possible to search across multiple models with the module method:
269269
```ruby
270270
Elasticsearch::Model.search('fox', [Article, Comment]).results.to_a.map(&:to_hash)
271271
# => [
272-
# {"_index"=>"articles", "_type"=>"article", "_id"=>"1", "_score"=>0.35136628, "_source"=>...},
273-
# {"_index"=>"comments", "_type"=>"comment", "_id"=>"1", "_score"=>0.35136628, "_source"=>...}
272+
# {"_index"=>"articles", "_id"=>"1", "_score"=>0.35136628, "_source"=>...},
273+
# {"_index"=>"comments", "_id"=>"1", "_score"=>0.35136628, "_source"=>...}
274274
# ]
275275

276276
Elasticsearch::Model.search('fox', [Article, Comment]).records.to_a
@@ -415,13 +415,11 @@ Article.__elasticsearch__.create_index! force: true
415415
Article.__elasticsearch__.refresh_index!
416416
```
417417

418-
By default, index name and document type will be inferred from your class name,
419-
you can set it explicitly, however:
418+
By default, index name will be inferred from your class name, you can set it explicitly, however:
420419

421420
```ruby
422421
class Article
423422
index_name "articles-#{Rails.env}"
424-
document_type "post"
425423
end
426424
```
427425

@@ -529,10 +527,10 @@ class Indexer
529527
case operation.to_s
530528
when /index/
531529
record = Article.find(record_id)
532-
Client.index index: 'articles', type: 'article', id: record.id, body: record.__elasticsearch__.as_indexed_json
530+
Client.index index: 'articles', id: record.id, body: record.__elasticsearch__.as_indexed_json
533531
when /delete/
534532
begin
535-
Client.delete index: 'articles', type: 'article', id: record_id
533+
Client.delete index: 'articles', id: record_id
536534
rescue Elastic::Transport::Transport::Errors::NotFound
537535
logger.debug "Article not found, ID: #{record_id}"
538536
end
@@ -555,7 +553,7 @@ You'll see the job being processed in the console where you started the _Sidekiq
555553
Indexer JID-eb7e2daf389a1e5e83697128 DEBUG: ["index", "ID: 7"]
556554
Indexer JID-eb7e2daf389a1e5e83697128 INFO: PUT http://localhost:9200/articles/article/1 [status:200, request:0.004s, query:n/a]
557555
Indexer JID-eb7e2daf389a1e5e83697128 DEBUG: > {"id":1,"title":"Updated", ...}
558-
Indexer JID-eb7e2daf389a1e5e83697128 DEBUG: < {"ok":true,"_index":"articles","_type":"article","_id":"1","_version":6}
556+
Indexer JID-eb7e2daf389a1e5e83697128 DEBUG: < {"ok":true,"_index":"articles","_id":"1","_version":6}
559557
Indexer JID-eb7e2daf389a1e5e83697128 INFO: done: 0.006 sec
560558
```
561559

elasticsearch-model/lib/elasticsearch/model.rb

-2
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@
6262
end
6363

6464
module Elasticsearch
65-
6665
# Elasticsearch integration for Ruby models
6766
# =========================================
6867
#
@@ -108,7 +107,6 @@ module Model
108107
def self.included(base)
109108
base.class_eval do
110109
include Elasticsearch::Model::Proxy
111-
112110
# Delegate common methods to the `__elasticsearch__` ClassMethodsProxy, unless they are defined already
113111
class << self
114112
METHODS.each do |method|

elasticsearch-model/lib/elasticsearch/model/adapters/active_record.rb

-4
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,9 @@
1818
module Elasticsearch
1919
module Model
2020
module Adapter
21-
2221
# An adapter for ActiveRecord-based models
2322
#
2423
module ActiveRecord
25-
2624
Adapter.register self,
2725
lambda { |klass| !!defined?(::ActiveRecord::Base) && klass.respond_to?(:ancestors) && klass.ancestors.include?(::ActiveRecord::Base) }
2826

@@ -71,7 +69,6 @@ def load
7169
end
7270

7371
module Callbacks
74-
7572
# Handle index updates (creating, updating or deleting documents)
7673
# when the model changes, by hooking into the lifecycle
7774
#
@@ -87,7 +84,6 @@ def self.included(base)
8784
end
8885

8986
module Importing
90-
9187
# Fetch batches of records from the database (used by the import method)
9288
#
9389
#

elasticsearch-model/lib/elasticsearch/model/indexing.rb

-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717

1818
module Elasticsearch
1919
module Model
20-
2120
# Provides the necessary support to set up index options (mappings, settings)
2221
# as well as instance methods to create, update or delete documents in the index.
2322
#
@@ -29,7 +28,6 @@ module Model
2928
# @see InstanceMethods#delete_document
3029
#
3130
module Indexing
32-
3331
# Wraps the [index settings](https://www.elastic.co/guide/en/elasticsearch/reference/current/index.html)
3432
#
3533
class Settings

0 commit comments

Comments
 (0)