2

I am with an Azure Search with around 615k docs. I am getting different counts when using $count when comparing with the previous search based on sql server. O the official doc I could not find any information about it, but here on StackOverflow I’ve found the following:

https://stackoverflow.com/a/47089349

So is the $count approximate or real? Is there any information in the official doc about it that I’ve missed?

Thiago Custodio
  • 17,332
  • 6
  • 45
  • 90

2 Answers2

3

The count is approximate. From the REST API documentation page:

$count=true | false

Optional, defaults to false. When calling via POST, this parameter is named count instead of $count. Specifies whether to fetch the total count of results. This is the count of all documents that match the search and $filter parameters, ignoring $top and $skip. Setting this value to true may have a performance impact. Note that the count returned is an approximation. If you’d like to get only the count without any documents, you can use $top=0

Gaurav Mantri
  • 128,066
  • 12
  • 206
  • 241
  • It seems that microsoft has adjusted the relevant sentence in the REST API documentation to: **Count is accurate if the index is stable, but will under or over-report any documents that are actively added, updated, or deleted.** – lgraf Aug 22 '22 at 07:11
0

The returned count is an approximation. Besides "REST API document", it's documented in ".NET API document" too.

rudin
  • 151
  • 3