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

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?

Hey,

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

Hope this helps.

--Alex

1 Like

Thanks Alex.

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.