# Get which condition a result matched when using bool should query?

**URL:** <https://discuss.elastic.co/t/get-which-condition-a-result-matched-when-using-bool-should-query/66034>\
**Category:** Elasticsearch\
**Created:** [November 14, 2016, 11:01pm UTC](https://discuss.elastic.co/t/get-which-condition-a-result-matched-when-using-bool-should-query/66034 "2016-11-14T23:01:41Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![suanmeiguo](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/suanmeiguo/32/11758_2.png) [@suanmeiguo](https://discuss.elastic.co/u/suanmeiguo)\
**Post date:** [November 14, 2016, 11:01pm UTC](https://discuss.elastic.co/t/get-which-condition-a-result-matched-when-using-bool-should-query/66034/1 "2016-11-14T23:01:41Z")

</div>

I'm querying Elasticsearch with a bool should query. The returned document match one or more conditions in the should query. Is there anyway for me to know which (one or more) condition it matched from Elasticsearch's response?

Much appreciated!

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [November 15, 2016, 3:11am UTC](https://discuss.elastic.co/t/get-which-condition-a-result-matched-when-using-bool-should-query/66034/2 "2016-11-15T03:11:58Z")

</div>

You can add

```
"_name": "foo bar"

```

In each query and see the effect.

---

<div class="post-metadata">

**Author:** ![suanmeiguo](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/suanmeiguo/32/11758_2.png) [@suanmeiguo](https://discuss.elastic.co/u/suanmeiguo)\
**Post date:** [November 15, 2016, 6:14pm UTC](https://discuss.elastic.co/t/get-which-condition-a-result-matched-when-using-bool-should-query/66034/3 "2016-11-15T18:14:06Z")

</div>

Works great. Thank you!

---

<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:** [December 13, 2016, 6:14pm UTC](https://discuss.elastic.co/t/get-which-condition-a-result-matched-when-using-bool-should-query/66034/4 "2016-12-13T18:14:15Z")

</div>

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