# Does \_count api of ES automatically skips boosting logic inside query field?

**URL:** <https://discuss.elastic.co/t/does--count-api-of-es-automatically-skips-boosting-logic-inside-query-field/100196>\
**Category:** Elasticsearch\
**Created:** [September 12, 2017, 10:34am UTC](https://discuss.elastic.co/t/does--count-api-of-es-automatically-skips-boosting-logic-inside-query-field/100196 "2017-09-12T10:34:16Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![amver](https://avatars.discourse-cdn.com/v4/letter/a/3da27b/32.png) [@amver](https://discuss.elastic.co/u/amver)\
**Post date:** [September 12, 2017, 10:34am UTC](https://discuss.elastic.co/t/does--count-api-of-es-automatically-skips-boosting-logic-inside-query-field/100196/1 "2017-09-12T10:34:17Z")

</div>

Hi,  
I want to get only the count of search hits from ElasticSearch.  
I currently have a structured query with highlighting, aggregation, sorting, post\_filters and all. Inside the query section, I also use the function score and boosting using '^'.  
Now in another application, all I want is the count of results, so I guess I need to use '\_count' api. I also want to reuse the current query generation logic.  
My question is does the \_count api automatically ignores the boosting logic inside the query portion?

Note: I want to it to skip the boosting logic and other parts as highlighting and aggregation to improve performance.  
If ES does not ignore the boosting logic automatically, is there a way we can do it manualy?

---

<div class="post-metadata">

**Author:** ![dakrone](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dakrone/32/23351_2.png) [@dakrone](https://discuss.elastic.co/u/dakrone)\
**Post date:** [September 15, 2017, 4:46pm UTC](https://discuss.elastic.co/t/does--count-api-of-es-automatically-skips-boosting-logic-inside-query-field/100196/2 "2017-09-15T16:46:00Z")

</div>

You should not have to worry about the cost of the boosting when performing a count, Lucene can skip the scoring phase when no documents are collected.

Additionally, you can simply set `"size": 0` in your query to do the same thing as the `/_count` API

---

<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:** [October 13, 2017, 4:46pm UTC](https://discuss.elastic.co/t/does--count-api-of-es-automatically-skips-boosting-logic-inside-query-field/100196/3 "2017-10-13T16:46:18Z")

</div>

Closed on October 13, 2017, 4:46pm UTC

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