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: README.md
+46-6Lines changed: 46 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -31,12 +31,17 @@ The Python interface to the Redis key-value store.
31
31
32
32
## Installation
33
33
34
-
Start a redis via docker:
34
+
Start a redis via docker (for Redis versions >= 8.0):
35
35
36
36
```bash
37
-
docker run -p 6379:6379 -it redis/redis-stack:latest
37
+
docker run -p 6379:6379 -it redis:latest
38
38
```
39
39
40
+
Start a redis via docker (for Redis versions < 8.0):
41
+
42
+
```bash
43
+
docker run -p 6379:6379 -it redis/redis-stack:latest
44
+
40
45
To install redis-py, simply:
41
46
42
47
``` bash
@@ -54,15 +59,16 @@ Looking for a high-level library to handle object mapping? See [redis-om-python]
54
59
55
60
## Supported Redis Versions
56
61
57
-
The most recent version of this library supports redis version [5.0](https://github.com/redis/redis/blob/5.0/00-RELEASENOTES), [6.0](https://github.com/redis/redis/blob/6.0/00-RELEASENOTES), [6.2](https://github.com/redis/redis/blob/6.2/00-RELEASENOTES), [7.0](https://github.com/redis/redis/blob/7.0/00-RELEASENOTES), [7.2](https://github.com/redis/redis/blob/7.2/00-RELEASENOTES)and [7.4](https://github.com/redis/redis/blob/7.4/00-RELEASENOTES).
62
+
The most recent version of this library supports Redis version [7.2](https://github.com/redis/redis/blob/7.2/00-RELEASENOTES), [7.4](https://github.com/redis/redis/blob/7.4/00-RELEASENOTES)and [8.0](https://github.com/redis/redis/blob/8.0/00-RELEASENOTES).
58
63
59
64
The table below highlights version compatibility of the most-recent library versions and redis versions.
60
65
61
66
| Library version | Supported redis versions |
62
67
|-----------------|-------------------|
63
68
| 3.5.3 |<= 6.2 Family of releases |
64
69
|>= 4.5.0 | Version 5.0 to 7.0 |
65
-
| >= 5.0.0 | Version 5.0 to current |
70
+
|>= 5.0.0 | Version 5.0 to 7.4 |
71
+
|>= 6.0.0 | Version 7.2 to current |
66
72
67
73
68
74
## Usage
@@ -152,8 +158,42 @@ The following example shows how to utilize [Redis Pub/Sub](https://redis.io/docs
### Redis’ search and query capabilities default dialect
162
+
163
+
Release 6.0.0 introduces a client-side default dialect for Redis’ search and query capabilities.
164
+
By default, the client now overrides the server-side dialect with version 2, automatically appending *DIALECT 2* to commands like *FT.AGGREGATE* and *FT.SEARCH*.
155
165
156
-
--------------------------
166
+
**Important**: Be aware that the query dialect may impact the results returned. If needed, you can revert to a different dialect version by configuring the client accordingly.
167
+
168
+
``` python
169
+
>>> from redis.commands.search.field import TextField
170
+
>>> from redis.commands.search.query import Query
171
+
>>> from redis.commands.search.index_definition import IndexDefinition
172
+
>>> import redis
173
+
174
+
>>> r = redis.Redis(host='localhost', port=6379, db=0)
175
+
>>> r.ft().create_index(
176
+
>>> (TextField("name"), TextField("lastname")),
177
+
>>> definition=IndexDefinition(prefix=["test:"]),
178
+
>>> )
179
+
180
+
>>> r.hset("test:1", "name", "James")
181
+
>>> r.hset("test:1", "lastname", "Brown")
182
+
183
+
>>> # Query with default DIALECT 2
184
+
>>> query = "@name: James Brown"
185
+
>>> q = Query(query)
186
+
>>> res = r.ft().search(q)
187
+
188
+
>>> # Query with explicit DIALECT 1
189
+
>>> query = "@name: James Brown"
190
+
>>> q = Query(query).dialect(1)
191
+
>>> res = r.ft().search(q)
192
+
```
193
+
194
+
You can find further details in the [query dialect documentation](https://redis.io/docs/latest/develop/interact/search-and-query/advanced-concepts/dialects/).
0 commit comments