TS.QUERYINDEX
- Available in:
- Redis Stack / Time series 1.0.0
- Time complexity:
- O(n) where n is the number of time-series that match the filters
Get all time series keys matching a filter list
Syntax
TS.QUERYINDEX filter...Required arguments
FILTER filter..
filters time series based on their labels and label values, with these options:
label=value, wherelabelequalsvaluelabel!=value, wherelabeldoes not equalvaluelabel=, wherekeydoes not have labellabellabel!=, wherekeyhas labellabellabel=(_value1_,_value2_,...), wherekeywith labellabelequals one of the values in the listlabel!=(value1,value2,...), where key with labellabeldoes not equal any of the values in the list
- When using filters, apply a minimum of one
label=valuefilter. QUERYINDEXcannot be part of a transaction that runs on a Redis cluster.- Filters are conjunctive. For example, the FILTER
type=temperature room=studymeans the a time series is a temperature time series of a study room.
Examples
Find keys by location and sensor type
Create a set of sensors to measure temperature and humidity in your study and kitchen.
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
OKRetrieve keys of all time series representing sensors located in the kitchen.
127.0.0.1:6379> TS.QUERYINDEX room=kitchen
1) "telemetry:kitchen:humidity"
2) "telemetry:kitchen:temperature"To retrieve the keys of all time series representing sensors that measure temperature, use this query:
127.0.0.1:6379> TS.QUERYINDEX type=temperature
1) "telemetry:kitchen:temperature"
2) "telemetry:study:temperature"See also
TS.CREATE | TS.MRANGE | TS.MREVRANGE | MGET
Related topics
Feedback
If you've found issues on this page, or have suggestions for improvement, please submit a request to merge or open an issue in the repository.