Skip to content

Ask the HotKV docs

Answers come only from these docs and can be wrong; check the linked pages before you rely on them.

TOPK.LIST

Last updated
TOPK.LIST key [WITHCOUNT]
Group
Top-K
Complexity
O(k log k), k being the list size
Arity
-1 (at least 1 words, counting the command name)
Flags
none
Keys
first 1, last 1, step 1
HotKV Cloud
All plans
On-Premise
no license needed

TOPK.LIST returns the items currently kept by the Top-K at key, ordered by estimated count, highest first.

Option Effect
WITHCOUNT Follow each item with its estimated count.
Case RESP2 RESP3
Default Array of items (bulk strings) Same
WITHCOUNT Flat array: item, count, item, count, … Same

The list holds fewer than topk items until enough distinct items were seen.

Error replies: TopK: key does not exist, WITHCOUNT keyword expected for any other option, and WRONGTYPE.

127.0.0.1:6379> TOPK.RESERVE trending 3 50 4 0.9
OK
127.0.0.1:6379> TOPK.INCRBY trending hotkv 10 redis 4
1) (nil)
2) (nil)
127.0.0.1:6379> TOPK.LIST trending
1) "hotkv"
2) "redis"
127.0.0.1:6379> TOPK.LIST trending WITHCOUNT
1) "hotkv"
2) (integer) 10
3) "redis"
4) (integer) 4

Same as TOPK.LIST in RedisBloom.

TOPK.QUERY, TOPK.COUNT, TOPK.ADD