Create a Multi-Language Text Index in MongoDB

When you create a text index in MongoDB, the index uses a default language of english.

The default language determines the rules to parse word roots (i.e. stemming) and ignore stop words.

However, you can change the default language if required.

You can also specify a language at the document level, and even at the subdocument level. The default language will only be used if a language hasn’t been specified at the document or subdocument level.

This article presents examples of specifying a language for a text index.

Continue reading

Create a Text Index with Different Field Weights in MongoDB

When you create a text index in MongoDB, you have the option of applying different weights to each indexed field.

These weights denote the relative significance of the indexed fields to each other. A field with a higher weight will have more impact in the search results than a field with a lower weight.

This provides you with a certain amount of control over how the search results are calculated.

The default weight is 1, so if you don’t specify a weight for field, it will be assigned a weight of 1.

Continue reading