Fix the vector retrieval sorting issue (#6431)

Co-authored-by: weifj <“weifj@tuyuansu.com.cn”>
This commit is contained in:
leoterry 2024-07-18 19:25:41 +08:00 committed by GitHub
parent c0ec40e483
commit dc847ba145
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 6 additions and 2 deletions

View File

@ -111,7 +111,8 @@ class ChromaVector(BaseVector):
metadata=metadata,
)
docs.append(doc)
# Sort the documents by score in descending order
docs = sorted(docs, key=lambda x: x.metadata['score'], reverse=True)
return docs
def search_by_full_text(self, query: str, **kwargs: Any) -> list[Document]:

View File

@ -362,6 +362,8 @@ class QdrantVector(BaseVector):
metadata=metadata,
)
docs.append(doc)
# Sort the documents by score in descending order
docs = sorted(docs, key=lambda x: x.metadata['score'], reverse=True)
return docs
def search_by_full_text(self, query: str, **kwargs: Any) -> list[Document]:

View File

@ -216,7 +216,8 @@ class WeaviateVector(BaseVector):
if score > score_threshold:
doc.metadata['score'] = score
docs.append(doc)
# Sort the documents by score in descending order
docs = sorted(docs, key=lambda x: x.metadata['score'], reverse=True)
return docs
def search_by_full_text(self, query: str, **kwargs: Any) -> list[Document]: