Skip to content

Commit

Permalink
Making search document subscriptable (#2615)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>

* Speeding up the protocol parsing (#2596)

* speeding up the protocol parser

* linting

* changes to ease

* Fixed CredentialsProvider examples (#2587)

Co-authored-by: dvora-h <[email protected]>

* 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 <[email protected]>
Co-authored-by: Alex Schmitz <[email protected]>
Co-authored-by: Chayim <[email protected]>
Co-authored-by: Bar Shaul <[email protected]>
Co-authored-by: dvora-h <[email protected]>
Co-authored-by: CrimsonGlory <[email protected]>
Co-authored-by: Raymond Yin <[email protected]>
  • Loading branch information
8 people authored Mar 15, 2023
1 parent a372ba4 commit 8bfd492
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
4 changes: 4 additions & 0 deletions redis/commands/search/document.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,7 @@ def __init__(self, id, payload=None, **fields):

def __repr__(self):
return f"Document {self.__dict__}"

def __getitem__(self, item):
value = getattr(self, item)
return value
2 changes: 2 additions & 0 deletions tests/test_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,9 @@ def test_client(client):

for doc in res.docs:
assert doc.id
assert doc["id"]
assert doc.play == "Henry IV"
assert doc["play"] == "Henry IV"
assert len(doc.txt) > 0

# test no content
Expand Down

0 comments on commit 8bfd492

Please sign in to comment.