Text Indexes
MongoDB provides text indexes to supporttext search queries on string content. text
indexes can include anyfield whose value is a string or an array of string elements.
To perform text search queries, you must have atext
index on your collection. A collection can only have onetext search index, but that index can cover multiple fields.
For example you can run the following in a mongo
shell toallow 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 textindexes, including behavior, tokenization, and properties.