# Cannot get desired query results with filter

**URL:** <https://discuss.elastic.co/t/cannot-get-desired-query-results-with-filter/244680>\
**Category:** Elasticsearch\
**Created:** [August 12, 2020, 8:39am UTC](https://discuss.elastic.co/t/cannot-get-desired-query-results-with-filter/244680 "2020-08-12T08:39:23Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![vinodkrishnanr](https://avatars.discourse-cdn.com/v4/letter/v/ea5d25/32.png) [@vinodkrishnanr](https://discuss.elastic.co/u/vinodkrishnanr)\
**Post date:** [August 12, 2020, 8:39am UTC](https://discuss.elastic.co/t/cannot-get-desired-query-results-with-filter/244680/1 "2020-08-12T08:39:24Z")

</div>

Hi

Im trying to understand why the below query does not produce the results.

```auto
{
    "query": {
        "bool": {
                    "filter": {
                        "terms": {
                            "classification": [
                                "secret",
                                "protected"
                            ]
                        }
            },
            "must": {
                "query_string": {
                    "query": "*Johnson*",
                    "fields": [
                        "classification",
                        "firstname",
                        "releasability",
                        "person"
                    ]
                }
            }
        }
    }
}

```

So we do have 'Johnson' in elasticsearch in the field person, but the result hit shows 0.

The expected output should be having hits with field Person having 'Johnson'

The filter should work only for field Classification with the values secret and protected, however, as for Person field there should be no filter applied.

If I remove the filter from the above query, it works when searched for Johnson, however the filter needs to be included to filter out some values

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [August 12, 2020, 8:46am UTC](https://discuss.elastic.co/t/cannot-get-desired-query-results-with-filter/244680/2 "2020-08-12T08:46:35Z")

</div>

please provide an exact reproduction that also contains index creation, mapping and document indexing in order to fully understand what you are doing. This helps to prevent guesswork. See also [https://www.elastic.co/help](https://www.elastic.co/help)

Thanks!

---

<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:** [September 9, 2020, 8:46am UTC](https://discuss.elastic.co/t/cannot-get-desired-query-results-with-filter/244680/3 "2020-09-09T08:46:36Z")

</div>

Closed on September 9, 2020, 8:46am UTC

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