Back to Redis

TOPK.QUERY

content/commands/topk.query.md

latest1.5 KB
Original Source

Checks whether one or more items are one of the Top-K items.

Parameters

  • key: the name of the sketch.
  • item: the items to be queried.

Example

redis> TOPK.QUERY topk 42 nonexist
1) (integer) 1
2) (integer) 0

Redis Software and Redis Cloud compatibility

| Redis Software | Redis Cloud | <span style="min-width: 9em; display: table-cell">Notes</span> | |:----------------------|:-----------------|:------| | <span title="Supported">✅ Supported</span> | <span title="Supported">✅ Flexible & Annual</span> <span title="Supported">✅ Free & Fixed</nobr></span> | |

Return information

{{< multitabs id="topk-query-return-info" tab1="RESP2" tab2="RESP3" >}}

One of the following:

  • [Array]({{< relref "/develop/reference/protocol-spec#arrays" >}}) of [integer replies]({{< relref "/develop/reference/protocol-spec#integers" >}}): 1 if an item is in the Top-K or 0 otherwise.
  • [Simple error reply]({{< relref "/develop/reference/protocol-spec#simple-errors" >}}) in these cases: non-existant key or key of the incorrect type.

-tab-sep-

  • [Array]({{< relref "/develop/reference/protocol-spec#arrays" >}}) of [boolean replies]({{< relref "/develop/reference/protocol-spec#booleans" >}}): true if an item is in the Top-K or false otherwise.
  • [Simple error reply]({{< relref "/develop/reference/protocol-spec#simple-errors" >}}) in these cases: non-existant key or key of the incorrect type.

{{< /multitabs >}}