Simple Query string returns documents based on a provided query
string, using a parser with a limited but fault-tolerant syntax.
Refer this to get a detailed explanation, which states that :
The simple_query_string query is a version of the query_string query
that is more suitable for use in a single search box that is exposed
to users because it replaces the use of AND/OR/NOT with +/|/-,
respectively, and it discards invalid parts of a query instead of
throwing an exception if a user makes a mistake.
It supports Lucene syntax to interpret the text, you can refer this article that gives detailed information about how simple query string works.
Match Query returns documents that match a provided text, number, date
or boolean value. The provided text is analyzed before matching.
Refer to this ES documentation part and this blog, to understand how the match query works
I have tried to run this below search query using both simple query string and match query:
Index Data
{
"content":"foo bar -baz"
}
Search Query using simple query string:
{
"query": {
"simple_query_string": {
"fields": [ "content" ],
"query": "foo bar -baz"
}
}
}
Search Result:
"hits": [
{
"_index": "stof_63937563",
"_type": "_doc",
"_id": "1",
"_score": 0.5753642, <-- note this
"_source": {
"content": "foo bar -baz"
}
}
]
Search Query using match query:
{
"query": {
"match": {
"content": {
"query": "foo bar -baz"
}
}
}
}
Search Result:
"hits": [
{
"_index": "stof_63937563",
"_type": "_doc",
"_id": "1",
"_score": 0.8630463, <-- note this
"_source": {
"content": "foo bar -baz"
}
}
]
Please refer this SO answer that explains the difference between multi_match
and query_string