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 <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>
  • Loading branch information
8 people committed 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
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
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.