qdrant / qdrant-client

Python client for Qdrant vector search engine
https://qdrant.tech
Apache License 2.0
738 stars 118 forks source link

`set_payload` in a nested payload #780

Open lambda-science opened 7 hours ago

lambda-science commented 7 hours ago

Hello.

I tried to change my points payload using Qdrant client. And I face a very non consistent behaviour driving me a bit crazy My points payload are like:

{
   "payload":{
      "meta":{
         "group_id": "a@b.com",
         "title": "My Document"
      }
   }
}

So basically all my fields are in a dict named meta and I want to modify the group_id with a new value. I used the following code: With the following code:

for key, value in uuid_email_mapping.items():
    body = {"group_id": value}
    resp = client.set_payload(
        collection_name=COLLECTION_NAME,
        payload=body,
        key="meta",
        points=qdrant_client.models.Filter(
            must=[
                qdrant_client.models.FieldCondition(
                    key="meta.group_id",
                    match=qdrant_client.models.MatchValue(value=key),
                ),
            ],
        ),
        wait=True,
    )

It doesn't work, it put the new group id at the root like

{
   "payload":{
      "group_id": "new group id",
      "meta":{
         "group_id": "a@b.com",
         "title": "My Document"
      }
   }
}

With the following code:

for key, value in uuid_email_mapping.items():
    body = {"meta.group_id": value}
    resp = client.set_payload(
        collection_name=COLLECTION_NAME,
        payload=body,
        key="meta",
        points=qdrant_client.models.Filter(
            must=[
                qdrant_client.models.FieldCondition(
                    key="meta.group_id",
                    match=qdrant_client.models.MatchValue(value=key),
                ),
            ],
        ),
        wait=True,
    )

It doesn't work, it put the new group id in the meta dict but also with meta prefix, like:

{
   "payload":{
      "meta":{
         "group_id": "a@b.com",
         "title": "My Document",
         "meta.group_id": "new group id",
      }
   }
}
lambda-science commented 7 hours ago

Version of cluster on Qdrant Cloud is 1.11.3 Related PR: https://github.com/qdrant/qdrant-client/pull/536#issuecomment-1994557600

lambda-science commented 7 hours ago
    body = {'meta.group_id': value}
    resp = client.set_payload(
        collection_name=COLLECTION_NAME,
        payload=body,
        points=qdrant_client.models.Filter(
            must=[
                qdrant_client.models.FieldCondition(
                    key='meta.group_id',
                    match=qdrant_client.models.MatchValue(value=key),
                ),
            ],
        ),
        wait=True,
    )
    print(resp)
{
   "payload":{
      "meta.group_id": "new group id",
      "meta":{
         "group_id": "a@b.com",
         "title": "My Document",

      }
   }
}

Driving me a bit crazy