> For the complete MongoDB documentation index, see www.mongodb.com/docs/llms.txt

# $text (query predicate operator)

**Note:**

MongoDB offers an improved full-text search solution, [MongoDB Search](https://www.mongodb.com/docs/atlas/atlas-search/), and semantic search solution, [MongoDB Vector Search](https://www.mongodb.com/docs/atlas/atlas-vector-search/vector-search-overview/). We recommend using the [`$search`](https://www.mongodb.com/docs/search/query/aggregation-stages/search.md#mongodb-pipeline-pipe.-search), [`$searchMeta`](https://www.mongodb.com/docs/search/query/aggregation-stages/searchMeta.md#mongodb-pipeline-pipe.-searchMeta), or [`$vectorSearch`](https://www.mongodb.com/docs/manual/reference/operator/aggregation/vectorsearch.md#mongodb-expression-exp.-vectorSearch) stages, instead of the `$text` operator.

This page describes the `$text` operator for self-managed deployments.

## Definition

`$text` performs a text query on fields indexed with a [text index.](https://www.mongodb.com/docs/manual/core/indexes/index-types/index-text.md#std-label-index-type-text)

## Compatibility

You can use `$text` for deployments hosted in the following environments:

- [MongoDB Atlas](https://www.mongodb.com/docs/atlas): The fully managed service for MongoDB deployments in the cloud

* [MongoDB Enterprise](https://www.mongodb.com/docs/manual/administration/install-enterprise.md#std-label-install-mdb-enterprise): The subscription-based, self-managed version of MongoDB

* [MongoDB Community](https://www.mongodb.com/docs/manual/administration/install-community.md#std-label-install-mdb-community-edition): The source-available, free-to-use, and self-managed version of MongoDB

## Syntax

A `$text` expression has the following syntax:

```javascript
{
  $text: {
    $search: <string>,
    $language: <string>,
    $caseSensitive: <boolean>,
    $diacriticSensitive: <boolean>
  }
}
```

The `$text` operator accepts these fields:

| Field | Type | Description |
| --- | --- | --- |
| `$search` | string | A string of terms that MongoDB parses and uses to query the text index. MongoDB performs a logical `OR` query on the terms unless you specify an [exact string](https://www.mongodb.com/docs/manual/reference/operator/query/text.md#std-label-text-operator-exact-string). See [Behavior](https://www.mongodb.com/docs/manual/reference/operator/query/text.md#std-label-text-query-operator-behavior) for details. |
| `$language` | string | Optional. The language that determines the stop words, stemmer, and tokenizer rules. Defaults to the index language. For supported languages, see [$text Query Languages on Self-Managed Deployments.](https://www.mongodb.com/docs/manual/reference/text-search-languages.md#std-label-text-search-languages) If you specify a `default_language` value of `none`, the text index parses through each word in the field, including stop words, and ignores suffix stemming. |
| `$caseSensitive` | boolean | Optional. Enables case sensitivity. Defaults to `false`. See [Case Insensitivity.](https://www.mongodb.com/docs/manual/reference/operator/query/text.md#std-label-text-operator-case-sensitivity) |
| `$diacriticSensitive` | boolean | Optional. Enables diacritic sensitivity for [version 3 text indexes](https://www.mongodb.com/docs/manual/core/indexes/index-types/index-text.md#std-label-index-type-text). Defaults to `false`. Earlier text index versions are always diacritic sensitive. See [Diacritic Insensitivity.](https://www.mongodb.com/docs/manual/reference/operator/query/text.md#std-label-text-operator-diacritic-sensitivity) |

By default, `$text` does not sort results by score. See [Text Score](https://www.mongodb.com/docs/manual/reference/operator/query/text.md#std-label-text-operator-text-score) for details on score sorting.

## Behavior

### Restrictions

- A query can specify only one `$text` expression.

- `$text` cannot appear in [`$nor`](https://www.mongodb.com/docs/manual/reference/operator/query/nor.md#mongodb-query-op.-nor) expressions.

- `$text` cannot appear in [`$elemMatch`](https://www.mongodb.com/docs/manual/reference/operator/query/elemmatch.md#mongodb-query-op.-elemMatch) query or projection expressions.

- All [`$or`](https://www.mongodb.com/docs/manual/reference/operator/query/or.md#mongodb-query-op.-or) clauses must be indexed to use `$text`.

- If a query includes a `$text` expression, you cannot use [`hint()`](https://www.mongodb.com/docs/manual/reference/method/cursor.hint.md#mongodb-method-cursor.hint) to specify which index to use for the query.

- Queries with `$text` cannot use [`$natural`](https://www.mongodb.com/docs/manual/reference/method/cursor.hint.md#mongodb-operator-metaOp.-natural) sort.

- You cannot combine the `$text` expression, which requires a special [text index](https://www.mongodb.com/docs/manual/core/indexes/index-types/index-text/create-text-index.md#std-label-create-text-index), with a query operator that requires a different type of special index. For example you cannot combine `$text` expression with the [`$near`](https://www.mongodb.com/docs/manual/reference/operator/query/near.md#mongodb-query-op.-near) operator.

- [Views](https://www.mongodb.com/docs/manual/core/views.md#std-label-views-landing-page) do not support `$text`.

- [Stable API](https://www.mongodb.com/docs/manual/reference/stable-api.md#std-label-stable-api) V1 does not support `$text` for index creation.

If using the `$text` operator in aggregation, the following restrictions also apply.

- The [`$match`](https://www.mongodb.com/docs/manual/reference/operator/aggregation/match.md#mongodb-pipeline-pipe.-match) stage that includes a `$text` must be the **first** stage in the pipeline.

- A `$text` operator can only occur once in the stage.

- The `$text` operator expression cannot appear in [`$or`](https://www.mongodb.com/docs/manual/reference/operator/aggregation/or.md#mongodb-expression-exp.-or) or [`$not`](https://www.mongodb.com/docs/manual/reference/operator/aggregation/not.md#mongodb-expression-exp.-not) expressions.

- `$text`, by default, does not return the matching documents in order of matching scores. To sort by descending score, use the [`$meta`](https://www.mongodb.com/docs/manual/reference/operator/aggregation/meta.md#mongodb-expression-exp.-meta) aggregation expression in the [`$sort`](https://www.mongodb.com/docs/manual/reference/operator/aggregation/sort.md#mongodb-pipeline-pipe.-sort) stage.

### `$search` Field

In the `$search` field, specify the words that MongoDB uses to query the [text index.](https://www.mongodb.com/docs/manual/core/indexes/index-types/index-text.md#std-label-index-type-text)

**Note:**

The `$search` field differs from the MongoDB Atlas [$search aggregation stage](https://www.mongodb.com/docs/atlas/reference/atlas-search/query-syntax/). The `$search` stage provides full-text search and is available only on MongoDB Atlas.

#### Exact Strings

To match an exact multi-word string instead of individual terms, enclose the string in escaped double quotes (`\"`): as in:

```javascript
"\"ssl certificate\""
```

If the `$search` string of a `$text` operation includes a multi-word string and individual terms, `$text` only matches the documents that include the multi-word string.

For example, this `$search` string returns documents with the exact string `"ssl certificate"`:

```javascript
"\"ssl certificate\" authority key"
```

#### Negations

Prefix a word with a hyphen-minus (`-`) to negate it:

- Negated words exclude documents that contain the negated word from the result set.

- A string with only negated words matches no documents.

- Hyphenated words like `pre-market` are not negations. MongoDB treats the hyphen as a delimiter. To negate `market`, use `pre -market`.

MongoDB applies all negations to the operation with logical `AND`.

### Match Operation

#### Stop Words

MongoDB ignores language-specific stop words such as `the` and `and` in English.

#### Stemmed Words

With case and diacritic insensitivity, `$text` matches the complete *stemmed* word. If a document field contains `blueberry`, a `$search` term of `blue` does not match. However, `blueberry` or `blueberries` do match.

##### Case Sensitivity and Stemmed Words

With case sensitivity enabled (`$caseSensitive: true`), if the suffix stem contains uppercase letters, `$text` matches the exact word.

##### Diacritic Sensitivity and Stemmed Words

With [diacritic sensitivity](https://www.mongodb.com/docs/manual/reference/operator/query/text.md#std-label-text-operator-diacritic-sensitivity) enabled (`$diacriticSensitive: true`), if the suffix stem contains diacritic marks, `$text` matches the exact word.

### Case Insensitivity

`$text` defaults to the case insensitivity of the [text](https://www.mongodb.com/docs/manual/core/indexes/index-types/index-text.md#std-label-index-type-text) index:

- The version 3 [text index](https://www.mongodb.com/docs/manual/core/indexes/index-types/index-text/text-index-properties.md#std-label-text-index-case-insensitivity) is case insensitive for Latin characters with or without diacritics and non-Latin alphabets like Cyrillic.

- Earlier versions are case insensitive for Latin characters without diacritics (`[A-z]`).

#### Enabling Case Sensitivity

Specify `$caseSensitive: true` to enable case sensitivity when the text index is case insensitive.

#### Case Sensitivity Process

When `$caseSensitive: true` and the text index is case insensitive, `$text`:

- Queries the text index for case-insensitive and diacritic-insensitive matches.

- Filters results to return only documents matching the specified case.

When `$caseSensitive: true` and the suffix stem contains uppercase letters, `$text` matches the exact word.

Enabling `$caseSensitive: true` may reduce performance.

### Diacritic Insensitivity

`$text` defaults to the diacritic insensitivity of the [text](https://www.mongodb.com/docs/manual/core/indexes/index-types/index-text.md#std-label-index-type-text) index:

- Version 3 [text index](https://www.mongodb.com/docs/manual/core/indexes/index-types/index-text/text-index-properties.md#std-label-text-index-diacritic-insensitivity) is diacritic insensitive. The index does not distinguish between characters with diacritic marks and their non-marked counterparts (`é`, `ê`, `e`).

- Earlier versions are diacritic sensitive.

#### Enabling Diacritic Sensitivity

Specify `$diacriticSensitive: true` to enable diacritic sensitivity with version 3 text indexes.

Earlier text index versions are always diacritic sensitive, so `$diacriticSensitive` has no effect.

#### Diacritic Sensitivity Process

With version 3 text indexes and `$diacriticSensitive: true`, `$text`:

- Queries the diacritic-insensitive text index.

- Filters results to return only documents matching the diacritic marks in the specified terms.

Enabling `$diacriticSensitive: true` may reduce performance.

With earlier text index versions, `$diacriticSensitive: true` queries the already diacritic-sensitive text index.

When `$diacriticSensitive: true` and the suffix stem contains diacritic marks, `$text` matches the exact word.

**See also:**

[Stemmed Words](https://www.mongodb.com/docs/manual/reference/operator/query/text.md#std-label-match-operation-stemmed-words)

### Text Score

The `$text` operator assigns a score to each result document. The score represents the relevance of a document to a given query. The score can be part of a [`sort()`](https://www.mongodb.com/docs/manual/reference/method/cursor.sort.md#mongodb-method-cursor.sort) method specification as well as part of the projection expression. The `{ $meta: "textScore" }` expression provides information on the processing of the `$text` operation. See [`$meta`](https://www.mongodb.com/docs/manual/reference/operator/aggregation/meta.md#mongodb-expression-exp.-meta) projection operator for details on accessing the score for projection or sort.

### Memory Limits

**Changed in version 8.3**

Starting in MongoDB 8.3, the query engine limits the `TextOr` stage memory usage to 100 megabytes. The `TextOr` stage processes [`$text`](https://www.mongodb.com/docs/manual/reference/operator/query/text.md#mongodb-query-op.-text) queries that read text score metadata. For example, `TextOr` processes queries that sort results by text score. If the `TextOr` stage exceeds this limit:

- If `allowDiskUse` is `true`, the stage spills intermediate results to disk.

- If `allowDiskUse` is `false`, the query fails with an exceeded memory limit error.

In earlier versions, the `TextOr` stage had no memory limit and consumed RAM without restrictions, risking out-of-memory (OOM) errors.

## Examples

The examples on this page use data from the [sample\_mflix dataset](https://www.mongodb.com/docs/manual/sample-data/sample-mflix.md#std-label-sample-mflix). For details on how to load this dataset into your self-managed MongoDB deployment, see [Load the Sample Dataset](https://www.mongodb.com/docs/manual/sample-data/load-sample-data-local.md#std-label-sample-dataset-local). If you made any modifications to the sample databases, you may need to drop and recreate the databases to run the examples on this page.

The examples assume a [version 3 text](https://www.mongodb.com/docs/manual/core/indexes/index-types/index-text.md#std-label-index-type-text) index on the `title` and `fullplot` fields:

```javascript
db.movies.createIndex( { title: "text", fullplot: "text" } )

```

### Search for a Single Word

This example specifies `baseball` in the `$search` string. The query returns documents containing the stemmed version of `baseball` in the indexed `title` or `fullplot` fields:

```javascript
db.movies.find(
   { $text: { $search: "baseball" }, runtime: { $gt: 1000 } },
   { _id: 0, title: 1, year: 1, runtime: 1 }
)

```

**Output:**

```javascript
[ { title: 'Baseball', year: 1994, runtime: 1140 } ]

```

### Match Any Search Term

A space-delimited `$search` string performs a logical `OR` on each term. MongoDB returns documents containing any of the terms.

This example specifies two space-delimited terms. The query returns documents containing the stemmed versions of `baseball` **or** `colorado` in the indexed `title` or `fullplot` fields:

```javascript
db.movies.find(
   { $text: { $search: "baseball colorado" },
     runtime: { $gt: 1000 } },
   { _id: 0, title: 1, year: 1, runtime: 1, fullplot: 1 }
)

```

**Output:**

```javascript
[
  {
    runtime: 1140,
    title: 'Baseball',
    fullplot: 'Ken Burns relates the history of baseball in a fashion similar to that of his Civil War mini series. Old-time photos and illustrations depict the games early years, while newsreels and video clips highlight more recent developments. Players and participants speak in their own words, and sports writers and broadcasters offer commentary on the sport and events they witnessed.',
    year: 1994
  },
  {
    runtime: 1256,
    title: 'Centennial',
    fullplot: 'This is the story of the evolution of the town Centennial, Colorado. It follows the paths of dozens of people who come to the area for many reasons: money, freedom, or crime. It also shows the bigoted treatment of the Native Indians by the advancing US colonists. It is topped off with a murder mystery that takes 100 years to solve.',
    year: 1978
  }
]

```

### Search for an Exact String

Escape the quotes to match an exact multi-word string.

This example matches the exact phrase `ken burns`:

```javascript
db.movies.find(
   { $text: { $search: "\"ken burns\"" },
     runtime: { $gt: 1000 } },
   { _id: 0, title: 1, year: 1, runtime: 1, fullplot: 1 }
)

```

**Output:**

```javascript
[
  {
    runtime: 1140,
    title: 'Baseball',
    fullplot: 'Ken Burns relates the history of baseball in a fashion similar to that of his Civil War mini series. Old-time photos and illustrations depict the games early years, while newsreels and video clips highlight more recent developments. Players and participants speak in their own words, and sports writers and broadcasters offer commentary on the sport and events they witnessed.',
    year: 1994
  }
]

```

This example performs a logical OR of two exact strings:

```javascript
db.movies.find(
   { $text: { $search: "\'ken burns\' \'centennial\'" },
     runtime: { $gt: 1000 } },
   { _id: 0, title: 1, year: 1, runtime: 1, fullplot: 1 }
)

```

**Output:**

```javascript
[
  {
    runtime: 1140,
    title: 'Baseball',
    fullplot: 'Ken Burns relates the history of baseball in a fashion similar to that of his Civil War mini series. Old-time photos and illustrations depict the games early years, while newsreels and video clips highlight more recent developments. Players and participants speak in their own words, and sports writers and broadcasters offer commentary on the sport and events they witnessed.',
    year: 1994
  },
  {
    runtime: 1256,
    title: 'Centennial',
    fullplot: 'This is the story of the evolution of the town Centennial, Colorado. It follows the paths of dozens of people who come to the area for many reasons: money, freedom, or crime. It also shows the bigoted treatment of the Native Indians by the advancing US colonists. It is topped off with a murder mystery that takes 100 years to solve.',
    year: 1978
  }
]

```

### Exclude Documents That Contain a Term

Prefix a term with `-` to exclude documents containing that term.

This example matches documents containing `baseball` or `colorado` but not `sport` (stemmed versions):

```javascript
db.movies.find(
   { $text: { $search: "baseball colorado -sport" },
     runtime: { $gt: 1000 } },
   { _id: 0, title: 1, year: 1, runtime: 1 }
)

```

**Output:**

```javascript
[ { title: 'Centennial', year: 1978, runtime: 1256 } ]

```

### Relevance Score Examples

#### Return the Relevance Score

This example queries for `baseball` and uses [`$meta`](https://www.mongodb.com/docs/manual/reference/operator/aggregation/meta.md#mongodb-expression-exp.-meta) to append the relevance score to each matching document. The returned document includes a `score` field with the relevance score:

```javascript
db.movies.find(
   { $text: { $search: "baseball" }, runtime: { $gt: 1000 } },
   { _id: 0, title: 1, year: 1,
     score: { $meta: "textScore" } }
)

```

**Output:**

```javascript
[
  {
    title: 'Baseball',
    year: 1994,
    score: ...
  }
]

```

#### Return Top 2 Matching Documents

Use [`limit()`](https://www.mongodb.com/docs/manual/reference/method/cursor.limit.md#mongodb-method-cursor.limit) with [`sort()`](https://www.mongodb.com/docs/manual/reference/method/cursor.sort.md#mongodb-method-cursor.sort) to return the top matching documents.

This example queries for `baseball` **or** `colorado`, sorts by descending score, and limits results to the top two documents:

```javascript
db.movies.find(
   { $text: { $search: "baseball colorado" },
     runtime: { $gt: 1000 } },
   { _id: 0, title: 1, year: 1,
     score: { $meta: "textScore" } }
).sort( { score: { $meta: "textScore" } } ).limit(2)

```

**Output:**

```javascript
[
  { title: 'Baseball', year: 1994, score: ... },
  { title: 'Centennial', year: 1978, score: ... }
]

```

#### Combine $text with Other Query and Sort Operations

This example matches documents where `runtime` is greater than `1000` and the indexed fields contain `baseball` or `colorado`. It sorts by ascending `year`, then descending relevance score:

```javascript
db.movies.find(
   { runtime: { $gt: 1000 },
     $text: { $search: "baseball colorado" } },
   { _id: 0, title: 1, year: 1,
     score: { $meta: "textScore" } }
).sort( { year: 1, score: { $meta: "textScore" } } )

```

**Output:**

```javascript
[
  { title: 'Centennial', year: 1978, score: ... },
  { title: 'Baseball', year: 1994, score: ... }
]

```

### Query a Different Language

The rest of the examples on this page use an `articles` collection with a [version 3 text](https://www.mongodb.com/docs/manual/core/indexes/index-types/index-text.md#std-label-index-type-text) index on `subject`:

```javascript
db.articles.createIndex( { subject: "text" } )

```

The collection contains the following documents:

```javascript
db.articles.insertMany( [
   { _id: 1, subject: "coffee", author: "xyz", views: 50 },
   { _id: 2, subject: "Coffee Shopping", author: "efg", views: 5 },
   { _id: 3, subject: "Baking a cake", author: "abc", views: 90  },
   { _id: 4, subject: "baking", author: "xyz", views: 100 },
   { _id: 5, subject: "Café Con Leche", author: "abc", views: 200 },
   { _id: 6, subject: "Сырники", author: "jkl", views: 80 },
   { _id: 7, subject: "coffee and cream", author: "efg", views: 10 },
   { _id: 8, subject: "Cafe con Leche", author: "xyz", views: 10 }
] )

```

Use `$language` to specify the language that determines stop words, stemmer, and tokenizer rules for the `$search` string.

If you specify a `default_language` value of `none`, the text index parses through each word in the field, including stop words, and ignores suffix stemming.

This example specifies `es` (Spanish) as the language:

```javascript
db.articles.find(
   { $text: { $search: "leche", $language: "es" } }
)

```

**Output:**

```javascript
[
  { _id: 5, subject: 'Café Con Leche', author: 'abc', views: 200 },
  { _id: 8, subject: 'Cafe con Leche', author: 'xyz', views: 10 }
]

```

You can also specify languages by name, such as `spanish`. See [$text Query Languages on Self-Managed Deployments](https://www.mongodb.com/docs/manual/reference/text-search-languages.md#std-label-text-search-languages) for supported languages.

### Sort by Relevance Score

You can specify the [`{ $meta: "textScore" }`](https://www.mongodb.com/docs/manual/reference/operator/aggregation/meta.md#mongodb-expression-exp.-meta) expression in the [`sort()`](https://www.mongodb.com/docs/manual/reference/method/cursor.sort.md#mongodb-method-cursor.sort) without also specifying the expression in the projection. For example:

```javascript
db.articles.find(
   { $text: { $search: "cake" } }
).sort( { score: { $meta: "textScore" } } )
```

As a result, you can sort the resulting documents by their relevance without projecting the `textScore`.

If you include the [`{ $meta: "textScore" }`](https://www.mongodb.com/docs/manual/reference/operator/aggregation/meta.md#mongodb-expression-exp.-meta) expression in both the [projection](https://www.mongodb.com/docs/manual/reference/method/db.collection.find.md#std-label-find-projection) and [`sort()`](https://www.mongodb.com/docs/manual/reference/method/cursor.sort.md#mongodb-method-cursor.sort), the projection and sort documents can have different field names for the expression. For example, in the following operation, the projection uses a field named `score` for the expression and the [`sort()`](https://www.mongodb.com/docs/manual/reference/method/cursor.sort.md#mongodb-method-cursor.sort) uses the field named `ignoredName`:

```javascript
db.articles.find(
   { $text: { $search: "cake" } },
   { score: { $meta: "textScore" } }
).sort( { ignoredName: { $meta: "textScore" } } )
```

### Case and Diacritic Insensitivity

`$text` defaults to the case and diacritic insensitivity of the text index. Version 3 text indexes are diacritic insensitive and case insensitive for Latin characters with diacritics and non-Latin alphabets like Cyrillic. See [text Index Case Insensitivity](https://www.mongodb.com/docs/manual/core/indexes/index-types/index-text/text-index-properties.md#std-label-text-index-case-insensitivity) and [text Index Diacritic Insensitivity.](https://www.mongodb.com/docs/manual/core/indexes/index-types/index-text/text-index-properties.md#std-label-text-index-diacritic-insensitivity)

This example performs a case and diacritic insensitive query. Using version 3 text indexes, the query matches documents containing the stemmed versions of the search terms:

```javascript
db.articles.find( { $text: { $search: "сы́рники CAFÉS" } } )

```

**Output:**

```javascript
[
  { _id: 6, subject: 'Сырники', author: 'jkl', views: 80 },
  { _id: 5, subject: 'Café Con Leche', author: 'abc', views: 200 },
  { _id: 8, subject: 'Cafe con Leche', author: 'xyz', views: 10 }
]

```

Earlier text index versions would not match any documents.

### Case Sensitivity

Enable case sensitivity with `$caseSensitive: true`. This may reduce performance.

#### Case-Sensitive Term Search

This example performs a case-sensitive query for `Coffee`:

```javascript
db.articles.find(
   { $text: { $search: "Coffee", $caseSensitive: true } }
)

```

**Output:**

```javascript
[ { _id: 2, subject: 'Coffee Shopping', author: 'efg', views: 5 } ]

```

#### Case-Sensitive Exact String Search

This example performs a case-sensitive query for an exact multi-word string:

```javascript
db.articles.find( {
   $text: { $search: "\"Café Con Leche\"", $caseSensitive: true }
} )

```

**Output:**

```javascript
[ { _id: 5, subject: 'Café Con Leche', author: 'abc', views: 200 } ]

```

#### Case-Sensitive Negated Term Search

You can use case sensitivity with negated terms (terms prefixed with `-`).

This example performs a case-sensitive query for documents containing `Coffee` but not `shop` (stemmed versions):

```javascript
db.articles.find(
   { $text: { $search: "Coffee -shop", $caseSensitive: true } }
)

```

**Output:**

```javascript
[ { _id: 2, subject: 'Coffee Shopping', author: 'efg', views: 5 } ]

```

### Diacritic Sensitivity

Enable diacritic sensitivity with version 3 [text](https://www.mongodb.com/docs/manual/core/indexes/index-types/index-text.md#std-label-index-type-text) indexes using `$diacriticSensitive: true`. This may reduce performance.

#### Diacritic-Sensitive Term Search

This example performs a diacritic-sensitive query for `CAFÉ` (stemmed version):

```javascript
db.articles.find(
   { $text: { $search: "CAFÉ", $diacriticSensitive: true } }
)

```

**Output:**

```javascript
[ { _id: 5, subject: 'Café Con Leche', author: 'abc', views: 200 } ]

```

#### Diacritic-Sensitive Negated Term Search

You can use diacritic sensitivity with negated terms (terms prefixed with `-`).

This example performs a diacritic-sensitive query for documents containing `leches` but not `cafés` (stemmed versions):

```javascript
db.articles.find(
   { $text: { $search: "leches -cafés", $diacriticSensitive: true } }
)

```

**Output:**

```javascript
[ { _id: 8, subject: 'Cafe con Leche', author: 'xyz', views: 10 } ]

```

**See also:**

- [Text Indexes on Self-Managed Deployments](https://www.mongodb.com/docs/manual/core/indexes/index-types/index-text.md#std-label-index-type-text)

- [Stemmed Words](https://www.mongodb.com/docs/manual/reference/operator/query/text.md#std-label-match-operation-stemmed-words)

- [Exact Strings](https://www.mongodb.com/docs/manual/reference/operator/query/text.md#std-label-text-operator-exact-string)

- [Negations](https://www.mongodb.com/docs/manual/reference/operator/query/text.md#std-label-text-operator-term-negation)

- [Case Insensitivity](https://www.mongodb.com/docs/manual/reference/operator/query/text.md#std-label-text-operator-case-sensitivity)

- [Case Sensitivity and Stemmed Words](https://www.mongodb.com/docs/manual/reference/operator/query/text.md#std-label-case-sensitivity-and-stemming)

- [Diacritic Insensitivity](https://www.mongodb.com/docs/manual/reference/operator/query/text.md#std-label-text-operator-diacritic-sensitivity)

- [Diacritic Sensitivity and Stemmed Words](https://www.mongodb.com/docs/manual/reference/operator/query/text.md#std-label-diacritic-sensitivity-and-stemming)

- [`$meta`](https://www.mongodb.com/docs/manual/reference/operator/aggregation/meta.md#mongodb-expression-exp.-meta)

- [$text in the Aggregation Pipeline](https://www.mongodb.com/docs/manual/tutorial/text-search-in-aggregation.md#std-label-text-agg)
