{
  "id": "topk.count",
  "title": "TOPK.COUNT",
  "url": "https://redis.io/docs/latest/commands/topk.count/",
  "summary": "Return the count for one or more items 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": "0b586b672cc55f41850428aab041be8e0ef47c96b4e8f4492a3a654ed4455b1d",
  "sections": [
    {
      "id": "overview",
      "title": "Overview",
      "role": "overview",
      "text": "Returns counts for each item present in the sketch. \nMultiple items can be requested at once.\nPlease note this number will never be higher than the real count and will likely be lower.\n\nThis command has been deprecated. The count value is not a representative of\nthe number of appearances of an item."
    },
    {
      "id": "parameters",
      "title": "Parameters",
      "role": "parameters",
      "text": "* **key**: the name of the sketch where items are to be counted.\n* **item**: the items to be counted."
    },
    {
      "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]() of [integer replies]() representing the count of each specified item. For non-existant items, `0` is returned.\n* [Simple error reply]() in these cases: incorrect number of arguments, non-existant key, or key of the incorrect type.\n\n**RESP3:**\n\nOne of the following:\n\n* [Array]() of [integer replies]() representing the count of each specified item. For non-existant items, `0` is returned.\n* [Simple error reply]() in these cases: incorrect number of arguments, non-existant key, or key of the incorrect type."
    }
  ],
  "examples": [
    {
      "id": "examples-ex0",
      "language": "plaintext",
      "code": "redis> TOPK.COUNT topk foo 42 nonexist\n1) (integer) 3\n2) (integer) 1\n3) (integer) 0",
      "section_id": "examples"
    }
  ]
}
