# How to get multiple objects by id in one call?

**URL:** <https://forum.weaviate.io/t/how-to-get-multiple-objects-by-id-in-one-call/5278>\
**Category:** Support\
**Created:** [October 14, 2024, 2:55pm UTC](https://forum.weaviate.io/t/how-to-get-multiple-objects-by-id-in-one-call/5278 "2024-10-14T14:55:23Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![msj242](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.weaviate.io/msj242/32/340_2.png) [@msj242](https://forum.weaviate.io/u/msj242)\
**Post date:** [October 14, 2024, 2:55pm UTC](https://forum.weaviate.io/t/how-to-get-multiple-objects-by-id-in-one-call/5278/1 "2024-10-14T14:55:23Z")

</div>

I’d like to query multiple Ids but in one call to the server - I am using the client on nodejs.

would

```auto
builder.withWhere({
                    path: ["id"],
                    operator: "ContainsAny",
                    valueString: [...ids...]
                });

```

Assuming there are 10 ids will this definitely find all 10 if they exist? Or are there efficiency limits so that it won’t search the whole database to get all 10? (I know these limits can happen with text/vector searches etc…).

Ie: should I do 10 separate find by id searches to definitely find the objects - or can I safely use the above?

---

<div class="post-metadata">

**Author:** ![DudaNogueira](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.weaviate.io/dudanogueira/32/7846_2.png) [@DudaNogueira](https://forum.weaviate.io/u/DudaNogueira)\
**Post date:** [October 14, 2024, 3:29pm UTC](https://forum.weaviate.io/t/how-to-get-multiple-objects-by-id-in-one-call/5278/2 "2024-10-14T15:29:35Z")

</div>

hi @msj242 !!

I believe this is the best way to filter.

Here is a full python v4 example:

```python
from weaviate.util import generate_uuid5
client.collections.delete("Test")

collection = client.collections.create(
    name="Test",
    vectorizer_config=wvc.config.Configure.Vectorizer.none(),
    properties=[
        wvc.config.Property(
            name="text",
            data_type=wvc.config.DataType.TEXT,
            vectorize_property_name=True,
            tokenization=wvc.config.Tokenization.WORD
        ),
    ]
)

for i in range(10):
    collection.data.insert({"text": f"content {i}"}, uuid=generate_uuid5(i))

query = collection.query.fetch_objects(
    filters=wvc.query.Filter.by_property("_id").contains_any([generate_uuid5(1), generate_uuid5(3)])
)

for object in query.objects:
    print(object.properties)

```

---

<div class="post-metadata">

**Author:** ![msj242](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.weaviate.io/msj242/32/340_2.png) [@msj242](https://forum.weaviate.io/u/msj242)\
**Post date:** [October 14, 2024, 4:32pm UTC](https://forum.weaviate.io/t/how-to-get-multiple-objects-by-id-in-one-call/5278/3 "2024-10-14T16:32:23Z")

</div>

@DudaNogueira Just curious though if “contains\_any” will search the database for all the ids - or if there is a limit to the search. I understood text/vector searches have some limit to preserve resources.

Thanks!

---

<div class="post-metadata">

**Author:** ![parkerduckworth](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.weaviate.io/parkerduckworth/32/206_2.png) [@parkerduckworth](https://forum.weaviate.io/u/parkerduckworth)\
**Post date:** [October 15, 2024, 8:01pm UTC](https://forum.weaviate.io/t/how-to-get-multiple-objects-by-id-in-one-call/5278/4 "2024-10-15T20:01:39Z")

</div>

Hey @msj242, under the hood, `contains_any` just builds a filter which is passed into the same search function as any other search. So the global max limit, `QUERY_MAXIMUM_RESULTS`, will be applied in the same manner 🙂
