Docs Menu
Docs Home
/
MongoDB Manual
/ / /

Perform a Text Search (Self-Managed Deployments)

To run text search queries on self-managed deployments, you must have a text index on your collection. MongoDB provides text indexes to support text search queries on string content. Text indexes can include any field whose value is a string or an array of string elements. A collection can only have one text search index, but that index can cover multiple fields.

To perform text search queries, you must have a text index on your collection. A collection can only have one text search index, but that index can cover multiple fields.

For example you can run the following in a mongo shell to allow text search over the name and description fields:

db.stores.createIndex( { name: "text", description: "text" } )

See the Text Indexes section for a full reference on text indexes, including behavior, tokenization, and properties.

Back

Text Search on Self-Managed Deployments