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

# Operators and Collectors

## Operators

The following table describes the operators that can be used inside of the [`$search`](https://www.mongodb.com/docs/search/query/aggregation-stages/search.md#mongodb-pipeline-pipe.-search) and [`$searchMeta`](https://www.mongodb.com/docs/search/query/aggregation-stages/searchmeta.md#mongodb-pipeline-pipe.-searchMeta) aggregation pipeline stages to customize the output of your MongoDB Search query. Each operator supports queries over particular MongoDB Search [field types.](https://www.mongodb.com/docs/search/indexes/define-field-mappings.md#std-label-bson-data-types)

| Operator | Description | Supported MongoDB Search Types |
| --- | --- | --- |
| [autocomplete](https://www.mongodb.com/docs/search/query/operators-collectors/autocomplete.md#std-label-autocomplete-ref) | Performs a search-as-you-type query from an incomplete input string. | [autocomplete](https://www.mongodb.com/docs/search/indexes/field-types/autocomplete-type.md#std-label-bson-data-types-autocomplete) |
| [compound](https://www.mongodb.com/docs/search/query/operators-collectors/compound.md#std-label-compound-ref) | Combines other operators into a single query. | Field types supported by the operators used inside the `compound` operator. |
| [embeddedDocument](https://www.mongodb.com/docs/search/query/operators-collectors/embedded-document.md#std-label-embedded-document-ref) | Queries fields in embedded documents, which are documents that are elements of an array. | [embeddedDocuments](https://www.mongodb.com/docs/search/indexes/field-types/embedded-documents-type.md#std-label-bson-data-types-embedded-documents) and field types supported by the operators used inside the `embeddedDocument` operator. |
| [equals](https://www.mongodb.com/docs/search/query/operators-collectors/equals.md#std-label-equals-ref) | Checks whether the field contains the specified value, including null value. | [boolean](https://www.mongodb.com/docs/search/indexes/field-types/boolean-type.md#std-label-boolean-ref)[date](https://www.mongodb.com/docs/search/indexes/field-types/date-type.md#std-label-bson-data-types-date)[objectId](https://www.mongodb.com/docs/search/indexes/field-types/object-id-type.md#std-label-objectId-ref)[number](https://www.mongodb.com/docs/search/indexes/field-types/number-type.md#std-label-bson-data-types-number)[token](https://www.mongodb.com/docs/search/indexes/field-types/token-type.md#std-label-bson-data-types-token)[uuid](https://www.mongodb.com/docs/search/indexes/field-types/uuid-type.md#std-label-bson-data-types-uuid) |
| [exists](https://www.mongodb.com/docs/search/query/operators-collectors/exists.md#std-label-exists-ref) | Tests for the presence of a specified field, regardless of the field type. | Field type isn't used by the `exists` operator. |
| [geoShape](https://www.mongodb.com/docs/search/query/operators-collectors/geoshape.md#std-label-geoshape-ref) | Queries for values with specified geo shapes. | [geo](https://www.mongodb.com/docs/search/indexes/field-types/geo-type.md#std-label-bson-data-types-geo) |
| [geoWithin](https://www.mongodb.com/docs/search/query/operators-collectors/geowithin.md#std-label-geowithin-ref) | Queries for points within specified geographic shapes. | [geo](https://www.mongodb.com/docs/search/indexes/field-types/geo-type.md#std-label-bson-data-types-geo) |
| [hasAncestor](https://www.mongodb.com/docs/search/query/operators-collectors/hasancestor.md#std-label-has-ancestor-ref) | Queries intermediary ancestor-level fields using `returnScope`. | Field type supported by the operator used in the query. |
| [hasRoot](https://www.mongodb.com/docs/search/query/operators-collectors/hasroot.md#std-label-has-root-ref) | Queries root-level fields using `returnScope`. | Field type supported by the operator used in the query. |
| [in](https://www.mongodb.com/docs/search/query/operators-collectors/in.md#std-label-in-ref) | Queries both single value and array of values. | [boolean](https://www.mongodb.com/docs/search/indexes/field-types/boolean-type.md#std-label-boolean-ref)[date](https://www.mongodb.com/docs/search/indexes/field-types/date-type.md#std-label-bson-data-types-date)[objectId](https://www.mongodb.com/docs/search/indexes/field-types/object-id-type.md#std-label-objectId-ref)[number](https://www.mongodb.com/docs/search/indexes/field-types/number-type.md#std-label-bson-data-types-number)[token](https://www.mongodb.com/docs/search/indexes/field-types/token-type.md#std-label-bson-data-types-token)[uuid](https://www.mongodb.com/docs/search/indexes/field-types/uuid-type.md#std-label-bson-data-types-uuid) |
| [knnBeta](https://www.mongodb.com/docs/search/query/operators-collectors/knn-beta.md#std-label-knn-beta-ref) | (Deprecated) Performs semantic search using [Hierarchical Navigable Small Worlds](https://arxiv.org/abs/1603.09320) algorithm. | [knnVector](https://www.mongodb.com/docs/search/indexes/field-types/knn-vector.md#std-label-fts-data-types-knn-vector) |
| [moreLikeThis](https://www.mongodb.com/docs/search/query/operators-collectors/morelikethis.md#std-label-more-like-this-ref) | Queries for similar documents. | [string](https://www.mongodb.com/docs/search/indexes/field-types/string-type.md#std-label-bson-data-types-string) |
| [near](https://www.mongodb.com/docs/search/query/operators-collectors/near.md#std-label-near-ref) | Queries for values near a specified [number](https://www.mongodb.com/docs/search/indexes/field-types/number-type.md#std-label-bson-data-types-number), [date](https://www.mongodb.com/docs/search/indexes/field-types/date-type.md#std-label-bson-data-types-date), or [geo point.](https://www.mongodb.com/docs/search/indexes/field-types/geo-type.md#std-label-bson-data-types-geo) | [date](https://www.mongodb.com/docs/search/indexes/field-types/date-type.md#std-label-bson-data-types-date)[geo point](https://www.mongodb.com/docs/search/indexes/field-types/geo-type.md#std-label-bson-data-types-geo)[number](https://www.mongodb.com/docs/search/indexes/field-types/number-type.md#std-label-bson-data-types-number) |
| [phrase](https://www.mongodb.com/docs/search/query/operators-collectors/phrase.md#std-label-phrase-ref) | Searches documents for terms in an order similar to the query. | [string](https://www.mongodb.com/docs/search/indexes/field-types/string-type.md#std-label-bson-data-types-string) |
| [queryString](https://www.mongodb.com/docs/search/query/operators-collectors/querystring.md#std-label-querystring-ref) | Supports querying a combination of indexed fields and values. | [string](https://www.mongodb.com/docs/search/indexes/field-types/string-type.md#std-label-bson-data-types-string) |
| [range](https://www.mongodb.com/docs/search/query/operators-collectors/range.md#std-label-range-ref) | Queries for values within a specific numeric, date, string, and objectId range. | [date](https://www.mongodb.com/docs/search/indexes/field-types/date-type.md#std-label-bson-data-types-date)[number](https://www.mongodb.com/docs/search/indexes/field-types/number-type.md#std-label-bson-data-types-number)[objectId](https://www.mongodb.com/docs/search/indexes/field-types/object-id-type.md#std-label-objectId-ref)[token](https://www.mongodb.com/docs/search/indexes/field-types/token-type.md#std-label-bson-data-types-token) |
| [regex](https://www.mongodb.com/docs/search/query/operators-collectors/regex.md#std-label-regex-ref) | Interprets the `query` field as a regular expression. | [string](https://www.mongodb.com/docs/search/indexes/field-types/string-type.md#std-label-bson-data-types-string) |
| [span](https://www.mongodb.com/docs/search/query/operators-collectors/span.md#std-label-span-ref) | (Deprecated) Specifies relative positional requirements for query predicates within specified regions of a text field. | [string](https://www.mongodb.com/docs/search/indexes/field-types/string-type.md#std-label-bson-data-types-string) |
| [text](https://www.mongodb.com/docs/search/query/operators-collectors/text.md#std-label-text-ref) | Performs textual analyzed search. | [string](https://www.mongodb.com/docs/search/indexes/field-types/string-type.md#std-label-bson-data-types-string) |
| [vectorSearch](https://www.mongodb.com/docs/search/query/operators-collectors/vectorsearch.md#std-label-fts-vectorSearch-ref) | Performs semantic search using lexical pre-filters. | [vector](https://www.mongodb.com/docs/search/indexes/field-types/vector-type.md#std-label-bson-data-types-vector) |
| [wildcard](https://www.mongodb.com/docs/search/query/operators-collectors/wildcard.md#std-label-wildcard-ref) | Supports special characters in the query string that can match any character. | [string](https://www.mongodb.com/docs/search/indexes/field-types/string-type.md#std-label-bson-data-types-string) |

## Collectors

The following table describes the collectors that can be used inside of the [`$search`](https://www.mongodb.com/docs/search/query/aggregation-stages/search.md#mongodb-pipeline-pipe.-search) and [`$searchMeta`](https://www.mongodb.com/docs/search/query/aggregation-stages/searchmeta.md#mongodb-pipeline-pipe.-searchMeta) aggregation pipeline stages to return a document representing the [metadata results](https://www.mongodb.com/docs/search/query/aggregation-stages/searchmeta.md#std-label-fts-metadata-results) of your MongoDB Search query. This results document is typically an aggregation over the matching MongoDB Search query results. The table also shows the MongoDB Search [field types](https://www.mongodb.com/docs/search/indexes/define-field-mappings.md#std-label-bson-data-types) that the collector supports.

| Collector | Description | Supported Field Types |
| --- | --- | --- |
| [facet](https://www.mongodb.com/docs/search/query/operators-collectors/facet.md#std-label-fts-facet-ref) | Groups query results by values or ranges in specified, faceted fields and returns the count for each of those groups. | [date](https://www.mongodb.com/docs/search/indexes/field-types/date-type.md#std-label-bson-data-types-date)[number](https://www.mongodb.com/docs/search/indexes/field-types/number-type.md#std-label-bson-data-types-number)[token](https://www.mongodb.com/docs/search/indexes/field-types/token-type.md#std-label-bson-data-types-token) (string) |

## Next Steps

### Learn by Watching

You can also watch the following videos to learn more about MongoDB Search operators and collectors:

#### Video: Query Operators and Relevancy Controls for Precision Searches

##### Watch an overview of |fts| query operators and |fts| scores.

Watch this video for an overview of searching and tracking your queries with MongoDB Search. In this video, you can learn more about MongoDB Search [operators](https://www.mongodb.com/docs/search/query/operators-collectors/overview.md#std-label-fts-operators) and how MongoDB Search [scores](https://www.mongodb.com/docs/search/query/score/overview.md#std-label-scoring-ref) documents in the results.

*Duration: 15 Minutes*

#### Video: Elevate Your Search with Fuzzy, Geospatial and Highlighting Hacks

##### Watch a video tutorial about advanced search topics.

Follow along with this video to learn how to search fields in embedded documents using the [embeddedDocument](https://www.mongodb.com/docs/search/query/operators-collectors/embedded-document.md#std-label-embedded-document-ref) operator, how to perform fuzzy search using the [text](https://www.mongodb.com/docs/search/query/operators-collectors/text.md#std-label-text-ref) operator [fuzzy option](https://www.mongodb.com/docs/search/query/operators-collectors/text.md#std-label-text-ref-fields), how to build search-as-you-type function using the [autocomplete](https://www.mongodb.com/docs/search/query/operators-collectors/autocomplete.md#std-label-autocomplete-ref) operator, how to run geospatial queries using the [geoWithin](https://www.mongodb.com/docs/search/query/operators-collectors/geowithin.md#std-label-geowithin-ref) and [geoShape](https://www.mongodb.com/docs/search/query/operators-collectors/geoshape.md#std-label-geoshape-ref) operators, how to retrieve similar or alternate results using the [moreLikeThis](https://www.mongodb.com/docs/search/query/operators-collectors/morelikethis.md#std-label-more-like-this-ref) operator, and how to display search terms in their original context using [highlighting.](https://www.mongodb.com/docs/search/query/highlighting.md#std-label-highlight-ref)

*Duration: 12 Minutes*
