# Can we combine query\_string and multi\_match queries?

**URL:** https://discuss.elastic.co/t/can-we-combine-query-string-and-multi-match-queries/118192
**Category:** Elasticsearch
**Created:** [February 2, 2018, 9:13am UTC](https://discuss.elastic.co/t/can-we-combine-query-string-and-multi-match-queries/118192 "2018-02-02T09:13:22Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![sps2018](https://avatars.discourse-cdn.com/v4/letter/s/76d3ee/32.png) [@sps2018](https://discuss.elastic.co/u/sps2018)
#### Post date: [February 2, 2018, 9:13am UTC](https://discuss.elastic.co/t/can-we-combine-query-string-and-multi-match-queries/118192/1 "2018-02-02T09:13:22Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![mayya](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mayya/32/83147_2.png) [@mayya](https://discuss.elastic.co/u/mayya)
#### Post date: [February 15, 2018, 6:34pm UTC](https://discuss.elastic.co/t/can-we-combine-query-string-and-multi-match-queries/118192/3 "2018-02-15T18:34:34Z")

</div>

If you want to search for a phrase like `data structure`, a suitable query type would be `Match Phrase Query`: [https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-match-query-phrase.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-match-query-phrase.html)

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [March 15, 2018, 6:35pm UTC](https://discuss.elastic.co/t/can-we-combine-query-string-and-multi-match-queries/118192/4 "2018-03-15T18:35:13Z")

</div>

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