# Query\_string in filters - are they "exactly" or "at least"?

**URL:** <https://discuss.elastic.co/t/query-string-in-filters-are-they-exactly-or-at-least/197703>\
**Category:** Kibana\
**Created:** [September 2, 2019, 2:14pm UTC](https://discuss.elastic.co/t/query-string-in-filters-are-they-exactly-or-at-least/197703 "2019-09-02T14:14:34Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![chris2](https://avatars.discourse-cdn.com/v4/letter/c/ac8455/32.png) [@chris2](https://discuss.elastic.co/u/chris2)\
**Post date:** [September 2, 2019, 2:14pm UTC](https://discuss.elastic.co/t/query-string-in-filters-are-they-exactly-or-at-least/197703/1 "2019-09-02T14:14:34Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Marius\_Dragomir](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/marius_dragomir/32/42087_2.png) [@Marius\_Dragomir](https://discuss.elastic.co/u/Marius_Dragomir)\
**Post date:** [September 6, 2019, 10:36am UTC](https://discuss.elastic.co/t/query-string-in-filters-are-they-exactly-or-at-least/197703/2 "2019-09-06T10:36:06Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![chris2](https://avatars.discourse-cdn.com/v4/letter/c/ac8455/32.png) [@chris2](https://discuss.elastic.co/u/chris2)\
**Post date:** [September 10, 2019, 11:22am UTC](https://discuss.elastic.co/t/query-string-in-filters-are-they-exactly-or-at-least/197703/3 "2019-09-10T11:22:56Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Marius\_Dragomir](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/marius_dragomir/32/42087_2.png) [@Marius\_Dragomir](https://discuss.elastic.co/u/Marius_Dragomir)\
**Post date:** [September 10, 2019, 1:26pm UTC](https://discuss.elastic.co/t/query-string-in-filters-are-they-exactly-or-at-least/197703/4 "2019-09-10T13:26:49Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [October 8, 2019, 1:26pm UTC](https://discuss.elastic.co/t/query-string-in-filters-are-they-exactly-or-at-least/197703/5 "2019-10-08T13:26:56Z")

</div>

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