-
Notifications
You must be signed in to change notification settings - Fork 238
find doesn't return DocList with same doc_type as index #1445
Copy link
Copy link
Closed
Description
When using find, the DocList returned in the FindResult doesn't keep the same doc_type as the index. Is this intended? It would be a nice QOL to use specific attributes for all of the matches such as .text.
Python version: 3.11.2
Docarray version: 0.30.0
Reproducible example:
import numpy
from docarray import DocList, BaseDoc
from docarray.typing import NdArray
from docarray.utils.find import find
class Text(BaseDoc):
embedding: NdArray[128]
text: str
if __name__ == "__main__":
store = DocList[Text](
[Text(embedding=numpy.random.rand(128), text="Hello, world!") for i in range(10)]
)
query = Text(embedding=numpy.random.rand(128), text="Random query")
matches, scores = find(
index=store,
query=query,
search_field="embedding",
limit=3
)
print(matches.doc_type, store.doc_type)
# Fails on print(matches.text)Output <class 'docarray.base_doc.any_doc.AnyDoc'> <class '__main__.Text'>
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
Type
Projects
Status
Done