Hi,
I want to create a query for fetching data from elasticsearch which can search for both single and multi-word queries.
For eg, If I search for the keyword : "run" ; it should search for run like Bruno, run, Rune, Irungu etc.
and If I search for keyword : "data structure"; it should return the documents having "data structure" (exact matching).
I have created a query as below:
{
"query": {
"bool": {
"should": [
{
"query_string": {
"fields": [ "" ],
"query": ""+searchTerm+"*"
}
},
{
"multi_match": {
"query": searchTerm,
"operator": "and"
}
}
]
}
}
}
It is working fine when I searched for single word query but not when searched with multiword.
Please correct what I'm doing wrong.