@@ -76,7 +76,7 @@ We can save a `Note` instance into the repository...
76
76
note = Note .new id: 1 , text: ' Test'
77
77
78
78
repository.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]
80
80
# > {"id":1,"text":"Test"}
81
81
# < {"_index":"repository","_type":"note","_id":"1","_version":1,"created":true}
82
82
```
@@ -85,7 +85,7 @@ repository.save(note)
85
85
86
86
``` ruby
87
87
n = 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]
89
89
# < {"_index":"repository","_type":"note","_id":"1","_version":2,"found":true, "_source" : {"id":1,"text":"Test"}}
90
90
=> < Note: 0x007fcbfc0c4980 @attributes = {" id" =>1 , " text" =>" Test" }>
91
91
```
@@ -104,7 +104,7 @@ repository.search(query: { match: { text: 'test' } }).first
104
104
105
105
``` ruby
106
106
repository.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]
108
108
# < {"found":true,"_index":"repository","_type":"note","_id":"1","_version":3}
109
109
=> {" found" =>true , " _index" =>" repository" , " _type" =>" note" , " _id" =>" 1" , " _version" =>2 }
110
110
```
@@ -145,7 +145,7 @@ class MyRepository
145
145
end
146
146
147
147
client = 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 )
149
149
repository.settings number_of_shards: 1 do
150
150
mapping do
151
151
indexes :text , analyzer: ' snowball'
@@ -168,7 +168,7 @@ Save the document with extra properties added by the `serialize` method:
168
168
169
169
``` ruby
170
170
repository.save(note)
171
- # PUT http://localhost:9200/my_notes/my_note /1
171
+ # PUT http://localhost:9200/my_notes/note /1
172
172
# > {"id":1,"text":"Test","my_special_key":"my_special_stuff"}
173
173
{" _index" =>" my_notes" , " _type" =>" my_note" , " _id" =>" 1" , " _version" =>4 , ... }
174
174
```
@@ -177,7 +177,7 @@ And `deserialize` it:
177
177
178
178
``` ruby
179
179
repository.find(1 )
180
- # ***** CUSTOM DESERIALIZE LOGIC KICKING IN ... *****
180
+ # ***** CUSTOM DESERIALIZE LOGIC... *****
181
181
< Note: 0x007f9bd782b7a0 @attributes = {... " my_special_key" =>" my_special_stuff" }>
182
182
```
183
183
@@ -245,10 +245,10 @@ repository.create_index!(force: true)
245
245
note = Note .new (' id' => 1 , ' text' => ' Document with image' , ' image' => ' ... BINARY DATA ...' )
246
246
247
247
repository.save(note)
248
- # PUT http://localhost:9200/notes_development/note /1
248
+ # PUT http://localhost:9200/notes_development/_doc /1
249
249
# > {"id":1,"text":"Document with image","image":"Li4uIEJJTkFSWSBEQVRBIC4uLg==\n"}
250
250
puts repository.find(1 ).attributes[' image' ]
251
- # GET http://localhost:9200/notes_development/note /1
251
+ # GET http://localhost:9200/notes_development/_doc /1
252
252
# < {... "_source" : { ... "image":"Li4uIEJJTkFSWSBEQVRBIC4uLg==\n"}}
253
253
# => ... BINARY DATA ...
254
254
```
@@ -452,22 +452,22 @@ The `save` method allows you to store a domain object in the repository:
452
452
``` ruby
453
453
note = Note .new id: 1 , title: ' Quick Brown Fox'
454
454
repository.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}
456
456
```
457
457
458
458
The ` update ` method allows you to perform a partial update of a document in the repository.
459
459
Use either a partial document:
460
460
461
461
``` ruby
462
462
repository.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}
464
464
```
465
465
466
466
Or a script (optionally with parameters):
467
467
468
468
``` ruby
469
469
repository.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}
471
471
```
472
472
473
473
@@ -507,11 +507,11 @@ The `search` method is used to retrieve objects from the repository by a query s
507
507
508
508
``` ruby
509
509
repository.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
511
511
# => [<MyNote ... FOX ...>, <MyNote ... DOG ...>]
512
512
513
513
repository.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
515
515
# > {"query":{"match":{"title":"fox dog"}}}
516
516
# => [<MyNote ... FOX ...>, <MyNote ... DOG ...>]
517
517
```
0 commit comments