content/commands/ts.queryindex.md
{{< note >}} This command's behavior varies in clustered Redis environments. See the [multi-key operations]({{< relref "/develop/using-commands/multi-key-operations" >}}) page for more information. {{< /note >}}
Get all time series keys matching a filter list. Note: all matching keys will be listed, whether or not the user has read access.
filters time series based on their labels and label values. Each filter expression has one of the following syntaxes:
label!= - the time series has a label named labellabel=value - the time series has a label named label with a value equal to valuelabel=(value1,value2,...) - the time series has a label named label with a value equal to one of the values in the listlabel= - the time series does not have a label named labellabel!=value - the time series does not have a label named label with a value equal to valuelabel!=(value1,value2,...) - the time series does not have a label named label with a value equal to any of the values in the list<note><b>Notes:</b>
label=value or label=(value1,value2,...) is required.type=temperature room=study means that a time series is a temperature time series of a study room.x="y y" or x='(y y,z z)'.
</note>
<note><b>Note:</b> The QUERYINDEX command cannot be part of a transaction when running on a Redis cluster.</note>
Create a set of sensors to measure temperature and humidity in your study and kitchen.
{{< highlight bash >}} 127.0.0.1:6379> TS.CREATE telemetry:study:temperature LABELS room study type temperature OK 127.0.0.1:6379> TS.CREATE telemetry:study:humidity LABELS room study type humidity OK 127.0.0.1:6379> TS.CREATE telemetry:kitchen:temperature LABELS room kitchen type temperature OK 127.0.0.1:6379> TS.CREATE telemetry:kitchen:humidity LABELS room kitchen type humidity OK {{< / highlight >}}
Retrieve keys of all time series representing sensors located in the kitchen.
{{< highlight bash >}} 127.0.0.1:6379> TS.QUERYINDEX room=kitchen
To retrieve the keys of all time series representing sensors that measure temperature, use this query:
{{< highlight bash >}} 127.0.0.1:6379> TS.QUERYINDEX type=temperature
| 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> | |
{{< multitabs id="ts-queryindex-return-info" tab1="RESP2" tab2="RESP3" >}}
One of the following:
-tab-sep-
One of the following:
{{< /multitabs >}}
[TS.CREATE]({{< relref "commands/ts.create/" >}}) | [TS.MRANGE]({{< relref "commands/ts.mrange/" >}}) | [TS.MREVRANGE]({{< relref "commands/ts.mrevrange/" >}}) | [TS.MGET]({{< relref "commands/ts.mget/" >}})
[RedisTimeSeries]({{< relref "/develop/data-types/timeseries/" >}})