Search API vs Count API performance?

Recently we made changes to our code, where we replaced a search request (with aggs, score functions, etc.) with a count request. The problem is that we can't monitor count requests with a stats group.

Someone claimed that count API internally runs a trimmed down search request and if we sent an equivalent "trimmed down search request" (no aggs, no score functions, size:0, filter context) the performance would be almost the same + we could monitor it with stats group.

  • Is there a way besides raw HTTP time to compare the two?
  • Is count API more optimized for this?

Hi @gskema,

the count API issues a search request under the hood indeed. You can have a look at the source code of RestCountAction to see how it uses the search API.

To your questions:

Is there a way besides raw HTTP time to compare the two?

Unfortunately, I don't quite understand what you are after here.

Is count API more optimized for this?

As you can see in the source code, it is really just issues a search request under the hood, so: no.

Daniel

Thanks for answering @danielmitterdorfer

By asking

Is there a way besides raw HTTP time to compare the two?

I wanted to know if _count API supports something like stat groups or has response.took so we can measure the load on our servers. We already switched to plain search request so we could track the load with a stat group, which was unavailable for _count request

Ah, I see. No, it is not possible to use stats groups or get took in the response.

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