Module: Tire::Model::Percolate::InstanceMethods

Included in:
Search::InstanceMethodsProxy
Defined in:
lib/tire/model/percolate.rb

Instance Method Summary collapse

Instance Method Details

#percolate(&block) ⇒ Object

Run this document against registered percolator queries, without indexing it.

First, register a percolator query:

Article.index.register_percolator_query('fail')    { |query| query.string 'fail' }

Then, you may query the percolator endpoint with:

p Article.new(:title => 'This is a FAIL!').percolate

Optionally, you may pass a block to filter which percolator queries will be executed.

See http://www.elasticsearch.org/guide/reference/api/percolate.html for more information.



79
80
81
# File 'lib/tire/model/percolate.rb', line 79

def percolate(&block)
  index.percolate instance, block
end

#percolate=(pattern) ⇒ Object

Mark this instance for percolation when adding it to the index.



85
86
87
# File 'lib/tire/model/percolate.rb', line 85

def percolate=(pattern)
  @_percolator = pattern
end

#percolatorObject

Returns the status or pattern of percolator for this instance.



91
92
93
# File 'lib/tire/model/percolate.rb', line 91

def percolator
  @_percolator || instance.class.tire.percolator || nil
end