# Using filters with the Document Service API

> Source: https://docs.strapi.io/cms/api/document-service/filters

The Document Service API provides attribute operators (`$eq`, `$lt`, `$contains`, etc.) and logical operators (`$and`, `$or`, `$not`) to filter query results with support for case-sensitive and case-insensitive matching.

The [Document Service API](/cms/api/document-service) offers the ability to filter results.

The following operators are available:

| Operator                         | Description                              |
| -------------------------------- | ---------------------------------------- |
| [`$eq`](#eq)                     | Equal                                    |
| [`$eqi`](#eqi)                   | Equal (case-insensitive)                 |
| [`$ne`](#ne)                     | Not equal                                |
| [`$nei`](#nei)                   | Not equal (case-insensitive)             |
| [`$lt`](#lt)                     | Less than                                |
| [`$lte`](#lte)                   | Less than or equal to                    |
| [`$gt`](#gt)                     | Greater than                             |
| [`$gte`](#gte)                   | Greater than or equal to                 |
| [`$in`](#in)                     | Included in an array                     |
| [`$notIn`](#notin)               | Not included in an array                 |
| [`$contains`](#contains)         | Contains                                 |
| [`$notContains`](#notcontains)   | Does not contain                         |
| [`$containsi`](#containsi)       | Contains (case-insensitive)              |
| [`$notContainsi`](#notcontainsi) | Does not contain (case-insensitive)      |
| [`$null`](#null)                 | Is null                                  |
| [`$notNull`](#notnull)           | Is not null                              |
| [`$between`](#between)           | Is between                               |
| [`$startsWith`](#startswith)     | Starts with                              |
| [`$startsWithi`](#startswithi)   | Starts with (case-insensitive)           |
| [`$endsWith`](#endswith)         | Ends with                                |
| [`$endsWithi`](#endswithi)       | Ends with (case-insensitive)             |
| [`$or`](#or)                     | Joins the filters in an "or" expression  |
| [`$and`](#and)                   | Joins the filters in an "and" expression |
| [`$not`](#not)                   | Joins the filters in an "not" expression |

:::strapi Deep filtering with the various APIs
For examples of how to deep filter with the various APIs, please refer to [this blog article](https://strapi.io/blog/deep-filtering-alpha-26).
:::

## Attribute operators

<br/>

#### GET strapi.documents().findMany() — $not

Negates the nested condition(s).

**JavaScript:**
```
const entries = await strapi.documents('api::article.article').findMany({
  filters: {
    title: {
      $not: {
        $contains: 'Hello World',
      },
    },
  },
});
```

#### GET strapi.documents().findMany() — $eq

Attribute equals input value.

**JavaScript:**
```
const entries = await strapi.documents('api::article.article').findMany({
  filters: {
    title: {
      $eq: 'Hello World',
    },
  },
});
```

**Shorthand:**
```
// $eq can be omitted:
const entries = await strapi.documents('api::article.article').findMany({
  filters: {
    title: 'Hello World',
  },
});
```

#### GET strapi.documents().findMany() — $eqi

Attribute equals input value (case-insensitive).

**JavaScript:**
```
const entries = await strapi.documents('api::article.article').findMany({
  filters: {
    title: {
      $eqi: 'HELLO World',
    },
  },
});
```

#### GET strapi.documents().findMany() — $ne

Attribute does not equal input value.

**JavaScript:**
```
const entries = await strapi.documents('api::article.article').findMany({
  filters: {
    title: {
      $ne: 'ABCD',
    },
  },
});
```

#### GET strapi.documents().findMany() — $nei

Attribute does not equal input value (case-insensitive).

**JavaScript:**
```
const entries = await strapi.documents('api::article.article').findMany({
  filters: {
    title: {
      $nei: 'abcd',
    },
  },
});
```

#### GET strapi.documents().findMany() — $in

Attribute is contained in the input list.

**JavaScript:**
```
const entries = await strapi.documents('api::article.article').findMany({
  filters: {
    title: {
      $in: ['Hello', 'Hola', 'Bonjour'],
    },
  },
});
```

**Shorthand:**
```
// $in can be omitted when passing an array of values:
const entries = await strapi.documents('api::article.article').findMany({
  filters: {
    title: ['Hello', 'Hola', 'Bonjour'],
  },
});
```

#### GET strapi.documents().findMany() — $notIn

Attribute is not contained in the input list.

**JavaScript:**
```
const entries = await strapi.documents('api::article.article').findMany({
  filters: {
    title: {
      $notIn: ['Hello', 'Hola', 'Bonjour'],
    },
  },
});
```

#### GET strapi.documents().findMany() — $lt

Attribute is less than the input value.

**JavaScript:**
```
const entries = await strapi.documents('api::article.article').findMany({
  filters: {
    rating: {
      $lt: 10,
    },
  },
});
```

#### GET strapi.documents().findMany() — $lte

Attribute is less than or equal to the input value.

**JavaScript:**
```
const entries = await strapi.documents('api::article.article').findMany({
  filters: {
    rating: {
      $lte: 10,
    },
  },
});
```

#### GET strapi.documents().findMany() — $gt

Attribute is greater than the input value.

**JavaScript:**
```
const entries = await strapi.documents('api::article.article').findMany({
  filters: {
    rating: {
      $gt: 5,
    },
  },
});
```

#### GET strapi.documents().findMany() — $gte

Attribute is greater than or equal to the input value.

**JavaScript:**
```
const entries = await strapi.documents('api::article.article').findMany({
  filters: {
    rating: {
      $gte: 5,
    },
  },
});
```

#### GET strapi.documents().findMany() — $between

**JavaScript:**
```
const entries = await strapi.documents('api::article.article').findMany({
  filters: {
    rating: {
      $between: [1, 20],
    },
  },
});
```

#### GET strapi.documents().findMany() — $contains

Attribute contains the input value (case-sensitive).

**JavaScript:**
```
const entries = await strapi.documents('api::article.article').findMany({
  filters: {
    title: {
      $contains: 'Hello',
    },
  },
});
```

#### GET strapi.documents().findMany() — $notContains

Attribute does not contain the input value (case-sensitive).

**JavaScript:**
```
const entries = await strapi.documents('api::article.article').findMany({
  filters: {
    title: {
      $notContains: 'Hello',
    },
  },
});
```

#### GET strapi.documents().findMany() — $containsi

**JavaScript:**
```
const entries = await strapi.documents('api::article.article').findMany({
  filters: {
    title: {
      $containsi: 'hello',
    },
  },
});
```

#### GET strapi.documents().findMany() — $notContainsi

**JavaScript:**
```
const entries = await strapi.documents('api::article.article').findMany({
  filters: {
    title: {
      $notContainsi: 'hello',
    },
  },
});
```

#### GET strapi.documents().findMany() — $startsWith

Attribute starts with input value (case-sensitive).

**JavaScript:**
```
const entries = await strapi.documents('api::article.article').findMany({
  filters: {
    title: {
      $startsWith: 'ABCD',
    },
  },
});
```

#### GET strapi.documents().findMany() — $startsWithi

Attribute starts with input value (case-insensitive).

**JavaScript:**
```
const entries = await strapi.documents('api::article.article').findMany({
  filters: {
    title: {
      $startsWithi: 'ABCD', // will return the same as filtering with 'abcd'
    },
  },
});
```

#### GET strapi.documents().findMany() — $endsWith

Attribute ends with input value (case-sensitive).

**JavaScript:**
```
const entries = await strapi.documents('api::article.article').findMany({
  filters: {
    title: {
      $endsWith: 'ABCD',
    },
  },
});
```

#### GET strapi.documents().findMany() — $endsWithi

Attribute ends with input value (case-insensitive).

**JavaScript:**
```
const entries = await strapi.documents('api::article.article').findMany({
  filters: {
    title: {
      $endsWith: 'ABCD', // will return the same as filtering with 'abcd'
    },
  },
});
```

#### GET strapi.documents().findMany() — $null

**JavaScript:**
```
const entries = await strapi.documents('api::article.article').findMany({
  filters: {
    title: {
      $null: true,
    },
  },
});
```

#### GET strapi.documents().findMany() — $notNull

**JavaScript:**
```
const entries = await strapi.documents('api::article.article').findMany({
  filters: {
    title: {
      $notNull: true,
    },
  },
});
```

## Logical operators

#### GET strapi.documents().findMany() — $and

**JavaScript:**
```
const entries = await strapi.documents('api::article.article').findMany({
  filters: {
    $and: [
      {
        title: 'Hello World',
      },
      {
        createdAt: { $gt: '2021-11-17T14:28:25.843Z' },
      },
    ],
  },
});
```

**Implicit $and:**
```
// $and will be used implicitly when passing an object with nested conditions:
const entries = await strapi.documents('api::article.article').findMany({
  filters: {
    title: 'Hello World',
    createdAt: { $gt: '2021-11-17T14:28:25.843Z' },
  },
});
```

#### GET strapi.documents().findMany() — $or

**JavaScript:**
```
const entries = await strapi.documents('api::article.article').findMany({
  filters: {
    $or: [
      {
        title: 'Hello World',
      },
      {
        createdAt: { $gt: '2021-11-17T14:28:25.843Z' },
      },
    ],
  },
});
```

#### GET strapi.documents().findMany() — $not

Negates the nested conditions.

**JavaScript:**
```
const entries = await strapi.documents('api::article.article').findMany({
  filters: {
    $not: {
      title: 'Hello World',
    },
  },
});
```

:::note
`$not` can be used as:

- a logical operator (e.g. in `filters: { $not: { // conditions... }}`)
- [an attribute operator](#not) (e.g. in `filters: { attribute-name: $not: { ... } }`).
:::

:::tip
`$and`, `$or` and `$not` operators are nestable inside of another `$and`, `$or` or `$not` operator.
:::
