{
  "schema_version": 2,
  "id": "commands/topk.query",
  "title": "TOPK.QUERY",
  "url": "https://redis.io/docs/latest/commands/topk.query/",
  "summary": "Checks whether one or more items are in a sketch",
  "since": "2.0.0",
  "tags": [
    "docs",
    "develop",
    "stack",
    "oss",
    "rs",
    "rc",
    "oss",
    "kubernetes",
    "clients"
  ],
  "last_updated": "2026-09-18T09:48:54+01:00",
  "page_type": "content",
  "content_hash": "a9026d375d0d74e6df2957aa72797b38e769dcbd6cceb613d1e1d36f40bcd633",
  "sections": [
    {
      "id": "overview",
      "title": "Overview",
      "role": "overview",
      "text": "Checks whether one or more items are one of the Top-K items."
    },
    {
      "id": "required-arguments",
      "title": "Required arguments",
      "role": "content",
      "text": "<details open><summary><code>key</code></summary>\n\nthe name of the sketch.\n\n</details>\n\n<details open><summary><code>item [item ...]</code></summary>\n\nthe items to be queried.\n\n</details>"
    },
    {
      "id": "examples",
      "title": "Examples",
      "role": "example",
      "text": "[code example]"
    },
    {
      "id": "redis-software-and-redis-cloud-compatibility",
      "title": "Redis Software and Redis Cloud compatibility",
      "role": "content",
      "text": "| Redis<br />Software | Redis<br />Cloud | <span style=\"min-width: 9em; display: table-cell\">Notes</span> |\n|:----------------------|:-----------------|:------|\n| <span title=\"Supported\">&#x2705; Supported</span><br /> | <span title=\"Supported\">&#x2705; Flexible & Annual</span><br /><span title=\"Supported\">&#x2705; Free & Fixed</nobr></span> |  |"
    },
    {
      "id": "return-information",
      "title": "Return information",
      "role": "returns",
      "text": "**RESP2:**\n\nOne of the following:\n\n* [Array](https://redis.io/docs/latest/develop/reference/protocol-spec#arrays) of [integer replies](https://redis.io/docs/latest/develop/reference/protocol-spec#integers): `1` if an item is in the Top-K or `0` otherwise.\n* [Simple error reply](https://redis.io/docs/latest/develop/reference/protocol-spec#simple-errors) in these cases: non-existant key or key of the incorrect type.\n\n**RESP3:**\n\n* [Array](https://redis.io/docs/latest/develop/reference/protocol-spec#arrays) of [boolean replies](https://redis.io/docs/latest/develop/reference/protocol-spec#booleans): `true` if an item is in the Top-K or `false` otherwise.\n* [Simple error reply](https://redis.io/docs/latest/develop/reference/protocol-spec#simple-errors) in these cases: non-existant key or key of the incorrect type."
    }
  ],
  "examples": [
    {
      "id": "examples-ex0",
      "language": "plaintext",
      "code": "redis> TOPK.QUERY topk 42 nonexist\n1) (integer) 1\n2) (integer) 0",
      "section_id": "examples"
    }
  ]
}
