Module: ElasticSearchable::ActiveRecordExtensions::ClassMethods
- Defined in:
- lib/elastic_searchable/active_record_extensions.rb
Instance Method Summary collapse
-
#elastic_searchable(options = {}) ⇒ Object
Valid options: :type (optional) configue type to store data in.
Instance Method Details
#elastic_searchable(options = {}) ⇒ Object
Valid options: :type (optional) configue type to store data in. default to model table name :mapping (optional) configure field properties for this model (ex: skip analyzer for field) :if (optional) reference symbol/proc condition to only index when condition is true :unless (optional) reference symbol/proc condition to skip indexing when condition is true :json (optional) configure the json document to be indexed (see api.rubyonrails.org/classes/ActiveModel/Serializers/JSON.html#method-i-as_json for available options)
after_percolate called after object is indexed in elasticsearch only fires if the update index call returns a non-empty set of registered percolations use the “percolations” instance method from within callback to inspect what percolations were returned
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/elastic_searchable/active_record_extensions.rb', line 25 def elastic_searchable( = {}) include ElasticSearchable::ActiveRecordExtensions::LocalMethods cattr_accessor :elastic_options self. = .symbolize_keys.merge(:unless => Array.wrap([:unless]).push(:elasticsearch_offline?)) attr_reader :hit attr_accessor :index_lifecycle if self.[:index_options] ActiveSupport::Deprecation.warn ":index_options has been deprecated. Use ElasticSearchable.index_settings instead.", caller end if self.[:index] ActiveSupport::Deprecation.warn ":index has been deprecated. Use ElasticSearchable.index_name instead.", caller end after_commit_backgrounded :update_index_on_create, :if => :should_index?, :on => :create, :backgrounded => ElasticSearchable. after_commit_backgrounded :update_index_on_update, :if => :should_index?, :on => :update, :backgrounded => ElasticSearchable. after_commit :delete_from_index, :unless => :elasticsearch_offline?, :on => :destroy end |