View a markdown version of this page

Text Indexes - Amazon DocumentDB
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).

Text Indexes

Text indexes are useful in searching for words or phrases in text fields within documents, allowing you to perform full-text search functionality. You can create single field text indexes or compound text indexes with more than one text field. However, you can only have one text index per collection. For more information, please see the Unlock the power of Amazon DocumentDB text search with real-world use cases.

Supported index properties

Option 3.6 4.0 5.0 8.0 Elastic Cluster
name No No Yes Yes No

Creating a text index

Use the createIndex() method to create a text index. The method syntax is: db.collection.createIndex(<keys>, <options>)

The keys parameter is a JSON document that specifies the field(s) and text index type:

{ "<field 1>": "text", "<field 2>": "text" }

The options parameter is a JSON document that specifies the name of the index:

{ "name": "<name>" }

See Index Properties for examples of creating text indexes.