Skip to content

Commit 2859c84

Browse files
authored
Merge branch 'master' into ps_flaky_tests_fixes_round_2
2 parents 3416fd7 + 77e8db2 commit 2859c84

13 files changed

+65
-33
lines changed

docs/advanced_features.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -384,13 +384,13 @@ run_in_thread.
384384
385385
A PubSub object adheres to the same encoding semantics as the client
386386
instance it was created from. Any channel or pattern that's unicode will
387-
be encoded using the charset specified on the client before being sent
387+
be encoded using the encoding specified on the client before being sent
388388
to Redis. If the client's decode_responses flag is set the False (the
389389
default), the 'channel', 'pattern' and 'data' values in message
390390
dictionaries will be byte strings (str on Python 2, bytes on Python 3).
391391
If the client's decode_responses is True, then the 'channel', 'pattern'
392392
and 'data' values will be automatically decoded to unicode strings using
393-
the client's charset.
393+
the client's encoding.
394394

395395
PubSub objects remember what channels and patterns they are subscribed
396396
to. In the event of a disconnection such as a network error or timeout,

doctests/home_json.py

Lines changed: 53 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import redis.commands.search.aggregation as aggregations
1111
import redis.commands.search.reducers as reducers
1212
from redis.commands.search.field import TextField, NumericField, TagField
13-
from redis.commands.search.indexDefinition import IndexDefinition, IndexType
13+
from redis.commands.search.index_definition import IndexDefinition, IndexType
1414
from redis.commands.search.query import Query
1515
import redis.exceptions
1616
# STEP_END
@@ -25,7 +25,12 @@
2525
except redis.exceptions.ResponseError:
2626
pass
2727

28-
r.delete("user:1", "user:2", "user:3")
28+
try:
29+
r.ft("hash-idx:users").dropindex(True)
30+
except redis.exceptions.ResponseError:
31+
pass
32+
33+
r.delete("user:1", "user:2", "user:3", "huser:1", "huser:2", "huser:3")
2934
# REMOVE_END
3035
# STEP_START create_data
3136
user1 = {
@@ -134,4 +139,50 @@
134139
)
135140
# REMOVE_END
136141

142+
# STEP_START make_hash_index
143+
hashSchema = (
144+
TextField("name"),
145+
TagField("city"),
146+
NumericField("age")
147+
)
148+
149+
hashIndexCreated = r.ft("hash-idx:users").create_index(
150+
hashSchema,
151+
definition=IndexDefinition(
152+
prefix=["huser:"], index_type=IndexType.HASH
153+
)
154+
)
155+
# STEP_END
156+
# REMOVE_START
157+
assert hashIndexCreated
158+
# REMOVE_END
159+
160+
# STEP_START add_hash_data
161+
huser1Set = r.hset("huser:1", mapping=user1)
162+
huser2Set = r.hset("huser:2", mapping=user2)
163+
huser3Set = r.hset("huser:3", mapping=user3)
164+
# STEP_END
165+
# REMOVE_START
166+
assert huser1Set
167+
assert huser2Set
168+
assert huser3Set
169+
# REMOVE_END
170+
171+
# STEP_START query1_hash
172+
findPaulHashResult = r.ft("hash-idx:users").search(
173+
Query("Paul @age:[30 40]")
174+
)
175+
176+
print(findPaulHashResult)
177+
# >>> Result{1 total, docs: [Document {'id': 'huser:3',
178+
# >>> 'payload': None, 'name': 'Paul Zamir', ...
179+
# STEP_END
180+
# REMOVE_START
181+
assert str(findPaulHashResult) == (
182+
"Result{1 total, docs: [Document " +
183+
"{'id': 'huser:3', 'payload': None, 'name': 'Paul Zamir', " +
184+
"'email': '[email protected]', 'age': '35', 'city': 'Tel Aviv'}]}"
185+
)
186+
# REMOVE_END
187+
137188
r.close()

doctests/query_agg.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from redis.commands.search import Search
77
from redis.commands.search.aggregation import AggregateRequest
88
from redis.commands.search.field import NumericField, TagField
9-
from redis.commands.search.indexDefinition import IndexDefinition, IndexType
9+
from redis.commands.search.index_definition import IndexDefinition, IndexType
1010
import redis.commands.search.reducers as reducers
1111

1212
r = redis.Redis(decode_responses=True)

doctests/query_combined.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import warnings
77
from redis.commands.json.path import Path
88
from redis.commands.search.field import NumericField, TagField, TextField, VectorField
9-
from redis.commands.search.indexDefinition import IndexDefinition, IndexType
9+
from redis.commands.search.index_definition import IndexDefinition, IndexType
1010
from redis.commands.search.query import Query
1111
from sentence_transformers import SentenceTransformer
1212

doctests/query_em.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import redis
55
from redis.commands.json.path import Path
66
from redis.commands.search.field import TextField, NumericField, TagField
7-
from redis.commands.search.indexDefinition import IndexDefinition, IndexType
7+
from redis.commands.search.index_definition import IndexDefinition, IndexType
88
from redis.commands.search.query import NumericFilter, Query
99

1010
r = redis.Redis(decode_responses=True)

doctests/query_ft.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import redis
66
from redis.commands.json.path import Path
77
from redis.commands.search.field import TextField, NumericField, TagField
8-
from redis.commands.search.indexDefinition import IndexDefinition, IndexType
8+
from redis.commands.search.index_definition import IndexDefinition, IndexType
99
from redis.commands.search.query import NumericFilter, Query
1010

1111
r = redis.Redis(decode_responses=True)

doctests/query_geo.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import redis
66
from redis.commands.json.path import Path
77
from redis.commands.search.field import GeoField, GeoShapeField
8-
from redis.commands.search.indexDefinition import IndexDefinition, IndexType
8+
from redis.commands.search.index_definition import IndexDefinition, IndexType
99
from redis.commands.search.query import Query
1010

1111
r = redis.Redis(decode_responses=True)

doctests/query_range.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import redis
66
from redis.commands.json.path import Path
77
from redis.commands.search.field import TextField, NumericField, TagField
8-
from redis.commands.search.indexDefinition import IndexDefinition, IndexType
8+
from redis.commands.search.index_definition import IndexDefinition, IndexType
99
from redis.commands.search.query import NumericFilter, Query
1010

1111
r = redis.Redis(decode_responses=True)

doctests/search_quickstart.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import redis.commands.search.reducers as reducers
1111
from redis.commands.json.path import Path
1212
from redis.commands.search.field import NumericField, TagField, TextField
13-
from redis.commands.search.indexDefinition import IndexDefinition, IndexType
13+
from redis.commands.search.index_definition import IndexDefinition, IndexType
1414
from redis.commands.search.query import Query
1515

1616
# HIDE_END

doctests/search_vss.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
TextField,
2121
VectorField,
2222
)
23-
from redis.commands.search.indexDefinition import IndexDefinition, IndexType
23+
from redis.commands.search.index_definition import IndexDefinition, IndexType
2424
from redis.commands.search.query import Query
2525
from sentence_transformers import SentenceTransformer
2626

redis/client.py

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
import re
33
import threading
44
import time
5-
import warnings
65
from itertools import chain
76
from typing import (
87
TYPE_CHECKING,
@@ -203,8 +202,6 @@ def __init__(
203202
unix_socket_path: Optional[str] = None,
204203
encoding: str = "utf-8",
205204
encoding_errors: str = "strict",
206-
charset: Optional[str] = None,
207-
errors: Optional[str] = None,
208205
decode_responses: bool = False,
209206
retry_on_timeout: bool = False,
210207
retry_on_error: Optional[List[Type[Exception]]] = None,
@@ -256,20 +253,6 @@ def __init__(
256253
else:
257254
self._event_dispatcher = event_dispatcher
258255
if not connection_pool:
259-
if charset is not None:
260-
warnings.warn(
261-
DeprecationWarning(
262-
'"charset" is deprecated. Use "encoding" instead'
263-
)
264-
)
265-
encoding = charset
266-
if errors is not None:
267-
warnings.warn(
268-
DeprecationWarning(
269-
'"errors" is deprecated. Use "encoding_errors" instead'
270-
)
271-
)
272-
encoding_errors = errors
273256
if not retry_on_error:
274257
retry_on_error = []
275258
if retry_on_timeout is True:

redis/cluster.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,6 @@ def parse_cluster_myshardid(resp, **options):
142142
SLOT_ID = "slot-id"
143143

144144
REDIS_ALLOWED_KEYS = (
145-
"charset",
146145
"connection_class",
147146
"connection_pool",
148147
"connection_pool_class",
@@ -152,7 +151,6 @@ def parse_cluster_myshardid(resp, **options):
152151
"decode_responses",
153152
"encoding",
154153
"encoding_errors",
155-
"errors",
156154
"host",
157155
"lib_name",
158156
"lib_version",

redis/commands/search/commands.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
SEARCH_CMD = "FT.SEARCH"
2424
ADD_CMD = "FT.ADD"
2525
ADDHASH_CMD = "FT.ADDHASH"
26-
DROP_CMD = "FT.DROP"
2726
DROPINDEX_CMD = "FT.DROPINDEX"
2827
EXPLAIN_CMD = "FT.EXPLAIN"
2928
EXPLAINCLI_CMD = "FT.EXPLAINCLI"
@@ -35,7 +34,6 @@
3534
DICT_ADD_CMD = "FT.DICTADD"
3635
DICT_DEL_CMD = "FT.DICTDEL"
3736
DICT_DUMP_CMD = "FT.DICTDUMP"
38-
GET_CMD = "FT.GET"
3937
MGET_CMD = "FT.MGET"
4038
CONFIG_CMD = "FT.CONFIG"
4139
TAGVALS_CMD = "FT.TAGVALS"
@@ -406,6 +404,7 @@ def add_document_hash(self, doc_id, score=1.0, language=None, replace=False):
406404
doc_id, conn=None, score=score, language=language, replace=replace
407405
)
408406

407+
@deprecated_function(version="2.0.0", reason="deprecated since redisearch 2.0")
409408
def delete_document(self, doc_id, conn=None, delete_actual_document=False):
410409
"""
411410
Delete a document from index
@@ -440,6 +439,7 @@ def load_document(self, id):
440439

441440
return Document(id=id, **fields)
442441

442+
@deprecated_function(version="2.0.0", reason="deprecated since redisearch 2.0")
443443
def get(self, *ids):
444444
"""
445445
Returns the full contents of multiple documents.

0 commit comments

Comments
 (0)