cakephp / elastic-search

Elastic search datasource for CakePHP
Other
88 stars 53 forks source link

$query->count() doesn't return the correct count. #103

Closed burzum closed 6 years ago

burzum commented 8 years ago
        debug($countQuery->all()->getTotalHits());
        $profilesCount = ($countQuery->count());
        debug($profilesCount);

First debug will give you a different number than second. Except you have the same counts ;)

I expected $countQuery->count() to return the same number as getTotalHits().

While I'm OK with using getTotalHits() after I found the method I don't think the behavior of count() is correct.

markstory commented 8 years ago

The Query object doesn't implement count are you sure you're not calling count() on the resultset? The documentation for ResultSet::count() states:

Returns size of current set

Which means its not supposed to be the same as getTotalHits()