Ask about the usage of negative query_string

I've read the latest documentation and am sure I can't answer my question.
https://www.elastic.co/guide/en/elasticsearch/reference/7.8/query-dsl-query-string-query.html#query-string-syntax

The first DSL syntax succeeded

> GET /_search
> {
>   "query": {
>     "query_string": {
>       "query": "(Succeed: false) AND NOT Error: bpm_warnning AND NOT Error: 本任务已经处理"
>     }
>   }
> }

If only the NOT condition is left, the elastic search results are a bit strange

> GET /_search
> {
>   "query": {
>     "query_string": {
>       "query": "NOT Error: 本任务已经处理"
>     }
>   }
> }

The same negative syntax using simple_query_string will have similar results.

> GET /_search
> {
>   "query": {
>     "simple_query_string": {
>       "fields": [ "Error" ],
>       "query": "-bpm_warnning"
>     }
>   }
> }

Please do not use screenshots, but snippets and written text. Screenshots are hard to read for some people. Thanks!

You are searching across all indices, which includes an system internal index called .async-search, which contains a document that does not contain the field you are searching for, so this is a match.

TLDR; Always specify the index you are searching in!

Thank you. I found the problem

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