Skip to content

Conversation

@barnuri
Copy link
Contributor

@barnuri barnuri commented Nov 17, 2025

This pull request adds a new method to the VectorStore class in vectorstores.py, enhancing its functionality to support similarity search directly by vector input.

New functionality:

  • Added the similarity_search_by_vector method to the VectorStore class, allowing users to perform similarity searches using a query vector and returning relevant documents.

@blink1073 blink1073 changed the title feat_add_search_by_vector INTPYTHON-832 Add search_by_vector method to VectorStore Nov 19, 2025
@blink1073
Copy link
Collaborator

Hi @barnuri, thanks again for this PR! Can you please add a test for this new method to https://github.com/langchain-ai/langchain-mongodb/blob/main/libs/langchain-mongodb/tests/integration_tests/test_vectorstore_from_texts.py?

@caseyclements
Copy link
Collaborator

Hi @barnuri. Just curious. Even though _similarity_search_with_score is marked for internal use by its leading underscore, what motivated you not to use it?

@barnuri
Copy link
Contributor Author

barnuri commented Nov 20, 2025

Hi @barnuri. Just curious. Even though _similarity_search_with_score is marked for internal use by its leading underscore, what motivated you not to use it?

we have a logic that already have the vector, and tried multiple searches, so embedded it every time instead of passing the vector its a waste

@barnuri
Copy link
Contributor Author

barnuri commented Nov 24, 2025

@blink1073 @caseyclements any update ?

barnuri and others added 4 commits November 24, 2025 22:16
Co-authored-by: barnuri <13019522+barnuri@users.noreply.github.com>
[WIP] Add docstring as suggested in review for patch 1
@barnuri barnuri requested a review from blink1073 November 24, 2025 20:33
@blink1073
Copy link
Collaborator

@blink1073
Copy link
Collaborator

Type checker errors:

langchain_mongodb/vectorstores.py:874: error: Signature of "similarity_search_by_vector" incompatible with supertype "langchain_core.vectorstores.base.VectorStore"  [override]
langchain_mongodb/vectorstores.py:874: note:      Superclass:
langchain_mongodb/vectorstores.py:874: note:          def similarity_search_by_vector(self, embedding: list[float], k: int = ..., **kwargs: Any) -> list[Document]
langchain_mongodb/vectorstores.py:874: note:      Subclass:
langchain_mongodb/vectorstores.py:874: note:          def similarity_search_by_vector(self, query_vector: list[float], *args: Any, **kwargs: Any) -> list[Document]
langchain_mongodb/vectorstores.py:900: error: "MongoDBAtlasVectorSearch" has no attribute "vector_store"  [attr-defined]
Installing missing stub packages:

@blink1073
Copy link
Collaborator

I'd suggest aligning with the superclass signature

Copilot AI and others added 3 commits November 24, 2025 21:07
Co-authored-by: barnuri <13019522+barnuri@users.noreply.github.com>
@barnuri
Copy link
Contributor Author

barnuri commented Nov 24, 2025

I'd suggest aligning with the superclass signature

fixed

Copy link
Collaborator

@blink1073 blink1073 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks again!

@blink1073 blink1073 merged commit cce6df2 into langchain-ai:main Nov 24, 2025
14 checks passed
@blink1073
Copy link
Collaborator

We're planning to wait until next week for the 0.9 release, since it is a holiday week for us.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants