Skip to main content
Use SEARCH.COUNT to count documents matching a query without retrieving them. The filter is the same JSON object that SEARCH.QUERY takes, but only the number of matching documents is computed and returned, so nothing depends on the size of the result and no LIMIT gets in the way of the total. That makes it the right command for result counters, pagination totals, and cheap existence checks over a filter. See Counting for feature examples and common use cases.

Syntax

<json_filter> is an Upstash JSON filter. The command accepts an index name or alias.

Response

Returns the number of matching documents as an integer. Returns -1 if the index does not exist.

Examples