Find answers from the community

Updated 3 months ago

Qdrant query

Hello! Thanks for the great library! I have a question about using Qdrant. I was able to save the index to qdrant collection but I can't figure out how to query it after. I found this code but stuck then

Plain Text
qdrant_vector_store = QdrantVectorStore(collection_name="test", client=qdrant_client)
query = VectorStoreQuery(query_str='Did Y Combinator have its name always?')

What should I do now? (The complement question is: should I save each separate index (based on a different set of documents) into a separate collection?) THANKS!
L
S
8 comments
Yes, of course! But it doesn't show how I query the indices stored in the database, after. Let me describe the use case:
I'm working on an app allowing users to load their custom data and then query them. I'm building index (exactly as shown in this example), then save to the qdrant. As I should provide a unified code for every single user, at them moment they will query their own index, I have no idea which index they will query.
I assume I can create a separate collection for each index (say, based on the user's dataset's ID or so) and then I will have to find this collection (what is easy) and query it. So, how to do that?
I found this example for Qdrant:
Plain Text
    response = openai.Embedding.create(
        input="What is starship?",
        model="text-embedding-ada-002"
    )
    embeddings = response['data'][0]['embedding']

    search_result = qdrant_client.search(
        collection_name="mycollection",
        query_vector=embeddings, 
        limit=5
    )

I suppose LlamIndex should have something like that?
To later query an existing index that you saved on qdrant, im pretty sure you can do something like this

index = GPTQdrantIndex([], client=client, collection_name="collection_name")

index.query("my query")
Thanks! I will try tomorrow and let you know how it works.
Yep, it worked!! Back to my second question, should I create a separate collection for each index built from a specific set of documents? One consideration is the index dimensions - a collection may not have indices with different dimensions and from LlamaIndex docs and code it's not clear if it's always the same or not. Thanks!
Hmm, What do you mean by index dimensions?

If you have a system where different users are uploading documents, I think it makes sense to create an index/collection for each user
I meant the dimensions of vector (I guess of embeddings), and from the qdrant documentation "A collection is a named set of points (vectors with a payload) among which you can search. Vectors within the same collection must have the same dimensionality and be compared by a single metric."
Right! As long as you use a consistent embedding model, the dimensions should always match (openAI embeddings are 1536 dimensions)
Add a reply
Sign up and join the conversation on Discord