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


(Aman Verma) #1

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?


(Lee Hinman) #2

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


(system) #3

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