son
son

Reputation: 13

llama index vectorstore querying with specific filtering

I have this simple code to query from files thats saved in a chroma vector store. Now if each file belongs to some user and each user can only query with data from their files and not others, how can I achieve this? I was thinking maybe save userId as metadata for each document and query with userId as filter, any help would be greatly appreciated. Thanks!

chroma_client = chromadb.PersistentClient(path="chroma")
chroma_collection = chroma_client.get_collection("quickstart")

vector_store = ChromaVectorStore(chroma_collection=chroma_collection)
index = VectorStoreIndex.from_vector_store(vector_store=vector_store)

retriever = index.as_retriever(retriever_mode='embedding')
query_engine = RetrieverQueryEngine(retriever)
query_engine = index.as_query_engine()
response = query_engine.query("what's the persons name")
print(response)

I tried asking the assistant from their website but it just gives random answers. Currently going through their doc to maybe get some lead.

Upvotes: 1

Views: 4529

Answers (1)

son
son

Reputation: 13

After messing around a bit, I found using metadata to tell the documents apart did not give consistent results so I created a vectorstore for each user and store their data there, working fine so far.

Upvotes: -3

Related Questions