# Filter on content relationship nested field

**URL:** <https://community.prismic.io/t/filter-on-content-relationship-nested-field/13809>\
**Category:** Developing with Prismic\
**Created:** [August 3, 2023, 5:04pm UTC](https://community.prismic.io/t/filter-on-content-relationship-nested-field/13809 "2023-08-03T17:04:21Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![pi.raph](https://dub1.discourse-cdn.com/flex013/user_avatar/community.prismic.io/pi.raph/32/6164_2.png) [@pi.raph](https://community.prismic.io/u/pi.raph)\
**Post date:** [August 3, 2023, 5:04pm UTC](https://community.prismic.io/t/filter-on-content-relationship-nested-field/13809/1 "2023-08-03T17:04:21Z")

</div>

Hello,

I'm using `"@prismicio/client": "^7.1.0"` and I would like to know if it's possible to filter on content relationship nested field.

Example:  
I have two custom types: article and category.

- article.category is a content relationship field
- category.mysubfield = "a" | "b" | "c"

I would like to use `client.getByType` with a filters options like this:

```auto
filters: [filter.any("my.article.category.mysubfield", ["a", "b"])]

```

I've also tried to preload the categories and use an array of IDs, with **in** or **any** operator, but didn't work either:

```auto
filters: [filter.in("my.article.category", categories.map(({ id }) => id))]

```

ps: I'm well aware of **[Content Relationship - Documentation - Prismic](https://prismic.io/docs/content-relationship#query-by-content-relationship)** and **[@prismicio/client Technical Reference - Documentation - Prismic](https://prismic.io/docs/technical-reference/prismicio-client#query-filters)**

Thank you for your time,  
Raphael

---

<div class="post-metadata">

**Author:** ![Pau](https://dub1.discourse-cdn.com/flex013/user_avatar/community.prismic.io/pau/32/5422_2.png) [@Pau](https://community.prismic.io/u/Pau)\
**Post date:** [August 4, 2023, 12:03pm UTC](https://community.prismic.io/t/filter-on-content-relationship-nested-field/13809/3 "2023-08-04T12:03:12Z")

</div>

Filtering on nested fields within a Content Relationship is not supported directly but you can still query first level content from linked documents using REST

`my.[custom-type].[relationship-field]`

> **[Rest API Technical Reference](https://prismic.io/docs/rest-api-technical-reference#at)**
>
> The Prismic Rest API is an extremely fast, flexible, and powerful engine for your content. On this page, you will learn how to query the Rest API, including how to use filters, query options, and GraphQuery.

---

<div class="post-metadata">

**Author:** ![pi.raph](https://dub1.discourse-cdn.com/flex013/user_avatar/community.prismic.io/pi.raph/32/6164_2.png) [@pi.raph](https://community.prismic.io/u/pi.raph)\
**Post date:** [August 4, 2023, 1:41pm UTC](https://community.prismic.io/t/filter-on-content-relationship-nested-field/13809/4 "2023-08-04T13:41:41Z")

</div>

Hello,

Thanks for your response.  
Looks like there is no proper solution but I've managed to do with a combinaison of loading the sub collection and the any operator

```auto
filter.any(
        "my.article.category",
        categories.map(({ id }) => id),
      ),

```
