Skip to content

Stop-words not removed during simple-query query-time analysis #28855

@mohmad-null

Description

@mohmad-null

ES 6.2.1
I've noticed that the simple-query-string query type (https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-simple-query-string-query.html) doesn't seem to handle stopwords at all at analysis time, best exemplified with "default_operator: AND".

Consider the below - We create an index and change the default analyzer to use English stopwords:

PUT /simp_idx
{
  "mappings": {
    "my_type": {
      "properties": {
  		"field_1": {
    			"type": "text"
    		}
      }
    }
  },
  	"settings": {
		"number_of_shards": 1,
		"number_of_replicas": 0,
		"analysis": {

			"filter": {
				"english_stop": {
					"type": "stop",
					"stopwords": "_english_"
				}
			},
			"analyzer": {
				"default": {
					"tokenizer": "standard",
					"filter": [
						"english_stop"
					]
				}
			}
		}
	}
}

And then populate it:

PUT /simp_idx/my_type/1
{
  "field_1": "place of beauty"
}
PUT /simp_idx/my_type/2
{
  "field_1": "place and beauty"
}

Now, if we query this with the regular query_string, we get the expected two results:

GET /simp_idx/my_type/_search
{
  "query": {
    "query_string" : {
        "query": "place of",
        "default_operator": "and"
    }
  }
}

But the same query using simple-query-string and the AND operator finds no results:

GET /simp_idx/my_type/_search
{
  "query": {
    "simple_query_string" : {
        "query": "place of",
			"fields": [ "field_1"],
        "default_operator": "and"
    }
  }
}

Remove the "of" from the query and it will work as expected.

Maybe this is intentional because the SQS is "simple", but it's not documented on the SQS page - the only explicitly stated difference is no exception raising. Seems like a bug though, hence the report.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions