Find answers from the community

Updated 2 months ago

Pg vectir

Hi everyone, I want to create a new User postgresql table that populates a relationship with the table created by PGVectorStore to mark the owner of documents in the vector store. Something like this:
Plain Text
class User(Base):
    __tablename__ = "users"

    id = Column(Integer, primary_key=True, index=True)
    email = Column(String, unique=True, index=True)
    hashed_password = Column(String)

    files = relationship("File", back_populates="owner")

How can I do that? I'm trying to create a new sqlalchemy model but don't know how to make PGVectorStore uses this instead of the default model.
Plain Text
class File(Base):
    __tablename__ = "data_pg_vector_store"

    id = Column(Integer, primary_key=True, index=True) 
    text = Column(String, index=True)
    metadata_ = Column(JSON, index=True)
    node_id = Column(String, unique=True, index=True)
    embedding = Column(Vector(1024))
    owner_id = Column(Integer, ForeignKey("users.id"))

    owner = relationship("User", back_populates="files")

Thanks in advance.
L
s
5 comments
Sadly you can't change the schema that pgvector store uses, without modifying source code

It requires a specific schema so that llamaindex knows how to query and retrieve data
Do you think of any solutions? I'm thinking of insert the user in the metadata_ and try to use filter on that column. Can I do that? 🧐
Yup, you can definitely do that
We actually just improved metadat filtering for postgres too. But I don't think it's on pypi just yet
OK, I'll give it a try. Thanks for your help
Add a reply
Sign up and join the conversation on Discord