AstraDB: use includeSimilarity option instead of $similarity (#13512)

- **Description:** AstraDB is going to deprecate the `$similarity`
projection property in favor of the ´includeSimilarity´ option flag. I
moved all the queries to the new format.
- **Tag maintainer:** @hemidactylus 
- **Twitter handle:** nicoloboschi
This commit is contained in:
Nicolò Boschi 2023-11-20 02:54:35 +01:00 committed by GitHub
parent 7100d586ef
commit 8362bd729b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -480,12 +480,11 @@ class AstraDB(VectorStore):
self.collection.paginated_find(
filter=metadata_parameter,
sort={"$vector": embedding},
options={"limit": k},
options={"limit": k, "includeSimilarity": True},
projection={
"_id": 1,
"content": 1,
"metadata": 1,
"$similarity": 1,
},
)
)
@ -609,12 +608,11 @@ class AstraDB(VectorStore):
self.collection.paginated_find(
filter=metadata_parameter,
sort={"$vector": embedding},
options={"limit": fetch_k},
options={"limit": fetch_k, "includeSimilarity": True},
projection={
"_id": 1,
"content": 1,
"metadata": 1,
"$similarity": 1,
"$vector": 1,
},
)