Best way to access objects using uuids in bulk/batch

What’s the best way to search objects using the uuid in batch/bulk at once.

client.data_object.get_by_id(uuid=document_id, class_name=class_name)

What if I want the bulk result, a way to pass multiple document_ids at once.

Hi @Mohit_Kumawat ! Welcome to our Community :hugs:

We have just released Weaviate 1.21.0, wich includes the ContainsAny and ContainsAll filters that can search thru an array of uuids fields.

However, it’s not yet merged into the Python client, but you can always use the raw method in order to query with Graphql directly.

Thanks for the response, What’s the correct way to access the uuid field in the where clause? Or ContainsAny clause?

Here is a python snippet that can do it:

import weaviate
client = weaviate.Client(url="http://localhost:8080")

for item in ["bar1", "bar2", "bar3"]:
    print(client.data_object.create({"foo": item}, "Documents", weaviate.util.generate_uuid5(item)))

# generated ids
# 9c4e9553-efba-53c6-9292-6fa221bea96d
# 9f6803c4-1bbd-554b-9356-3621b1d5d55b
# 8c19c346-105e-5b32-9c9b-a58642d1b0f7

# now you can query with:
client.query.raw('''
{
  Get{
    Documents(where: {
        path: ["id"],
        operator: ContainsAny,
        valueText: ["8c19c346-105e-5b32-9c9b-a58642d1b0f7", "9c4e9553-efba-53c6-9292-6fa221bea96d"]
      }){
      foo
    }
  }
}
''')
# should output: {'data': {'Get': {'Documents': [{'foo': 'bar1'}, {'foo': 'bar3'}]}}}

# now for the ContainsAll

client.query.raw('''
{
  Get{
    Documents(where: {
        path: ["id"],
        operator: ContainsAll,
        valueText: ["8c19c346-105e-5b32-9c9b-a58642d1b0f7", "9c4e9553-efba-53c6-9292-6fa221bea96d"]
      }){
      foo
    }
  }
}
''')
# should output:
# {'data': {'Get': {'Documents': []}}}

Let me me know if that helps :slight_smile:

Yes, that definitely helped. Thanks!