karmi/tire — Issue #176: The Facet initializer doesn't allow to pass parameters to Facet
Author: itayco
Created: 2011-12-18 08:24:03+00:00
State: open

In the current implementation it's impossible to pass parameters to Facet.

For example, the following code:

@term = "category_ids"

search = Tire.search do |search|
search.facet 'category' do |facet|
facet.terms @term, :size => 100
end
end

generates the following query:

{"facets":{"category":{"terms":{"field":null,"size":100,"all_terms":false}}}}

( note the "field":null )

The reason seems to be the Facet initializer - it's last line performs only instance_eval and not considering the block arity.
It should be exactly like the last line of the Query initializer, where passing parameters is possible.

Fixed it in this fork.