Sha256: 93fbb281d10409e96b072006af064c0056f86170b132354cc61b8855df6f7b39

Contents?: true

Size: 744 Bytes

Versions: 7

Compression:

Stored size: 744 Bytes

Contents

require 'activesearch/elastic_search'

module ElasticSearchRefresh
  
  def save
    super.tap { Tire.index('_all') { refresh }}
  end
  
  def destroy
    super.tap { Tire.index('_all') { refresh }}
  end
end

class ElasticSearchModel < ActiveMimic
  include ActiveSearch::ElasticSearch
  include ElasticSearchRefresh
  
  attribute :title
  attribute :text
  attribute :junk
  attribute :special, default: false
  
  search_by [:title, :text, store: [:title, :junk]], if: lambda { !self.special }

end

class AnotherElasticSearchModel < ActiveMimic
  include ActiveSearch::ElasticSearch
  include ElasticSearchRefresh
  
  attribute :title, type: String
  search_by [:title, store: [:title, :virtual]]
  
  def virtual
    "virtual"
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
activesearch-0.1.0 spec/models/elastic_search.rb
activesearch-0.0.16 spec/models/elastic_search.rb
activesearch-0.0.15 spec/models/elastic_search.rb
activesearch-0.0.14 spec/models/elastic_search.rb
activesearch-0.0.13 spec/models/elastic_search.rb
activesearch-0.0.12 spec/models/elastic_search.rb
activesearch-0.0.11 spec/models/elastic_search.rb