@@ -42,7 +42,7 @@ The library provides the Repository pattern for adding persistence to your Ruby
4242
4343The ` Elasticsearch::Persistence::Repository ` module provides an implementation of the
4444[ repository pattern] ( http://martinfowler.com/eaaCatalog/repository.html ) and allows
45- to save, delete, find and search objects stored in Elasticsearch, as well as configure
45+ you to save, delete, find and search objects stored in Elasticsearch, as well as configure
4646mappings and settings for the index. It's an unobtrusive and decoupled way of adding
4747persistence to your Ruby objects.
4848
@@ -257,9 +257,9 @@ puts repository.find(1).attributes['image']
257257
258258Each of the following configurations can be set for a repository instance.
259259If you have included the ` Elasticsearch::Persistence::Repository::DSL ` mixin, then you can use the class-level DSL
260- methods to set each configuration . You can override the configuration for any instance by passing options to the
260+ methods to set each value . You can still override the configuration for any instance by passing options to the
261261` #initialize ` method.
262- If you don't use the DSL mixin, you can set also the instance configuration with options passed the ` #initialize ` method.
262+ Even if you don't use the DSL mixin, you can set the instance configuration with options passed the ` #initialize ` method.
263263
264264##### Client
265265
@@ -269,6 +269,9 @@ The repository uses the standard Elasticsearch [client](https://github.com/elast
269269client = Elasticsearch ::Client .new (url: ' http://search.server.org' )
270270repository = NoteRepository .new (client: client)
271271repository.client.transport.logger = Logger .new (STDERR )
272+ repository.client
273+ # => Elasticsearch::Client
274+
272275```
273276
274277or with the DSL mixin:
@@ -282,6 +285,8 @@ class NoteRepository
282285end
283286
284287repository = NoteRepository .new
288+ repository.client
289+ # => Elasticsearch::Client
285290
286291```
287292
@@ -292,6 +297,9 @@ is 'repository'.
292297
293298``` ruby
294299repository = NoteRepository .new (index_name: ' notes_development' )
300+ repository.index_name
301+ # => 'notes_development'
302+
295303```
296304
297305or with the DSL mixin:
@@ -305,15 +313,20 @@ class NoteRepository
305313end
306314
307315repository = NoteRepository .new
316+ repository.index_name
317+ # => 'notes_development'
308318
309319```
310320
311- The ` type ` method specifies the Elasticsearch document type to use for storage, lookup and search. The default value is
321+ The ` document_type ` method specifies the Elasticsearch document type to use for storage, lookup and search. The default value is
312322'_ doc'. Keep in mind that future versions of Elasticsearch will not allow you to set this yourself and will use the type,
313323'_ doc'.
314324
315325``` ruby
316326repository = NoteRepository .new (document_type: ' note' )
327+ repository.document_type
328+ # => 'note'
329+
317330```
318331
319332or with the DSL mixin:
@@ -327,6 +340,8 @@ class NoteRepository
327340end
328341
329342repository = NoteRepository .new
343+ repository.document_type
344+ # => 'note'
330345
331346```
332347
@@ -336,6 +351,9 @@ returned instead.
336351
337352``` ruby
338353repository = NoteRepository .new (klass: Note )
354+ repository.klass
355+ # => Note
356+
339357```
340358
341359or with the DSL mixin:
@@ -349,6 +367,8 @@ class NoteRepository
349367end
350368
351369repository = NoteRepository .new
370+ repository.klass
371+ # => Note
352372
353373```
354374
@@ -383,8 +403,10 @@ repository = NoteRepository.new
383403
384404```
385405
386- You can also use the ` #create ` method defined on the repository class to create and set the mappings and settings
387- on an instance with a block in one call:
406+ ##### Create a Repository and set its configuration with a block
407+
408+ You can also use the ` #create ` method to instantiate and set the mappings and settings on an instance
409+ with a block in one call:
388410
389411``` ruby
390412repository = NoteRepository .create(index_name: ' notes_development' ) do
@@ -399,13 +421,15 @@ repository = NoteRepository.create(index_name: 'notes_development') do
399421end
400422```
401423
424+ ##### Index Management
425+
402426The convenience methods ` create_index! ` , ` delete_index! ` and ` refresh_index! ` allow you to manage the index lifecycle.
403427These methods can only be called on repository instances and are not implemented at the class level.
404428
405429##### Serialization
406430
407- The ` serialize ` and ` deserialize ` methods allow you to customize the serialization of the document when passing it
408- to the storage , and the initialization procedure when loading it from the storage:
431+ The ` serialize ` and ` deserialize ` methods allow you to customize the serialization of the document when it
432+ is persisted to Elasticsearch , and define the initialization procedure when loading it from the storage:
409433
410434``` ruby
411435class NoteRepository
@@ -447,7 +471,7 @@ repository.update 1, script: 'if (!ctx._source.tags.contains(t)) { ctx._source.t
447471```
448472
449473
450- The ` delete ` method allows to remove objects from the repository (pass either the object itself or its ID):
474+ The ` delete ` method allows you to remove objects from the repository (pass either the object itself or its ID):
451475
452476``` ruby
453477repository.delete(note)
@@ -456,7 +480,7 @@ repository.delete(1)
456480
457481##### Finding
458482
459- The ` find ` method allows to find one or many documents in the storage and returns them as deserialized Ruby objects:
483+ The ` find ` method allows you to find one or many documents in the storage and returns them as deserialized Ruby objects:
460484
461485``` ruby
462486repository.save Note .new (id: 2 , title: ' Fast White Dog' )
@@ -479,7 +503,7 @@ Handle the missing objects in the application code, or call `compact` on the res
479503
480504##### Search
481505
482- The ` search ` method to retrieve objects from the repository by a query string or definition in the Elasticsearch DSL:
506+ The ` search ` method is used to retrieve objects from the repository by a query string or definition in the Elasticsearch DSL:
483507
484508``` ruby
485509repository.search(' fox or dog' ).to_a
0 commit comments