# Filter and Match all order

**URL:** <https://discuss.elastic.co/t/filter-and-match-all-order/5274>\
**Category:** Elasticsearch\
**Created:** [August 30, 2011, 5:04am UTC](https://discuss.elastic.co/t/filter-and-match-all-order/5274 "2011-08-30T05:04:12Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![BeckerIV](https://avatars.discourse-cdn.com/v4/letter/b/f05b48/32.png) [@BeckerIV](https://discuss.elastic.co/u/BeckerIV)\
**Post date:** [August 30, 2011, 5:04am UTC](https://discuss.elastic.co/t/filter-and-match-all-order/5274/1 "2011-08-30T05:04:12Z")

</div>

> <https://gist.github.com/sbeckeriv/1180213>

I have an index and I am getting a geo\_bounding\_box with lat and long  
from google maps. With out the extra filter the query works fine.

I am using elasticsearch head page to debug this. When I use this part  
of the query  
"query": {  
"match\_all": {},  
"filter": {  
"range": {  
"inspection\_score": {  
"from": 30  
}  
}  
}  
}

It works fine. When I switch the order of match\_all and filter the  
query does not parse. Please see gist for the full query details. I am  
using code to generate the json and it puts the filter in front of the  
match all so it breaks.

---

<div class="post-metadata">

**Author:** ![BeckerIV](https://avatars.discourse-cdn.com/v4/letter/b/f05b48/32.png) [@BeckerIV](https://discuss.elastic.co/u/BeckerIV)\
**Post date:** [August 30, 2011, 5:14am UTC](https://discuss.elastic.co/t/filter-and-match-all-order/5274/2 "2011-08-30T05:14:39Z")

</div>

I moved the range part in to the filter with the bounding\_box as an  
and statement.  
I updated the bottom of the gist with my new working query. It is odd  
to me still  
that one query works well and the other errors.

My new query that works fine  
{  
"query": {  
"filtered": {  
"filter": {  
"and": [  
{  
"geo\_bounding\_box": {  
"location": {  
"bottom\_right": [  
-122.315513187315,  
47.6137317545592  
],  
"top\_left": [  
-122.320740812685,  
47.6149522383193  
]  
}  
}  
},  
{  
"range": {  
"inspection\_score": {  
"from": 50  
}  
}  
}  
]  
},  
"query": {  
"match\_all": {}  
}  
}  
}  
}

On Aug 29, 10:04 pm, BeckerIV [sbecke...@gmail.com](mailto:sbecke...@gmail.com) wrote:

> [query problem · GitHub](https://gist.github.com/1180213)
> 
> I have an index and I am getting a geo\_bounding\_box with lat and long  
> from google maps. With out the extra filter the query works fine.
> 
> I am using elasticsearch head page to debug this. When I use this part  
> of the query  
> "query": {  
> "match\_all": {},  
> "filter": {  
> "range": {  
> "inspection\_score": {  
> "from": 30  
> }  
> }  
> }  
> }
> 
> It works fine. When I switch the order of match\_all and filter the  
> query does not parse. Please see gist for the full query details. I am  
> using code to generate the json and it puts the filter in front of the  
> match all so it breaks.

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [August 30, 2011, 2:20pm UTC](https://discuss.elastic.co/t/filter-and-match-all-order/5274/3 "2011-08-30T14:20:35Z")

</div>

Heya,

Yea, thats the correct format. The query parsing is a bit too lenient, and  
if it can be parsed, it will be...

On Tue, Aug 30, 2011 at 8:14 AM, BeckerIV [sbeckeriv@gmail.com](mailto:sbeckeriv@gmail.com) wrote:

> I moved the range part in to the filter with the bounding\_box as an  
> and statement.  
> I updated the bottom of the gist with my new working query. It is odd  
> to me still  
> that one query works well and the other errors.
> 
> My new query that works fine  
> {  
> "query": {  
> "filtered": {  
> "filter": {  
> "and": [  
> {  
> "geo\_bounding\_box": {  
> "location": {  
> "bottom\_right": [  
> -122.315513187315,  
> 47.6137317545592  
> ],  
> "top\_left": [  
> -122.320740812685,  
> 47.6149522383193  
> ]  
> }  
> }  
> },  
> {  
> "range": {  
> "inspection\_score": {  
> "from": 50  
> }  
> }  
> }  
> ]  
> },  
> "query": {  
> "match\_all": {}  
> }  
> }  
> }  
> }
> 
> On Aug 29, 10:04 pm, BeckerIV [sbecke...@gmail.com](mailto:sbecke...@gmail.com) wrote:
> 
> > [query problem · GitHub](https://gist.github.com/1180213)
> > 
> > I have an index and I am getting a geo\_bounding\_box with lat and long  
> > from google maps. With out the extra filter the query works fine.
> > 
> > I am using elasticsearch head page to debug this. When I use this part  
> > of the query  
> > "query": {  
> > "match\_all": {},  
> > "filter": {  
> > "range": {  
> > "inspection\_score": {  
> > "from": 30  
> > }  
> > }  
> > }  
> > }
> > 
> > It works fine. When I switch the order of match\_all and filter the  
> > query does not parse. Please see gist for the full query details. I am  
> > using code to generate the json and it puts the filter in front of the  
> > match all so it breaks.

---

<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, 3:55am UTC](https://discuss.elastic.co/t/filter-and-match-all-order/5274/4 "2017-07-06T03:55:32Z")

</div>

Closed on July 6, 2017, 3:55am UTC


