Hi
I am facing one issue while using query_string. For strings having space it's not applying synonyms filter but same thing is working with match query .
index creation script-
PUT my_index1 { "settings": { "analysis": { "filter": { "content_synonyms": { "type": "synonym", "synonyms": [ "air print => airprint" ] } }, "analyzer": { "search_a": { "filter": [ "lowercase", "content_synonyms" ], "type": "custom", "tokenizer": "standard" }, "index_a": { "filter": [ "lowercase" ], "type": "custom", "tokenizer": "standard" } } } }, "mappings": { "test": { "properties": { "body": { "type": "text", "analyzer": "index_a", "search_analyzer": "search_a", "search_quote_analyzer": "index_a" } } } } } PUT my_index1/test/3 {"body": "air"} PUT my_index1/test/2 {"body": "print"} PUT my_index1/test/1 {"body": "airprint"}
query_string I am using-
GET my_index1/test/_search?explain { "size": 10, "query": { "query_string": { "query": "body:(air print)" } } }
query_string response -
[ { "_index": "my_index1", "_type": "test", "_id": "2", "_score": 0.2876821, "_source": { "body": "print" } }, { "_index": "my_index1", "_type": "test", "_id": "3", "_score": 0.2876821, "_source": { "body": "air" } } ]
I was expecting the 1st doc with "airprint"
In explain of query response(weight(body:print in 0) & weight(body:air in 0)) we can see it's only splitting as per tokenizer but not applying "air print => airprint" synonyms but while using same with match query synonyms are applied.
match query-
GET my_index1/test/_search?explain { "query": { "match": { "body": "air print" } } }
response-
[ { "_index": "my_index1", "_type": "test", "_id": "1", "_score": 0.2876821, "_source": { "body": "airprint" } } ]
Here it's applying "air print => airprint" synonyms & returning the 1st docs with "airprint" & applying the synonyms. We can check the explain of this query(weight(body:airprint in 0)).
It's kind weird to me why synonyms (when strings with space) not working with query_string but same thing works with match query. I was thinking both (match query & query_string) internally worked almost similar.
Can anyone explain this please?
I am using ES version 5.6.1