Cannot get desired query results with filter

Hi

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

{
    "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

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

Thanks!

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