You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/develop/use/patterns/indexes/index.md
+28Lines changed: 28 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -19,16 +19,36 @@ Redis is not exactly a key-value store, since values can be complex data structu
19
19
20
20
This document explains how it is possible to create indexes in Redis using the following data structures:
21
21
22
+
* Hashes and JSON documents, using a variety of field types; used in conjunction with the Redis query engine.
22
23
* Sorted sets to create secondary indexes by ID or other numerical fields.
23
24
* Sorted sets with lexicographical ranges for creating more advanced secondary indexes, composite indexes and graph traversal indexes.
24
25
* Sets for creating random indexes.
25
26
* Lists for creating simple iterable indexes and last N items indexes.
27
+
* Time series with labels.
26
28
27
29
Implementing and maintaining indexes with Redis is an advanced topic, so most
28
30
users that need to perform complex queries on data should understand if they
29
31
are better served by a relational store. However often, especially in caching
30
32
scenarios, there is the explicit need to store indexed data into Redis in order to speedup common queries which require some form of indexing in order to be executed.
31
33
34
+
## Hashes and JSON indexes
35
+
36
+
The Redis query engine provides capabilities to index and query both hash and JSON keys using a variety of field types:
37
+
38
+
*`TEXT`
39
+
*`TAG`
40
+
*`NUMERIC`
41
+
*`GEO`
42
+
*`VECTOR`
43
+
*`GEOSHAPE`
44
+
45
+
Once hash or JSON keys have been indexed using the [`FT.CREATE`]({{< baseurl >}}/commands/ft.create) command, all keys that use the prefix defined in the index can be queried using the [`FT.SEARCH`]({{< baseurl >}}/commands/ft.search) and [`FT.AGGREGATE`]({{< baseurl >}}/commands/ft.aggregate) commands.
46
+
47
+
For more information on creating hash and JSON indexes, see the following pages.
The simplest secondary index you can create with Redis is by using the
@@ -158,6 +178,14 @@ When representing much larger numbers, you need a different form of indexing
158
178
that is able to index numbers at any precision, called a lexicographical
159
179
index.
160
180
181
+
## Time series indexes
182
+
183
+
When you create a new time series using the [`TS.CREATE`]({{< baseurl >}}/commands/ts.create) command, you can associate one or more `LABELS` with it. Each label is a name-value pair, where the both name and value are text. Labels serve as a secondary index that allows you to execute queries on groups of time series keys using various time series commands.
184
+
185
+
See the [time series quickstart guide]({{< relref "/develop/data-types/timeseries/quickstart#labels" >}}) for an example of creating a time series with a label.
186
+
187
+
The [`TS.MGET`]({{< baseurl >}}/commands/ts.mget), [`TS.MRANGE`]({{< baseurl >}}/commands/ts.mrange), and [`TS.MREVRANGE`]({{< baseurl >}}/commands/ts.mrevrange) commands operate on multiple time series based on specified labels or using a label-related filter expression. The [`TS.QUERYINDEX`]({{< baseurl >}}/commands/ts.queryindex) command returns all time series keys matching a given label-related filter expression.
188
+
161
189
## Lexicographical indexes
162
190
163
191
Redis sorted sets have an interesting property. When elements are added
0 commit comments