# When placed inside a filter, does query perform the scoring task?

**URL:** <https://discuss.elastic.co/t/when-placed-inside-a-filter-does-query-perform-the-scoring-task/47380>\
**Category:** Elasticsearch\
**Created:** [April 14, 2016, 12:21pm UTC](https://discuss.elastic.co/t/when-placed-inside-a-filter-does-query-perform-the-scoring-task/47380 "2016-04-14T12:21:20Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ashish\_Goel](https://avatars.discourse-cdn.com/v4/letter/a/c2a13f/32.png) [@Ashish\_Goel](https://discuss.elastic.co/u/Ashish_Goel)\
**Post date:** [April 14, 2016, 12:21pm UTC](https://discuss.elastic.co/t/when-placed-inside-a-filter-does-query-perform-the-scoring-task/47380/1 "2016-04-14T12:21:20Z")

</div>

Please note: I am using Elasticsearch 1.5.0

For the sake of providing an example, I have placed a single query clause inside a bool filter.

> {  
> "filter": {  
> "bool" : {  
> "must": [  
> {  
> "query": {  
> "match": {  
> "my\_field": "my\_value"  
> }  
> }  
> }  
> ]  
> }  
> }  
> }

My question is that when the query clause is to be executed, will it perform the scoring task even though the query is present inside a filter?

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [April 14, 2016, 12:59pm UTC](https://discuss.elastic.co/t/when-placed-inside-a-filter-does-query-perform-the-scoring-task/47380/2 "2016-04-14T12:59:15Z")

</div>

Hey,

no, see the note mentioned at [https://www.elastic.co/guide/en/elasticsearch/reference/1.5/query-dsl-query-filter.html](https://www.elastic.co/guide/en/elasticsearch/reference/1.5/query-dsl-query-filter.html)

Hope this helps.

--Alex

---

<div class="post-metadata">

**Author:** ![Ashish\_Goel](https://avatars.discourse-cdn.com/v4/letter/a/c2a13f/32.png) [@Ashish\_Goel](https://discuss.elastic.co/u/Ashish_Goel)\
**Post date:** [April 14, 2016, 3:18pm UTC](https://discuss.elastic.co/t/when-placed-inside-a-filter-does-query-perform-the-scoring-task/47380/3 "2016-04-14T15:18:45Z")

</div>

Thanks Alex.

---

<div class="post-metadata">

**Author:** ![Ashish\_Goel](https://avatars.discourse-cdn.com/v4/letter/a/c2a13f/32.png) [@Ashish\_Goel](https://discuss.elastic.co/u/Ashish_Goel)\
**Post date:** [April 14, 2016, 4:41pm UTC](https://discuss.elastic.co/t/when-placed-inside-a-filter-does-query-perform-the-scoring-task/47380/4 "2016-04-14T16:41:12Z")

</div>

Discovered something interesting. As Alex mentioned above, the query will not be performing the scoring in the example above.  
But, if I modify the example in the manner below:

> {  
> "filter": {  
> "has\_parent": {  
> "type": "my\_parent\_type",  
> "query": {  
> "match": {  
> "name\_s": "my\_name"  
> }  
> },  
> "inner\_hits": {  
> "\_source": "name"  
> }  
> }  
> }  
> }

In this case, the output of the query shows score being calculated for the inner\_hit. Although, that score is ignored by the main filter leading to final score of the hit being equal to 1.  
It must be because of the has\_parent clause that the filter context from the main filter was not passed down to the query in the has\_parent clause.

---

<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, 10:59pm UTC](https://discuss.elastic.co/t/when-placed-inside-a-filter-does-query-perform-the-scoring-task/47380/5 "2017-07-05T22:59:07Z")

</div>


