{
  "schema_version": 2,
  "id": "commands/ts.queryindex",
  "title": "TS.QUERYINDEX",
  "url": "https://redis.io/docs/latest/commands/ts.queryindex/",
  "summary": "Get all time series keys matching a filter list",
  "since": "1.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": "0d59692813338fe4bd9814773b4c6a9eab0e6ca58be50cb4fb275c29b8cf66de",
  "sections": [
    {
      "id": "overview",
      "title": "Overview",
      "role": "overview",
      "text": "> [!NOTE]\n> This command's behavior varies in clustered Redis environments. See the [multi-key operations](https://redis.io/docs/latest/develop/using-commands/multi-key-operations) page for more information.\n\n\n\nGet all time series keys matching a filter list. Note: all matching keys will be listed, whether or not the user has read access.\n\n[Examples](#examples)"
    },
    {
      "id": "required-arguments",
      "title": "Required arguments",
      "role": "content",
      "text": "<details open>\n<summary><code>filterExpr...</code></summary>\n\nfilters time series based on their labels and label values.\n\nEach filter expression has one of the following syntaxes:\n\n  - `label!=` - the time series has a label named `label`\n  - `label=value` - the time series has a label named `label` with a value equal to `value`\n  - `label=(value1,value2,...)` - the time series has a label named `label` with a value equal to one of the values in the list\n  - `label=` - the time series does not have a label named `label`\n  - `label!=value` - the time series does not have a label named `label` with a value equal to `value`\n  - `label!=(value1,value2,...)` - the time series does not have a label named `label` with a value equal to any of the values in the list\n\n  <note><b>Notes:</b>\n   - At least one filter expression with a syntax `label=value` or `label=(value1,value2,...)` is required.\n   - Filter expressions are conjunctive. For example, the filter `type=temperature room=study` means that `type=temperature` AND `room=study`.\n   - Whitespace is not allowed in a filter expression except between quotes or double quotes in values - for example, `x=\"y y\"` or `x='(y y,z z)'`.\n   </note>\n\n</details>\n\n<note><b>Note:</b> The `QUERYINDEX` command cannot be part of a transaction when running on a Redis cluster.</note>"
    },
    {
      "id": "examples",
      "title": "Examples",
      "role": "example",
      "text": "<details open>\n<summary><b>Find keys by location and sensor type</b></summary>\n\nCreate a set of sensors to measure temperature and humidity in your study and kitchen.\n\n\nredis> TS.CREATE telemetry:study:temperature LABELS room study type temperature\nOK\nredis> TS.CREATE telemetry:study:humidity LABELS room study type humidity\nOK\nredis> TS.CREATE telemetry:kitchen:temperature LABELS room kitchen type temperature\nOK\nredis> TS.CREATE telemetry:kitchen:humidity LABELS room kitchen type humidity\nOK\n\n\nRetrieve keys of all time series representing sensors located in the kitchen. \n\n\nredis> TS.QUERYINDEX room=kitchen\n1) \"telemetry:kitchen:humidity\"\n2) \"telemetry:kitchen:temperature\"\n\n\nTo retrieve the keys of all time series representing sensors that measure temperature, use this query:\n\n\nredis> TS.QUERYINDEX type=temperature\n1) \"telemetry:kitchen:temperature\"\n2) \"telemetry:study:temperature\"\n\n</details>"
    },
    {
      "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* [Array reply](https://redis.io/docs/latest/develop/reference/protocol-spec#arrays) where each element is a [Bulk string reply](https://redis.io/docs/latest/develop/reference/protocol-spec#bulk-strings): a time series key. The array is empty if no time series matches the filter.\n* [Simple error reply](https://redis.io/docs/latest/develop/reference/protocol-spec#simple-errors) in these cases: invalid filter expression.\n\n**RESP3:**\n\nOne of the following:\n* [Set reply](https://redis.io/docs/latest/develop/reference/protocol-spec#sets) where each element is a [Bulk string reply](https://redis.io/docs/latest/develop/reference/protocol-spec#bulk-strings): a time series key. The set is empty if no time series matches the filter.\n* [Simple error reply](https://redis.io/docs/latest/develop/reference/protocol-spec#simple-errors) in these cases: invalid filter expression."
    },
    {
      "id": "see-also",
      "title": "See also",
      "role": "related",
      "text": "[`TS.CREATE`](https://redis.io/docs/latest/commands/ts.create) | [`TS.MRANGE`](https://redis.io/docs/latest/commands/ts.mrange) | [`TS.MREVRANGE`](https://redis.io/docs/latest/commands/ts.mrevrange) | [`TS.MGET`](https://redis.io/docs/latest/commands/ts.mget)"
    },
    {
      "id": "related-topics",
      "title": "Related topics",
      "role": "related",
      "text": "[RedisTimeSeries](https://redis.io/docs/latest/develop/data-types/timeseries)"
    }
  ],
  "examples": []
}
