karmi/tire — Issue #243: OR filter with multiple same key values get mapped to single key
Author: cwadding
Created: 2012-02-16 04:59:05+00:00
State: open

Just trying to duplicate an OR filter on as shown on the [elastic search site](http://www.elasticsearch.org/guide/reference/query-dsl/or-filter.html) in a rails app.

def self.search(params)
tire.search(:page => (params[:page] || 1), :per_page => (params[:per] || 10)) do
filter :or, {:filters => {:term => {"name.second" => "banon"}, :term => { "name.nick" => "kimchy" }}}
raise to_json
end
end

but the resulting json I get back is:

"filter": {
"or": {
"filters": {
"term": {
"name.nick": "kimchy"
}
}
}
},
"size": 10,
"from": 0
}

I also tried with square brackets as follows

def self.search(params)
tire.search(:page => (params[:page] || 1), :per_page => (params[:per] || 10)) do
filter :or, {:filters => [:term => {"name.second" => "banon"}, :term => { "name.nick" => "kimchy" }]}
raise to_json
end
end

and I get the same result. It seems that the earlier `term` gets over written by the second one. Is there anyway to allow for multiple term filters in an OR filter?