Query_string in filters - are they "exactly" or "at least"?

Hi! when we use query_string to filter in Kibana like this:

{
"query": {
"query_string": {
"default_field": "*",
"query": "apples AND bananas AND tomatoes"
}
}
}

Im not sure if the results generated are ONLY those with this specific combination, or those results with AT LEAST these 3 items?

How do I code so that it is exactly the combination stated and also if I want to make it at least the combination?

AND will only show documents that contain all the terms, if you want to make it "at least" you should be using OR

thank you!

may i also ask about this scenario:

  • say my query string is apples AND bananas
  • documents without apples or bananas will not be in the output.
  • but if my documents may have both apples AND bananas only, or apples AND bananas AND grapes

will the output consist be restricted to documents with ONLY apples and bananas? or include those with an additional word grapes?

it will include all of them in that case. You could add a negation for grapes, but you would need to know what the documents might contain other than apples and bananas.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.