Find answers from the community

Updated 3 months ago

Hello,

Hello,
I want to my users to be able to share document between another. I’m using qdrant, I’m wondering if the best practice would be to have an index per document, and each user have a collection of index, or if there is a way to move a file from one index (collection) to another collection without having to re do the embedding part ?
L
T
14 comments
I think its best practice to use filters -- its what qdrant actually recommends
I see, is it possible to add the group ID using llama index ?
yea -- that would just be a piece of metadata attached to the document/node
Then you can filter on that 👍
group_id is just the example too, it could be anything
username, organzation, etc.
I’m not sure to fully understand, where would this be used, when loading the query index or when querying it ?
For example

Plain Text
documents = [
  Document(text=..., metadata={"user_id": "123"})
  Document(text=..., metadata={"user_id": "321"})
]

index = VectorStoreIndex.from_documents(documents, ...)

from llama_index.core.vector_stores import (
    MetadataFilter,
    MetadataFilters,
    FilterOperator,
)

filters = MetadataFilters(
    filters=[
        MetadataFilter(key="user_id", operator=FilterOperator.EQ, value="123"),
    ]
)

# filtered query engine
query_engine = index.as_query_engine(..., filters=filters)

# filtered retriever
retriever = index.as_retriever(..., filters=filters)

etc.
Hope that makes sense
Right I see !
Thanks a lot
@Logan M do you know if it’s possible to have several filter with an OR ? When I try to set the condition with something like it’s always an AND

filters = MetadataFilters(
   filters=[
       MetadataFilter(key="user_id", operator=FilterOperator.EQ, value="user_id_1"),
       MetadataFilter(key="user_id", operator=FilterOperator.EQ, value="123"),
   ],
   condition=FilterCondition.OR,
)
Looks like the QdrantVectorStore treats everything as AND under the hood
you could pass in the filters in qdrant syntax, instead of using the filter objects

Plain Text
retriever = index.as_retriever(
    vector_store_kwargs={"qdrant_filters": <qdrant syntax filter>}
)
Add a reply
Sign up and join the conversation on Discord