Skip to content

Commit 8bfd492

Browse files
aksinha334davemcpheechayimbarshauldvora-h
authored
Making search document subscriptable (#2615)
* Fixed issue #2598 - make Document class subscriptable * Last time added older file, fixed it * retrigger checks * update json().arrindex() default values (#2611) * update json().arrindex() default values * add unit test * fix falsy checks * more unit tests * add asyncio tests * fix lint line length --------- Co-authored-by: Alex Schmitz <aschmitz@box.com> * Speeding up the protocol parsing (#2596) * speeding up the protocol parser * linting * changes to ease * Fixed CredentialsProvider examples (#2587) Co-authored-by: dvora-h <67596500+dvora-h@users.noreply.github.com> * ConnectionPool SSL example (#2605) * [types] update return type of smismember to list[int] (#2617) * update return type of smismember * use Literal instead of int * retrigger checks * Added test for document subscriptable in tests/test_search.py * Fixed linter issue * retrigger checks --------- Co-authored-by: Alex Schmitz <alex.schmitz@gmail.com> Co-authored-by: Alex Schmitz <aschmitz@box.com> Co-authored-by: Chayim <chayim@users.noreply.github.com> Co-authored-by: Bar Shaul <88437685+barshaul@users.noreply.github.com> Co-authored-by: dvora-h <67596500+dvora-h@users.noreply.github.com> Co-authored-by: CrimsonGlory <CrimsonGlory@users.noreply.github.com> Co-authored-by: Raymond Yin <raymond@tryevergreen.com>
1 parent a372ba4 commit 8bfd492

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

redis/commands/search/document.py

+4
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,7 @@ def __init__(self, id, payload=None, **fields):
1111

1212
def __repr__(self):
1313
return f"Document {self.__dict__}"
14+
15+
def __getitem__(self, item):
16+
value = getattr(self, item)
17+
return value

tests/test_search.py

+2
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,9 @@ def test_client(client):
140140

141141
for doc in res.docs:
142142
assert doc.id
143+
assert doc["id"]
143144
assert doc.play == "Henry IV"
145+
assert doc["play"] == "Henry IV"
144146
assert len(doc.txt) > 0
145147

146148
# test no content

0 commit comments

Comments
 (0)