> For the complete documentation index, see [llms.txt](https://developer.collibra.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developer.collibra.com/api/guides/common-concepts/filtering/collections-filtering.md).

# Collections filtering

In addition to entity properties, you can apply filtering on collections that are in relation with those entities, with the following operators:

## Operators

| Name         | Type                      | Description                                                                                                                                                       |
| ------------ | ------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| any          | Depends on the collection | Any of the collection items matches the given expression.                                                                                                         |
| all          | Depends on the collection | Every collection item matches the given expression.                                                                                                               |
| none         | Depends on the collection | None of the collection items matches the given expression.                                                                                                        |
| empty        | Boolean                   | The target collection is empty.                                                                                                                                   |
| typePublicId | String                    | Only available for the `typed` collections, such as asset attributes or relations. Allows you to filter collection elements by the public ID of the element type. |

{% hint style="info" %}
You can only use one of the `any`, `all`, `none`, and `empty` operators in the same collection filter expression.
{% endhint %}

### The `any` operator

This filtering operator means that any of the related entities fulfill the given criteria. The following example is a query for all assets with a **stringAttribute** that contains the word **personal** and is created by user with first name **Admin**:

```graphql
query {
    assets(
        where: {
            stringAttributes: {
                any: {_and: [
                    {stringValue: {contains: "Personal"}}
                    {createdBy: {firstName: {eq: "Admin"}}}
                ]}}
        }
    ) {
        id
        fullName
        stringAttributes {
            stringValue
            createdBy {
                firstName
            }
        }
    }
}
```

The response contains all assets that have a string attribute containing the word **personal** and created by a user with first name **Admin** but all of the other string attributes are returned. To further narrow down the results and only get the descriptions, add another filter on the inner **stringAttributes** field:

```graphql
query {
    assets(
        where: {
            stringAttributes: {any: {_and: [
                {stringValue: {contains: "Personal"}}
                {createdBy: {firstName: {eq: "Admin"}}}
            ]}}
        }
    ) {
        id
        fullName
        stringAttributes(where: {createdBy: {firstName: {eq: "Admin"}}}) {
            stringValue
            createdBy {
                firstName
            }
        }
    }
}
```

### The `all` operator

This filtering operator means that every entity fulfills the given criteria. The following example is a query for domains where all of the assets have the status **Accepted**:

```graphql
query {
    domains(
        where: { assets: { all: { status: { name: { eq: "Accepted" } } } } }
    ) {
        id
        assets {
            fullName
            status {
                name
            }
        }
    }
}
```

### The `none` operator

This filtering operator means that none of the entities fulfills the given criteria. This example demonstrates how to query the opposite of the `all` query example, domains where none of their assets have the status **Accepted**:

```graphql
query {
    domains(
        where: { assets: { none: { status: { name: { eq: "Accepted" } } } } }
    ) {
        id
        assets {
            fullName
            status {
                name
            }
        }
    }
}
```

The difference between using `{ all: { status: { name: { ne: "Accepted" } } } }` and `{ none: { status: { name: { eq: "Accepted" } } } }` is that for the `none` condition, the response contains domains where there are no assets or there are assets with no status set.

### The `empty` operator

This operator specifies that a given collection is empty. The following example is a query for all of the assets that don't have any `dateAttributes` assigned:

```graphql
query {
    assets(where: { dateAttributes: { empty: true } }) {
        id
        fullName
        dateAttributes {
            type {
                name
            }
            dateValue
        }
    }
}
```

### The `typePublicId` operator

This filtering operator restricts the next filtering condition to only apply on a given type of relation. It is the equivalent of `{ type: { publicId: { eq: "someValue" } } }`.

You can add the filter in a collection filter using the implicit `AND`. The following example returns assets that don't have any **stringAttributes** that have a **publicId** equal to **Note**:

```graphql
query {
    assets(where: { stringAttributes: { typePublicId: "Note", empty: true } }) {
        id
        fullName
        stringAttributes(where: { type: { publicId: { eq: "Note" } } }) {
            stringValue
            type {
                name
            }
        }
    }
}
```

In all of the above examples the query fetches the fields you are filtering on even though this is not necessary. If you don't need to verify the results, the above query is going to return the same asset data when omitting fetching the **stringAttributes**:

```graphql
query {
    assets(where: { stringAttributes: { typePublicId: "Note", empty: true } }) {
        id
        fullName
    }
}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://developer.collibra.com/api/guides/common-concepts/filtering/collections-filtering.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
