Enable_position_increments not working for phrase queries with stopwords

I'm following this guide https://stackoverflow.com/questions/31719249/how-to-query-a-phrase-with-stopwords-in-elasticsearch to run phrase queries against text with stopwords removed, and the verified answer doesn't work in Elasticsearch 7. Setting enable_position_increments to false in my query_string query doesn't do anything at all.

PUT /fr_articles
{
   "settings": {
      "analysis": {
         "analyzer": {
            "stop": {
               "type": "standard",
               "stopwords" : ["the"]
            }
         }
      }
   },
   "mappings": {
      "properties": {
            "title": {
               "type": "text",
               "analyzer": "stop"
            }
         }
   }
}
POST /fr_articles/test/1
{
    "title" : "Tom the king of Toulon!"
}
POST /fr_articles/_search
{
   "query": {
      "query_string": {
         "default_field": "title",
         "query" : "\"tom king\"",
         "enable_position_increments": false
      }
   }
}

This returns 0 results.

I don't want to use slop because then you lose control over what's the word that gets between the two other words.

Hi there,

I'm facing the same problem today... Same example, same version, same unexpected behavior...

Maybe we misunderstood the enable_position_increments option in query_string ?

Thanks for any help !

I wish someone from the Elastic or Lucene team would clarify this :frowning:

Hi ! The question has been answered here : https://github.com/elastic/elasticsearch/issues/43574

Have a nice day !

From the issue it looks like it was a bug?

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