Adding MongoDB as a vector store.
Implemented using basically the same logic and math as InMemoryVectorStore
so it's prob worth breaking some of those shared classes out.
Big thanks to @tzolov for the work on pgvector-store
, I was able to use most of his tests as guidance
Comment From: markpollack
Thanks so much, will review!
Comment From: markpollack
This is a strange case. All other vector stores that I'm aware of would implement the search inside the database, where as in this case is implementing a search as a linear in-memory scan. I think we would violate the "Principle of least astonishment" with this implementation. The implementation should be changed/updated to use AtlastVectorSearch from MongoDB.
I'll leave the PR open for a while to discuss.
Comment From: markpollack
Maybe contributing a MongoDB implementation of org.springframework.ai.loader.Loader
would be a good reuse of this PR for another feature. Thoughts?
Comment From: tzolov
@Kirbstomper,
For me would bring more value if the mongodb integration supports the Atlast VectorSearch
.
Don't know how challenging this task might be but will appreciate if you can explore this direction.
The Loader is a good idea as well.
Comment From: Kirbstomper
@markpollack @tzolov Getting a MongoDB data loader together doesn't look like it will be too much trouble. I can explore that in a separate feature/PR.
As for better supporting the capabilities provided by Atlas I can start to explore that direction. For now I think we can close this PR until that gets to a more realized state.
Comment From: jxblum
Have a look at Spring AI Issue #48. MongoDB offers Atlas Vector Search, which might be a suitable way to go.
Comment From: Kirbstomper
Have a look at Spring AI Issue #48. MongoDB offers Atlas Vector Search, which might be a suitable way to go.
So I was looking into this a bit last week. Using its built in similarity search seemed to be giving results I didn't expect, so need to take a deeper look on it
Comment From: markpollack
I'll close this PR for now and there can be a new one that includes support for mongodb's native capabilities.