MongoDb Indexing full text search MongoDb Indexing full text search mongoose mongoose

MongoDb Indexing full text search


Credit to @amenadiel for the original data here:

https://stackoverflow.com/a/24316510/7948962

From the MongoDB docs:

https://docs.mongodb.com/manual/core/index-text/

Index Entries

text index tokenizes and stems the terms in the indexed fields for the index entries. text index stores one index entry for each unique stemmed term in each indexed field for each document in the collection. The index uses simple language-specific suffix stemming.

This is to allow you to search partial "stem" terms in the index, and have the database return all related results. In your specific scenario, amaz is a bit of an odd token as it is a bit irregular compared to other words such as talking, which is tokenized to the word talk, or talked to talk. Similarly walking and walked to walk.

In your case, the word amazing in your text will be tokenized as amaz. If your column contained data such as amazed, it would receive the same amaz token as well. And those results would also be returned from a search of amaz.