Elastics::ModelIndexer
Notice: The
Elastics::ModelIndexer
includes alsoElastics::ModelSyncer
(see Elastics::ModelSyncer)
Elastics avoids polluting your models with many methods: indeed it adds just a few methods, all starting with the elastics_
prefix to avoid confusion:
Model.elastics
Model.elastics_in_batches
record.elastics
record.elastics_source
record.elastics_indexable?
Besides you can define a Model.elastics_result
method in order to customize the results (see Model.elastics_result)
The Model.elastics_in_batches
is used internally to import the records/documents of the model. It is defined for ActiveRecord
and Mongoid
models. You may want to override it if you want to import only a subset of the table/collection (for example if you need to do an incremental import/live-reindex based on a timestamp).
Class Methods
elastics
|
You access all the Elastics features included in your model through the |
elastics.index
|
By default the index used for all the models in your app is the
|
elastics.type
|
By default the type used for your model is the full-underscored class name. For example
|
elastics.parent
|
Defines elasticsearch parent/child relations (see Indexing Records). |
elastics.sync(*synced)
|
Implemented by the |
elastics.synced
|
Implemented by the |
elastics_result(result)
|
Custom defined method (see Model.elasticsresult). |
self.elastics_in_batches(options, block)
|
Custom defined method (see Model.elasticsinbatches). |
Instance Methods
You usually don’t need to deal with this methods unless you sync manually or have very special needs.
elastics
|
The |
elastics.index
|
The index for this record. |
elastics.type
|
The document type for this record. |
elastics.store
|
Indexes the |
elastics.remove
|
Removes the elasticsearch document for this record. It is used internally and you don't need to use this directly if you use |
elastics.sync
|
Implemented by the |
elastics.get
|
Retrieves the elasticsearch document from the index. The result is extended as usual (see Elastics Extenders, Elastics Model Extenders and Elastics Rails Extenders). Mostly useful in the console to inspect the elasticsearch related document.
|
elastics_source
|
(see Indexing Records) |
elastics_indexable?
|
(see Indexing Fields) |
elastics_action
|
Should return the elasticsearch action. Useful when you have some logic in your models to delete documents on import. Default |
Overriding Elastics Metafields | |
---|---|
elastics_id , elastics_index , elastics_type , elastics_parent , elastics_routing
|
Use only if you know what you are doing!
The |