Sha256: 3dc538ef9acaa49f80f71c2204fd6d84328166efd1c9336a60460dfa733a6ae1

Contents?: true

Size: 697 Bytes

Versions: 3

Compression:

Stored size: 697 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]]
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
activesearch-0.0.10 spec/models/elastic_search.rb
activesearch-0.0.9 spec/models/elastic_search.rb
activesearch-0.0.8 spec/models/elastic_search.rb