Enum SearchTokenization
- Namespace
- MongoDB.EntityFrameworkCore.Metadata.Search
- Assembly
- MongoDB.EntityFrameworkCore.dll
Tokenization strategies for MongoDB search string fields.
public enum SearchTokenization
Fields
EdgeGram = 0Edge-gram tokenization from the left edge (prefix grams). Produces tokens that start at the beginning of the term and extend up to the configured
maxGram. Typically used for autocomplete and prefix matching (e.g., "mon", "mong", "mongo").RightEdgeGram = 1Edge-gram tokenization from the right edge (suffix grams). Produces tokens that end at the end of the term and extend backward, enabling suffix matching (e.g., "bson", "son", "on"). Useful when you need to match endings such as file extensions or suffix-based queries.
NGram = 2N-gram tokenization using a sliding window across the entire term (infix grams). Produces overlapping tokens of length between
minGramandmaxGram, enabling substring matching anywhere within a word. Useful for partial/infix search, with increased index size.
Remarks
Tokenization controls how text is split into smaller units (tokens) for indexing and matching.
Use edge-gram tokenization for efficient prefix/suffix autocomplete, and n-gram tokenization for
infix matching within words. Actual token lengths are controlled by tokenizer options such as
minGram and maxGram in the analyzer configuration.
See MongoDB search tokenizer docs for details:
https://www.mongodb.com/docs/atlas/atlas-search/analyzers/tokenizers/edge-gram/,
https://www.mongodb.com/docs/atlas/atlas-search/analyzers/tokenizers/n-gram/.