Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions libs/langchain-mongodb/langchain_mongodb/vectorstores.py
Original file line number Diff line number Diff line change
Expand Up @@ -877,6 +877,26 @@ def similarity_search_by_vector(
*args: Any,
**kwargs: Any,
) -> list[Document]:
"""Return MongoDB documents most similar to the given query vector.

Atlas Vector Search eliminates the need to run a separate
search system alongside your database.

Args:
query_vector: Embedding vector to search for.
k: (Optional) number of documents to return. Defaults to 4.
pre_filter: List of MQL match expressions comparing an indexed field
post_filter_pipeline: (Optional) Pipeline of MongoDB aggregation stages
to filter/process results after $vectorSearch.
oversampling_factor: Multiple of k used when generating number of candidates
at each step in the HNSW Vector Search.
include_embeddings: If True, the embedding vector of each result
will be included in metadata.
kwargs: Additional arguments are specific to the search_type

Returns:
List of documents most similar to the query vector.
"""
tuple_list = self.vector_store._similarity_search_with_score(
query_vector,
*args,
Expand Down