{
  "id": "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",
  "tags": [
    "docs",
    "develop",
    "stack",
    "oss",
    "rs",
    "rc",
    "oss",
    "kubernetes",
    "clients"
  ],
  "last_updated": "2026-04-09T10:29:34-04:00",
  "page_type": "content",
  "content_hash": "9f3b8fd18b4b7b7bd3132ad7cdce70def445aeda00175a2e2c21664401bba37b",
  "sections": [
    {
      "id": "overview",
      "title": "Overview",
      "role": "overview",
      "text": "Checks whether one or more items are one of the Top-K items."
    },
    {
      "id": "parameters",
      "title": "Parameters",
      "role": "parameters",
      "text": "* **key**: the name of the sketch.\n* **item**: the items to be queried."
    },
    {
      "id": "example",
      "title": "Example",
      "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]() of [integer replies](): `1` if an item is in the Top-K or `0` otherwise.\n* [Simple error reply]() in these cases: non-existant key or key of the incorrect type.\n\n**RESP3:**\n\n* [Array]() of [boolean replies](): `true` if an item is in the Top-K or `false` otherwise.\n* [Simple error reply]() in these cases: non-existant key or key of the incorrect type."
    }
  ],
  "examples": [
    {
      "id": "example-ex0",
      "language": "plaintext",
      "code": "redis> TOPK.QUERY topk 42 nonexist\n1) (integer) 1\n2) (integer) 0",
      "section_id": "example"
    }
  ]
}
