Filter query by nested content relationship fields

Hello, I'm trying to get all documents of a type, filtered by 2 levels deep nested relationship fields.

I have a "photo" document that has the "entities" content relationship field which connects to the "car" document. The "car" document has the "manufacturer" content realtionship field that connects to the "car_manufacturer" document.

I need to get the "photo" documents that has cars with only specific manufacturer, is this possible?

I have tried the following, but i get error "unexpected field":

  const photos = await client.getByType("photo", {
    filters: [
      filter.at(
        "my.photo.entities.entity.manufacturer.car_manufacturer",
        page.id
      ),
    ],
  });

Thanks in advance

Hi, @john-mantas. Unfortunately, it isn't possible to filter by nested relationships like this.

Hi @Levi, thank you for the reply.

I had to add the nested relationship of the manufacturer as an extra separate "entity" to the "entities" relationship field of the photo to make it work, which is duplicate data entry and error prone but couldn't find another way

I'm glad that you found a workaround, but I'm sorry that it isn't ideal.

1 Like