Can we combine query_string and multi_match queries?

(Sandhya) #1

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": "
"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.

(Mayya Sharipova) #3

If you want to search for a phrase like data structure, a suitable query type would be Match Phrase Query:

(system) #4

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.