diff options
author | Abhishek Kumar Sinha <aksinha334@gmail.com> | 2023-03-16 01:19:02 +0530 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-15 21:49:02 +0200 |
commit | 8bfd492240fd33489a86cd3d353e3ece1fc94c10 (patch) | |
tree | e271726b839c16ceed57b794f66fc79bd28b5811 | |
parent | a372ba4f28f874ebff008a3bb4f5ce06104fd29b (diff) | |
download | redis-py-8bfd492240fd33489a86cd3d353e3ece1fc94c10.tar.gz |
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>
-rw-r--r-- | redis/commands/search/document.py | 4 | ||||
-rw-r--r-- | tests/test_search.py | 2 |
2 files changed, 6 insertions, 0 deletions
diff --git a/redis/commands/search/document.py b/redis/commands/search/document.py index 5b30505..47534ec 100644 --- a/redis/commands/search/document.py +++ b/redis/commands/search/document.py @@ -11,3 +11,7 @@ class Document: def __repr__(self): return f"Document {self.__dict__}" + + def __getitem__(self, item): + value = getattr(self, item) + return value diff --git a/tests/test_search.py b/tests/test_search.py index 57d4338..7a24281 100644 --- a/tests/test_search.py +++ b/tests/test_search.py @@ -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 |