# Performances differences between 0.20.x and 0.90 with filtered queries

**URL:** <https://discuss.elastic.co/t/performances-differences-between-0-20-x-and-0-90-with-filtered-queries/15202>\
**Category:** Elasticsearch\
**Created:** [January 10, 2014, 4:50pm UTC](https://discuss.elastic.co/t/performances-differences-between-0-20-x-and-0-90-with-filtered-queries/15202 "2014-01-10T16:50:10Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Frederick\_Cheung](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/frederick_cheung/32/1874_2.png) [@Frederick\_Cheung](https://discuss.elastic.co/u/Frederick_Cheung)\
**Post date:** [January 10, 2014, 4:50pm UTC](https://discuss.elastic.co/t/performances-differences-between-0-20-x-and-0-90-with-filtered-queries/15202/1 "2014-01-10T16:50:10Z")

</div>

Hi,

I'm in the process of planning an upgrade from ES 0.20.6 to ES 0.90.9 and  
have run across 2 performance gotchas.

The first is that a plain filtered query with a match\_all query and some  
filters on numeric attributes of the documents against ES 0.90.9 using the  
index build by ES 0.20.6 were about 2x slower than queries against ES  
0.20.6. Rebuilding the index against ES 0.90.9 eliminated that performance  
difference. Is this something to be expected?

The second concerns a pair of queries: a filtered query wrapping a custom  
score query, and in the second case a custom score query wrapping a  
filtered query. In both cases the actual filters, parameters to the custom  
scoring function are the same (I've included the queries below)

In the first case (filtered query wrapping a custom score) ES 0.90.9 is  
much slower (around 40ms) than ES 0.20.6 (5-6ms)

In the second case (custom score wrapping the filtered query) both ES  
0.20.6 and 0.90.9 perform very similarly (5-6ms)

So ES 0.20.6 doesn't seem to care which way around I do the filtering  
versus the custom scoring, whereas ES 0.90.9 seems to care very much. Is  
this expected? Does elastic search run queries 'from the inside out' ?

Thanks,

Fred

query1:

{  
"query": {  
"filtered": {  
"query": {  
"custom\_score": {  
"script": "recommendationscorer",  
"lang": "native",  
"params": {  
...  
},  
"query": {  
"match\_all": {}  
}  
}  
},  
"filter": {  
"and": [{  
"range": {  
"scores.144": {  
"gt": 0.5  
}  
}  
}, {  
"terms": {  
"retailer\_ids": [192]  
}  
}, {  
"term": {  
"garment\_category\_id": [1]  
}  
}]  
}  
}  
},  
"size": 8,  
"min\_score": 0.5,  
"from": 0,  
"fields": ["id"]  
}

query2:  
{  
"query": {  
"custom\_score": {  
"script": "recommendationscorer",  
"lang": "native",  
"params": {  
...  
},  
"query": {  
"filtered": {  
"query": {  
"match\_all": {}  
},  
"filter": {  
"and": [{  
"range": {  
"scores.144": {  
"gt": 0.5  
}  
}  
}, {  
"terms": {  
"retailer\_ids": [192]  
}  
}, {  
"term": {  
"garment\_category\_id": [1]  
}  
}]  
}  
}  
}  
}  
},  
"size": 8,  
"min\_score": 0.5,  
"from": 0,  
"fields": ["id"]  
}

--  
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).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/d1a9a190-d011-419e-bf63-63e965f75b3e%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/d1a9a190-d011-419e-bf63-63e965f75b3e%40googlegroups.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, 1:57am UTC](https://discuss.elastic.co/t/performances-differences-between-0-20-x-and-0-90-with-filtered-queries/15202/2 "2017-07-06T01:57:23Z")

</div>

Closed on July 6, 2017, 1:57am UTC


