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

Multi Analyzer

You can use the multi object in your index definition to specify alternate analyzers with which to also index the field. When you index a field with alternate analyzers in addition to the default analyzer, you can search the collection with either the default or the alternate analyzer. This page demonstrates how to specify alternate analyzers in your index definition using multi.

The multi path option is available only to fields of type string.

MongoDB Search does not support nesting multiple layers of multi objects.

The following examples demonstrate index definitions on the fields in the sample_mflix.movies collection. If you load the collection on your cluster, you can create the example indexes using the Visual Editor or the JSON Editor in the Atlas UI or using mongosh.

The following example index definition specifies an index on the title field using the standard analyzer. The index definition also specifies lucene.french analyzer as an alternate analyzer for the title field, with the name frenchAnalyzer.

The following query uses the alternate analyzer, named frenchAnalyzer, to search for the string liberte.

The document in the results is a match because the frenchAnalyzer reduced both the indexed string è Nous la Libertè and query term liberte to the base word libert. MongoDB Search won't return this document for a search with the standard analyzer because it doesn't remove diacritics. Each analyzer generates the following tokens (searchable terms) for the index and query:

Analyzer
Index Tokens
Query Tokens

Standard Analyzer

è, nous, la, libertè

libertè

French Analyzer

è, libert

libert

The following example index definition specifies an index on the title and plot fields using the standard analyzer. The index definition also specifies lucene.french as an alternate analyzer for the title and the plot fields.

The following query searches for matches for the string revolution in the title and the plot fields by using the alternate analyzer named frenchAnalyzer.

The documents in the results contain the query term in both the title and the plot fields. Each analyzer creates the following tokens (searchable terms) for the title field for each document in the results:

Year

Analyzer

Index Tokens

Query Tokens

2012

Standard Analyzer
French Analyzer

revolution
revolution

revolution
revolution

1985

Standard Analyzer
French Analyzer

revolution
revolution

revolution
revolution

2014

Standard Analyzer
French Analyzer

angels, of, revolution
angels, of, revolution

revolution
revolution

1970

Standard Analyzer
French Analyzer

start, the, revolution, without, me
start, the, revolution, without

revolution
revolution

1989

Standard Analyzer
French Analyzer

la, rèvolution, franèaise
revolution, franeais

revolution
revolution

For the fifth document in the results, the frenchAnalyzer removed the diacritics in the title field to match the document to the query term.