# Query on Filtered query

**URL:** <https://discuss.elastic.co/t/query-on-filtered-query/37625>\
**Category:** Elasticsearch\
**Created:** [December 19, 2015, 6:29pm UTC](https://discuss.elastic.co/t/query-on-filtered-query/37625 "2015-12-19T18:29:08Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pradeep\_Gupta](https://avatars.discourse-cdn.com/v4/letter/p/a8b319/32.png) [@Pradeep\_Gupta](https://discuss.elastic.co/u/Pradeep_Gupta)\
**Post date:** [December 19, 2015, 6:29pm UTC](https://discuss.elastic.co/t/query-on-filtered-query/37625/1 "2015-12-19T18:29:08Z")

</div>

we are trying below simple query. Here filter working as expected but query match\_all = travel is not working. I am expecting that below query should first look for all documents having "travel" any where, then it should filter documents based on cityname and weather.

But results only shows documents from filtered section. Some how it is not executing query portion.

{  
"query": {  
"filtered": {  
"query": {  
"match": {  
"\_all": "travel"  
},  
"filter": {  
"bool": {  
"must": [  
{  
"terms": {  
"cityname": [  
"bangalore",  
"delhi"  
]  
}  
},  
{  
"terms": {  
"weather": [  
"winter",  
"spring"  
]  
}  
}  
]  
}  
}  
}  
}  
}  
}

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [December 19, 2015, 6:52pm UTC](https://discuss.elastic.co/t/query-on-filtered-query/37625/2 "2015-12-19T18:52:08Z")

</div>

Hard to say without a full script.  
May be mapping issue?

BTW I'd not use \_all but copy\_to feature instead.

---

<div class="post-metadata">

**Author:** ![Pradeep\_Gupta](https://avatars.discourse-cdn.com/v4/letter/p/a8b319/32.png) [@Pradeep\_Gupta](https://discuss.elastic.co/u/Pradeep_Gupta)\
**Post date:** [December 20, 2015, 3:16am UTC](https://discuss.elastic.co/t/query-on-filtered-query/37625/3 "2015-12-20T03:16:20Z")

</div>

i got the issue in my query. I had placed filter inside the query tag. But It should have been sibling to query as i wanted to use query and filter both together.

---

<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 5, 2017, 11:29pm UTC](https://discuss.elastic.co/t/query-on-filtered-query/37625/4 "2017-07-05T23:29:45Z")

</div>


