I want to perform both exact word match and partial word/sub string match. For example, if I search for "test product"
then I should be able to find "test"
and "product"
related text in the result. I'm searching Elasticsearch with the below match query, which is not giving me the exact match, instead its giving some more irrelevant match.
I'm using Elasticsearch 6.3
My query for GET /_search
:
{
"must": {
"query_string": {
"query": "title:*test product*"
}
}
}
Search Result:
"hits": [
{
"_index": "67107104",
"_type": "_doc",
"_id": "1",
"_score": 0.6931471,
"_source": {
"title": "testing"
}
},
{
"_index": "67107104",
"_type": "_doc",
"_id": "2",
"_score": 0.6931471,
"_source": {
"title": "product good"
}
},
{
"_index": "67107104",
"_type": "_doc",
"_id": "3",
"_score": 0.6931471,
"_source": {
"title": "sample"
}
}
]
Expected Search Result:
"hits": [
{
"_index": "67107104",
"_type": "_doc",
"_id": "1",
"_score": 0.6931471,
"_source": {
"title": "testing"
}
},
{
"_index": "67107104",
"_type": "_doc",
"_id": "2",
"_score": 0.6931471,
"_source": {
"title": "product good"
}
}
]
In the search query above, you are searching in the
review
field, whereas in the search result you are getting data fortitle
fieldAdding a working example with index data, search query, and search result
Index Data:
Search Query:
Search Result: