Module: ElasticRecord::PercolatorModel::ClassMethods

Defined in:
lib/elastic_record/percolator_model.rb

Constant Summary collapse

DEFAULT_PERCOLATOR_MAPPING =
{
  properties: {
    query: { type: 'percolator' }
  }
}

Instance Method Summary collapse

Instance Method Details

#elastic_indexObject



18
19
20
21
22
23
24
25
26
27
28
# File 'lib/elastic_record/percolator_model.rb', line 18

def elastic_index
  @elastic_index ||=
    begin
      index = ElasticRecord::Index.new(self)
      index.mapping = DEFAULT_PERCOLATOR_MAPPING
      index.mapping = percolates_model.elastic_index.mapping
      index.analysis = percolates_model.elastic_index.analysis
      index.partial_updates = false
      index
    end
end

#percolate(document) ⇒ Object



30
31
32
33
34
# File 'lib/elastic_record/percolator_model.rb', line 30

def percolate(document)
  query = Arelastic::Queries::Percolate.new("query", document)

  elastic_search.filter(query).limit(5000)
end