For AI agents: a documentation index is available at https://www.mongodb.com/docs/llms.txt — markdown versions of all pages are available by appending .md to any URL path.
Docs Menu

Simple Analyzer

The simple analyzer divides text into searchable terms (tokens) wherever it finds a non-letter character, such as whitespace, punctuation, or one or more digits. It converts all text to lowercase.

If you select Refine Your Index, the Atlas UI displays a section titled View text analysis of your selected index configuration within the Index Configurations section. If you expand this section, the Atlas UI displays the index and search tokens that the simple analyzer generates for each sample string. You can see the tokens that the simple analyzer creates for a built-in sample document and query string when you create or edit an index in the Atlas UI Visual Editor.

Important

MongoDB Search won't index string fields where analyzer tokens exceed 32766 bytes in size. If using the keyword analyzer, string fields which exceed 32766 bytes will not be indexed.

The following example index definition specifies an index on the title field in the sample_mflix.movies collection using the simple analyzer. To follow along with this example, load the sample data on your cluster and either use mongosh or navigate to the Create a Search Index page in the Atlas UI following the steps in the Create a MongoDB Search Index tutorial.

Then, using the movies collection as your data source, follow the example procedure to create an index from mongosh or the Atlas UI Visual Editor or JSON editor.


The following query searches for the term lion in the title field and limits the output to five results.

MongoDB Search returns these documents by doing the following for the text in the title field using the lucene.simple analyzer:

  • Convert text to lowercase.

  • Create separate tokens by dividing text wherever there is a non-letter character.

The following table shows the tokens that MongoDB Search creates for each document in the results using the Simple Analyzer. For comparison, the table also shows tokens from the Standard Analyzer and Whitespace Analyzer:

Title
Simple Analyzer Tokens
Standard Analyzer Tokens
Whitespace Analyzer Tokens

White Lion

white, lion

white, lion

White, Lion

The Lion King

the, lion, king

the, lion, king

The, Lion, King

The Lion King 1 1/2

the, lion, king

the, lion, king, 1, 1, 2

The, Lion, King, 1, 1/2

Lion's Den

lion, s, den

lion's, den

Lion's, Den

MongoDB Search returns document Lion's Den in the results because the simple analyzer creates a separate token for lion, which matches the query term lion. By contrast, if you index the field using the Standard Analyzer or Whitespace Analyzer, MongoDB Search wouldn't return Lion's Den. The Standard Analyzer would create the token lion's and the Whitespace Analyzer would create Lion's, but neither would create a token for lion.