Querying without providing a list of facets the hit count appears to be too high

Is this a bug?

Calling this endpoint
xxxx-dsn.algolia.net/1/indexes/index_name/query

with POST -> {“params”:“query=Dance&hitsPerPage=25&maxValuesPerFacet=10000&page=0&facets=[*]”}

returns the correct amount of results

where as
POST -> {“params”:“query=Dance&hitsPerPage=25&maxValuesPerFacet=10000&page=0&facets=[]”}

POST -> {“params”:“query=Dance&hitsPerPage=25&maxValuesPerFacet=10000&page=0&facets=[“FacetThatExists”]”}

POST -> {“params”:“query=Dance&hitsPerPage=25&maxValuesPerFacet=10000&page=0&facets=[“FacetThatDoesntExists”]”}

All have a much higher nbHit count?

1 Like

Hi @s.pallesclark,

This is an interesting one. :slight_smile:

By default, the engine will stop scanning results after a few thousand hits to ensure better performance at the expense of exhaustivity of facet / nbHits counts. However, when the “facets: ” parameter is specified, the engine will spend more time scanning to gather more exhaustive facet / nbHits information.

This is why you’re seeing the correct count for your initial query, but estimated counts for the other queries.

2 Likes