fix(docstore): preserve retrieval ranking order in lancedb get() (#745)

This commit is contained in:
TommasoMoroHtx 2025-06-05 11:08:49 +02:00 committed by GitHub
parent ddb5187293
commit 833982ac81
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -113,14 +113,17 @@ class LanceDBDocumentStore(BaseDocumentStore):
) )
except (ValueError, FileNotFoundError): except (ValueError, FileNotFoundError):
docs = [] docs = []
return [
Document( # return the documents using the order of original ids (which were ordered by score)
id_=doc["id"], doc_dict = {
doc["id"]: Document(
d_=doc["id"],
text=doc["text"] if doc["text"] else "<empty>", text=doc["text"] if doc["text"] else "<empty>",
metadata=json.loads(doc["attributes"]), metadata=json.loads(doc["attributes"]),
) )
for doc in docs for doc in docs
] }
return [doc_dict[_id] for _id in ids if _id in doc_dict]
def delete(self, ids: Union[List[str], str], refresh_indices: bool = True): def delete(self, ids: Union[List[str], str], refresh_indices: bool = True):
"""Delete document by id""" """Delete document by id"""