# Ask about the usage of negative query\_string

**URL:** <https://discuss.elastic.co/t/ask-about-the-usage-of-negative-query-string/243412>\
**Category:** Elasticsearch\
**Created:** [August 1, 2020, 2:28am UTC](https://discuss.elastic.co/t/ask-about-the-usage-of-negative-query-string/243412 "2020-08-01T02:28:03Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![wajika](https://avatars.discourse-cdn.com/v4/letter/w/977dab/32.png) [@wajika](https://discuss.elastic.co/u/wajika)\
**Post date:** [August 1, 2020, 2:28am UTC](https://discuss.elastic.co/t/ask-about-the-usage-of-negative-query-string/243412/1 "2020-08-01T02:28:03Z")

</div>

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](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: 本任务已经处理"
> }
> }
> }

```

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/3/b/3b34c95b2814c4f60d6025b81092a7ed6a79771b.png)

The same negative syntax using simple\_query\_string will have similar results.

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

---

<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 3, 2020, 9:39am UTC](https://discuss.elastic.co/t/ask-about-the-usage-of-negative-query-string/243412/2 "2020-08-03T09:39:18Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![wajika](https://avatars.discourse-cdn.com/v4/letter/w/977dab/32.png) [@wajika](https://discuss.elastic.co/u/wajika)\
**Post date:** [August 5, 2020, 1:01am UTC](https://discuss.elastic.co/t/ask-about-the-usage-of-negative-query-string/243412/3 "2020-08-05T01:01:21Z")

</div>

Thank you. I found the problem

---

<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 2, 2020, 1:01am UTC](https://discuss.elastic.co/t/ask-about-the-usage-of-negative-query-string/243412/4 "2020-09-02T01:01:27Z")

</div>

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