# How to stop score calculating?

**URL:** <https://discuss.elastic.co/t/how-to-stop-score-calculating/152398>\
**Category:** Elasticsearch\
**Created:** [October 14, 2018, 5:02pm UTC](https://discuss.elastic.co/t/how-to-stop-score-calculating/152398 "2018-10-14T17:02:11Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![hym](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/hym/32/22399_2.png) [@hym](https://discuss.elastic.co/u/hym)\
**Post date:** [October 14, 2018, 5:02pm UTC](https://discuss.elastic.co/t/how-to-stop-score-calculating/152398/1 "2018-10-14T17:02:11Z")

</div>

I have a couple of questions in my mind regarding query tuning in Elastic search

1. Sometimes score for result hits are null, though the query written in **Query Context** , why?
2. Is there any configuration in Elastic search to disable score calculation?
3. Generally speaking, how expensive score calculation is?
4. I am used to wrapping all my queries in a **bool { filter }** to take them into the filter context, Is this a right strategy to force queries to run in a filter context or there are better ways?

Thanks in advance

---

<div class="post-metadata">

**Author:** ![polyfractal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/polyfractal/32/48162_2.png) [@polyfractal](https://discuss.elastic.co/u/polyfractal)\
**Post date:** [October 22, 2018, 4:51pm UTC](https://discuss.elastic.co/t/how-to-stop-score-calculating/152398/2 "2018-10-22T16:51:18Z")

</div>

1. I believe this happens if the document doesn't have any fields that are in the query. There's nothing to score so the score is null. I might be wrong about this though, would have to look at the docs and query in question

2. Putting all the query components in a filtering context will entirely disable scoring. It'll just be looking for match/no-match

3. Scoring is fairly cheap, it's essentially a few extra math operations per document (you can see the BM-25 algorithm here: [https://www.elastic.co/blog/practical-bm25-part-2-the-bm25-algorithm-and-its-variables](https://www.elastic.co/blog/practical-bm25-part-2-the-bm25-algorithm-and-its-variables)). But if you're repeating that scoring operation for a dozen query components times a few billion matching documents... it can add up.

4. That's the correct strategy. If something doesn't need scoring, put it in the `filter` clause of a boolean query. Or you can use the filter clause of a `constant_score` query for the same effect.

---

<div class="post-metadata">

**Author:** ![hym](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/hym/32/22399_2.png) [@hym](https://discuss.elastic.co/u/hym)\
**Post date:** [October 23, 2018, 7:27am UTC](https://discuss.elastic.co/t/how-to-stop-score-calculating/152398/3 "2018-10-23T07:27:21Z")

</div>

Thank you so much

---

<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:** [November 20, 2018, 7:27am UTC](https://discuss.elastic.co/t/how-to-stop-score-calculating/152398/4 "2018-11-20T07:27:23Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
