@@ -76,7 +76,7 @@ We can save a `Note` instance into the repository...
7676note = Note .new id: 1 , text: ' Test'
7777
7878repository.save(note)
79- # PUT http://localhost:9200/repository/note /1 [status:201, request:0.210s, query:n/a]
79+ # PUT http://localhost:9200/repository/_doc /1 [status:201, request:0.210s, query:n/a]
8080# > {"id":1,"text":"Test"}
8181# < {"_index":"repository","_type":"note","_id":"1","_version":1,"created":true}
8282```
@@ -85,7 +85,7 @@ repository.save(note)
8585
8686``` ruby
8787n = repository.find(1 )
88- # GET http://localhost:9200/repository/_all /1 [status:200, request:0.003s, query:n/a]
88+ # GET http://localhost:9200/repository/_doc /1 [status:200, request:0.003s, query:n/a]
8989# < {"_index":"repository","_type":"note","_id":"1","_version":2,"found":true, "_source" : {"id":1,"text":"Test"}}
9090=> < Note: 0x007fcbfc0c4980 @attributes = {" id" =>1 , " text" =>" Test" }>
9191```
@@ -104,7 +104,7 @@ repository.search(query: { match: { text: 'test' } }).first
104104
105105``` ruby
106106repository.delete(note)
107- # DELETE http://localhost:9200/repository/note /1 [status:200, request:0.014s, query:n/a]
107+ # DELETE http://localhost:9200/repository/_doc /1 [status:200, request:0.014s, query:n/a]
108108# < {"found":true,"_index":"repository","_type":"note","_id":"1","_version":3}
109109=> {" found" =>true , " _index" =>" repository" , " _type" =>" note" , " _id" =>" 1" , " _version" =>2 }
110110```
@@ -145,7 +145,7 @@ class MyRepository
145145end
146146
147147client = Elasticsearch ::Client .new (url: ENV [' ELASTICSEARCH_URL' ], log: true )
148- repository = MyRepository .new (client: client, index_name: :my_notes , type: :my_note , klass: Note )
148+ repository = MyRepository .new (client: client, index_name: :my_notes , type: :note , klass: Note )
149149repository.settings number_of_shards: 1 do
150150 mapping do
151151 indexes :text , analyzer: ' snowball'
@@ -168,7 +168,7 @@ Save the document with extra properties added by the `serialize` method:
168168
169169``` ruby
170170repository.save(note)
171- # PUT http://localhost:9200/my_notes/my_note /1
171+ # PUT http://localhost:9200/my_notes/note /1
172172# > {"id":1,"text":"Test","my_special_key":"my_special_stuff"}
173173{" _index" =>" my_notes" , " _type" =>" my_note" , " _id" =>" 1" , " _version" =>4 , ... }
174174```
@@ -177,7 +177,7 @@ And `deserialize` it:
177177
178178``` ruby
179179repository.find(1 )
180- # ***** CUSTOM DESERIALIZE LOGIC KICKING IN ... *****
180+ # ***** CUSTOM DESERIALIZE LOGIC... *****
181181< Note: 0x007f9bd782b7a0 @attributes = {... " my_special_key" =>" my_special_stuff" }>
182182```
183183
@@ -245,10 +245,10 @@ repository.create_index!(force: true)
245245note = Note .new (' id' => 1 , ' text' => ' Document with image' , ' image' => ' ... BINARY DATA ...' )
246246
247247repository.save(note)
248- # PUT http://localhost:9200/notes_development/note /1
248+ # PUT http://localhost:9200/notes_development/_doc /1
249249# > {"id":1,"text":"Document with image","image":"Li4uIEJJTkFSWSBEQVRBIC4uLg==\n"}
250250puts repository.find(1 ).attributes[' image' ]
251- # GET http://localhost:9200/notes_development/note /1
251+ # GET http://localhost:9200/notes_development/_doc /1
252252# < {... "_source" : { ... "image":"Li4uIEJJTkFSWSBEQVRBIC4uLg==\n"}}
253253# => ... BINARY DATA ...
254254```
@@ -452,22 +452,22 @@ The `save` method allows you to store a domain object in the repository:
452452``` ruby
453453note = Note .new id: 1 , title: ' Quick Brown Fox'
454454repository.save(note)
455- # => {"_index"=>"notes_development", "_type"=>"my_note ", "_id"=>"1", "_version"=>1, "created"=>true}
455+ # => {"_index"=>"notes_development", "_type"=>"_doc ", "_id"=>"1", "_version"=>1, "created"=>true}
456456```
457457
458458The ` update ` method allows you to perform a partial update of a document in the repository.
459459Use either a partial document:
460460
461461``` ruby
462462repository.update id: 1 , title: ' UPDATED' , tags: []
463- # => {"_index"=>"notes_development", "_type"=>"note ", "_id"=>"1", "_version"=>2}
463+ # => {"_index"=>"notes_development", "_type"=>"_doc ", "_id"=>"1", "_version"=>2}
464464```
465465
466466Or a script (optionally with parameters):
467467
468468``` ruby
469469repository.update 1 , script: ' if (!ctx._source.tags.contains(t)) { ctx._source.tags += t }' , params: { t: ' foo' }
470- # => {"_index"=>"notes_development", "_type"=>"note ", "_id"=>"1", "_version"=>3}
470+ # => {"_index"=>"notes_development", "_type"=>"_doc ", "_id"=>"1", "_version"=>3}
471471```
472472
473473
@@ -507,11 +507,11 @@ The `search` method is used to retrieve objects from the repository by a query s
507507
508508``` ruby
509509repository.search(' fox or dog' ).to_a
510- # GET http://localhost:9200/notes_development/my_note /_search?q=fox
510+ # GET http://localhost:9200/notes_development/_doc /_search?q=fox
511511# => [<MyNote ... FOX ...>, <MyNote ... DOG ...>]
512512
513513repository.search(query: { match: { title: ' fox dog' } }).to_a
514- # GET http://localhost:9200/notes_development/my_note /_search
514+ # GET http://localhost:9200/notes_development/_doc /_search
515515# > {"query":{"match":{"title":"fox dog"}}}
516516# => [<MyNote ... FOX ...>, <MyNote ... DOG ...>]
517517```
0 commit comments