diff --git a/libs/astradb/langchain_astradb/vectorstores.py b/libs/astradb/langchain_astradb/vectorstores.py index 6133440..6fbcc40 100644 --- a/libs/astradb/langchain_astradb/vectorstores.py +++ b/libs/astradb/langchain_astradb/vectorstores.py @@ -1801,9 +1801,6 @@ async def asimilarity_search_with_embedding( k: Number of Documents to return. Defaults to 4. filter: Filter on the metadata to apply. - Notes: - Either 'query' or 'query_embedding' must be set. - Returns: (query_embedding, List of (Document, embedding) most similar to the query). """ @@ -1831,6 +1828,10 @@ async def asimilarity_search_with_embedding( ) raise TypeError(msg) + # shortcut return if query isn't needed. + if k == 0 and len(query_embedding) > 0: + return (query_embedding, []) + async_cursor = self.astra_env.async_collection.find( filter=self.filter_to_query(filter), projection=self.document_codec.full_projection,