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.