# Create a query for which a result field is contained in the query text

**URL:** <https://discuss.elastic.co/t/create-a-query-for-which-a-result-field-is-contained-in-the-query-text/11977>\
**Category:** Elasticsearch\
**Created:** [May 15, 2013, 3:00pm UTC](https://discuss.elastic.co/t/create-a-query-for-which-a-result-field-is-contained-in-the-query-text/11977 "2013-05-15T15:00:03Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gian\_Reto\_a\_Porta](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gian_reto_a_porta/32/2332_2.png) [@Gian\_Reto\_a\_Porta](https://discuss.elastic.co/u/Gian_Reto_a_Porta)\
**Post date:** [May 15, 2013, 3:00pm UTC](https://discuss.elastic.co/t/create-a-query-for-which-a-result-field-is-contained-in-the-query-text/11977/1 "2013-05-15T15:00:03Z")

</div>

Hi

I have the following problem: I would like to create a query in  
ElasticSearch for which a field of the result should be contained in the  
query text.

Example Query:

{  
"query":{  
"match":{  
"city\_name":"Not related Text plus Wil AG"  
}  
}  
}

Result:  
{  
"\_index": "cities",  
"\_type": "city",  
"\_id": "z61KRT6QR32dTniAn0\_ApQ",  
"\_score": 6.063552,  
"\_source": {  
"country": "CH",  
"city\_name": "Birmenstorf AG"  
}  
}

I would like to define in the query that the field "city\_name" of the  
result (Birmenstorf AG) has to be contained in the query text (Not related  
Text plus Wil AG) o be a match.

Can I do this with ElasticSearch?

Thanks a lot for your help.

Regards  
Gian

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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:** [July 6, 2017, 2:36am UTC](https://discuss.elastic.co/t/create-a-query-for-which-a-result-field-is-contained-in-the-query-text/11977/2 "2017-07-06T02:36:30Z")

</div>


