I have an ElasticSearch / Tire query that has facets attached. It seems the facets a using the global scope, instead of the query scope and filters.
Here is my definition. I'm not sure how to scope the it to use the filters.
def self.facets_for(keyword_array, fasit, opts = {})
keyword_array = [keyword_array] if keyword_array.is_a?(String)
tire.search(per_page: opts[:per_page], page: opts[:page] ) do
query do
boolean { should { string '*' }}
end
filter :terms, :keyword => keyword_array
facet "phrases" do terms :phrases, :size => 20 end if fasit.include?("phrases")
facet "sentiment" do terms :sentiment end if fasit.include?("sentiment")
facet "lang" do terms :lang end if fasit.include?("lang")
facet "provider" do terms :provider end if fasit.include?("provider")
end # tire search
end
Right now, this returns facets that are "global" in scope, i.e. they aren't filtered by the filters (or the query if there is a more sophisticated query).
What am I missing?