This is probably very simple, but I can’t work it out. I have this tire/elasicsearch query on Project class:
def self.search(params)
tire.search(load: true, page: params[:page], per_page: 8) do
query do
boolean do
must { string params[:query], default_operator: "AND" } if params[:query].present?
must { term :status, "posted" }
must { term :budget, params[:budget] } if params[:budget].present?
end
end
end
end
I need the Status term to be searching on ‘posted’ OR ‘closed’ and can’t work this out. I tried term :status, [“posted”, “closed”] but this doesn’t return results so probably doing an AND.
Be grateful for the right tire syntax here. (NB not looking for the jason/elasticsearch string here)
Many thanks!
What you need is a
termsquery, which does theORbetween terms passed as an array:or something like this for dynamic values:
See this part of Tire documentation for more info and context.