mirror of
https://github.com/langchain-ai/langchain-postgres.git
synced 2026-08-24 11:42:51 -04:00
How to query CollectionStore and EmbeddingStore models directly in a clean way? #29
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @darahayes on GitHub (Jul 11, 2024).
Hello, thanks for this great project I've found it very useful. I have a use case right now where within one application I want to create and manage multiple collections as well as being able to fetch and return details about some collections, e.g. the name and the collection metadata - Essentially my use case is CRUD for collections.
Currently I don't really see any way to do that cleanly other than dropping down to raw SQL queries in my application. Would this be the recommended approach?
I see in the source code in
vectorstores.pythat there are "private"/unexposed SQLAlchemy models defined forCollectionStoreandEmbeddingsStore.Having them exposed would make querying against the tables a lot easier, at least for my particular use case.I can understand why you might want to keep them private - they might be subject to change and any user code that touches those models potentially breaks. But I think even when the models are not exposed, if there were changes that resulted in the database tables being different, this would still be a breaking change for a lot of apps anyways.
Is exposing those models something you might consider? Or would you recommend going with raw SQL? Would be more than happy to submit a PR. Thanks!
@eyurtsev commented on GitHub (Jul 12, 2024):
Hi @darahayes, there's no current way to do this.
This code needs to be refactored to support two things:
Here's a stub at the abstraction that's needed: https://github.com/langchain-ai/langchain/pull/23990/files
This would also open up the pathway for being able to apply specific types of indices on the collections and do schema migration down the roads if necessary.
If you're interested in helping out, I can help provide some guidance if needed!
@Sachin-Bhat commented on GitHub (Jul 18, 2024):
Hey @eyurtsev,
If more information is given I can take this up.
Cheers,
Sachin
@ghost commented on GitHub (May 23, 2025):
Langchain is exposing its
UpsertionRecordwhat can be referenced as a type or used to fetch rows from DB without raw SQLhttps://github.com/langchain-ai/langchain/blob/master/libs/langchain/langchain/indexes/_sql_record_manager.py#L53-L83
What's the exact blocker to expose
CollectionStoreandEmbeddingStoresimilar way inlangchain-postgrespackage?