I'm using tire with elasticsearch, and I'm stumped how to create a boolean query with the minimum_number_should_match option while also tossing it a set of queries stored in a block.
So, I have
options = {:minimum_number_should_match => 1}
s = Tire.search 'variations' do |search|
search.query do |query|
query.boolean options, &keyword_query(params[:keyword]) unless params[:keyword].blank?
end
end
def keyword_query(keyword)
lambda do |boolean|
boolean.should { string "name:*#{keyword}*"}
boolean.should { string "number:*#{keyword}*"}
boolean.should { string "nrf:*#{keyword}*"}
boolean.should { string "base_color:*#{keyword}*"}
boolean.should { string "skus:*#{keyword}*"}
boolean.should { string "color_name:*#{keyword}*"}
end
end`
But the option is not being added to the end query request to ElasticSearch. keyword_query returns a lambda. Is there another way I can add the options to this boolean query?