I am using ES 7.10.2
I have fields with keyword and text mappings.
When user specifies the search string, I wanted to parse the pieces of search string, then match each of those piece to each specific field, in the specific way that field mapping is configured, such that using same analyzer get used by search query as provided in field mapping.
For this requirement I am using Query-String-Query, I validated the above statement using _validate query.
But the same is also seems to be true, regarding Multi_Match query.
See below example:
POST /testindex/_doc/1
{"id":1,"firstname":"john","middlename":"clark","lastname":"smith"}
POST /testindex/_doc/2
{"id":2,"firstname":"john","middlename":"paladini","lastname":"miranda"}
Now When I use validate query for both Multi_Match and Query_String_Query
GET testindex/_validate/query?pretty=true&explain=true
{
"query": {
"multi_match" : {
"operator" : "or",
"fields" : [
"firstname",
"lastname",
"firstname.keyword",
"lastname.keyword"
],
"query" : "john smith"
}
}
}
GET testindex/_validate/query?pretty=true&explain=true
{
"query": {
"query_string": {
"default_operator": "OR",
"fields" : [
"firstname",
"lastname",
"firstname.keyword",
"lastname.keyword"
],
"query" : "john smith"
}
}
}
Both of them produce the exact same explanation:
{
"_shards" : {
"total" : 1,
"successful" : 1,
"failed" : 0
},
"valid" : true,
"explanations" : [
{
"index" : "testindex",
"valid" : true,
"explanation" : "((firstname:john firstname:smith) | firstname.keyword:john smith | lastname.keyword:john smith | (lastname:john lastname:smith))"
}
]
}
I know that QSQ is sensitive to invalid syntax.
Then what can be the difference between Multi_Match and QSQ ? are there any performace consideration ? and though multi_match is based on match it seems to behave fine with keyword field also?