diff --git a/redis/commands/search/document.py b/redis/commands/search/document.py index 5b3050545a..47534ec248 100644 --- a/redis/commands/search/document.py +++ b/redis/commands/search/document.py @@ -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 diff --git a/tests/test_search.py b/tests/test_search.py index 57d4338ead..7a2428151e 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