# Stop words if present in query\_string query behaving different in elastic 6.2 and 7.5

**URL:** <https://discuss.elastic.co/t/stop-words-if-present-in-query-string-query-behaving-different-in-elastic-6-2-and-7-5/282675>\
**Category:** Elasticsearch\
**Created:** [August 27, 2021, 1:39pm UTC](https://discuss.elastic.co/t/stop-words-if-present-in-query-string-query-behaving-different-in-elastic-6-2-and-7-5/282675 "2021-08-27T13:39:57Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![nishant.saini](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nishant.saini/32/41489_2.png) [@nishant.saini](https://discuss.elastic.co/u/nishant.saini)\
**Post date:** [August 27, 2021, 1:39pm UTC](https://discuss.elastic.co/t/stop-words-if-present-in-query-string-query-behaving-different-in-elastic-6-2-and-7-5/282675/1 "2021-08-27T13:39:57Z")

</div>

I'm unable to understand why the below query is behaving differently in the two versions.

```auto
{
  "query": {
    "bool": {
      "must": [
        {
          "query_string": {
            "query": "(field1:\"best\"^300 AND fields2:\"DUMMYSTR\"^200)",
            "fields": [],
            "type": "best_fields",
            "phrase_slop": 0,
            "boost": 1
          }
        }
      ],
      "boost": 1
    }
  }
}

```

Both `field1` and `field2` use same analyzer. `best` is a stop word and `DUMMYSTR` is present in all docs.  
In **ES 6.2.2** version the query returns 0 documents which is the expected result.  
In **ES 7.5.2** version the query parser seems to ignore the first part of the query i.e. `field1:\"best\"^300` as `best` is stop word and hence this part of the query has no terms left. Whereas since `DUMMYSTR` is present in all the documents the second part of the query matches all the docs and the same is returned in the result.

The \_validate api with explain returns the same explanation in both the versions which is

```auto
{
  "valid": true,
  "_shards": {
    "total": 1,
    "successful": 1,
    "failed": 0
  },
  "explanations": [
    {
      "index": "my_index",
      "valid": true,
      "explanation": """+(+(MatchNoDocsQuery("Matching no documents because no terms present."))^300.0 +(field2:dummystr)^200.0)"""
    }
  ]
}

```

1. Which version has the correct behaviour and why different behaviour?
2. What modification should I do in the query to achieve the same behaviour in ES 7.5 as well? One solution I can think is to create an analyzer to be used in search without the stop words filter. Any other suggestions?

---

<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 24, 2021, 1:40pm UTC](https://discuss.elastic.co/t/stop-words-if-present-in-query-string-query-behaving-different-in-elastic-6-2-and-7-5/282675/2 "2021-09-24T13:40:52Z")

</div>

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