> For the complete documentation index, see [llms.txt](https://docs.umbraco.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.umbraco.com/umbraco-compose/apis/graphql/filtering.md).

# Filtering

Explains how to filter GraphQL query results in Umbraco Compose using field conditions, filter methods, and boolean logic.

GraphQL query results can be filtered by specifying a `where` argument.

The value of this argument should be an object with information about the field and the type of filter to apply. For example, to retrieve the name of the product with ID 7 from the `products` collection, use the following query:

```graphql
query {
    products (where: { id: 7 }) {
        items {
            ... on Product {
                id
                name
                price
            }
        }
    }
}
```

## Filter Methods

In the above query, no filter type has been supplied, so GraphQL will default to comparing equality. It is possible to supply a different filter method. Do this by appending a filter suffix separated by an underscore character. Filters can only be applied to supported field types, as shown below:

<details>

<summary>All field types</summary>

| Suffix      | Includes Results When...                         |
| ----------- | ------------------------------------------------ |
| *No suffix* | The field is equal to a given value              |
| \_any       | The field is equal to any value in a given array |

</details>

<details>

<summary>Numbers &#x26; Datetimes</summary>

| Suffix | Includes Results When...                            |
| ------ | --------------------------------------------------- |
| \_gt   | The field is greater than a given value             |
| \_gte  | The field is greater than or equal to a given value |
| \_lt   | The field is less than a given value                |
| \_lte  | The field is less than or equal to a given value    |

</details>

<details>

<summary>Strings</summary>

| Suffix         | Includes Results When...                |
| -------------- | --------------------------------------- |
| \_contains     | The field contains a given substring    |
| \_starts\_with | The field starts with a given substring |
| \_ends\_with   | The field ends with a given substring   |

</details>

## Filtering by Type

You can filter results to include only content items with a specific type schema. You can do that by specifying an object with an empty property named after your type. For example, to select all content items of type `product` from the `content` collection, you might use the following query:

```graphql
query {
    content (where: { product: {}})
    {
        items {
            ... on Product {
                # Selected fields
            }
        }
    }
}
```

## Filtering by Property

You can filter by some property value of a type by first specifying the type, then the property on which to filter. For example, to retrieve all products priced at $10 or more, you might use the following query:

```graphql
query {
    products (where: { product: { price_gte: 10 }}) {
        items {
            ... on Product {
                # Selected fields
            }
        }
    }
}
```

## Nested Filtering

You can filter on properties of a nested object. This is done by passing a likewise nested object to the `where` argument. For example, the following query fetches all articles written by authors with specific names.

```graphql
query {
    articles (where: {
        article: {
            author: {
                name_any: ["John", "Jane"]
            }
        }
    })
    {
        items {
            ... on Article {
                # Selected fields
            }
        }
    }
}
```

## Filter Logic

Queries can also combine or invert filters using boolean operators.

```graphql
query {
    authors (where: {
        AND: [
            { author: { firstName: "John" }},
            { author: { lastName: "Doe" }}
        ]
    })
    {
        items {
            ... on Author {
                # Selected fields
            }
        }
    }
}
```

The boolean operators themselves may be nested inside of one another to create complex filters.


---

# 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, and the optional `goal` query parameter:

```
GET https://docs.umbraco.com/umbraco-compose/apis/graphql/filtering.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
