An n-gram is a contiguous sequence of a chosen number of characters or words. A sliding window produces overlapping sequences from the original text. section 7.7.2
Use the window size and position to distinguish related forms:
- Character bi-grams from “coffee” include “co”, “of”, “ff”, “fe”, and “ee”. section 7.7.2
- Character tri-grams from “coffee” include “cof”, “off”, “ffe”, and “fee”. section 7.7.2
- Edge n-grams anchor every sequence at the beginning: “c”, “co”, “cof”, “coff”, “coffe”, and “coffee”. section 7.7.2
- Word shingles form word sequences such as [“elasticsearch”, “in”] and [“in”, “action”]. section 4.6.6
Elasticsearch’s ngram tokenizer emits overlapping character sequences, while edge_ngram emits prefix sequences. Configure min_gram and max_gram to control their sizes. section 7.7.2
Typeahead for book titles
Mapping a title as search_as_you_type creates n-gram subfields automatically. A multi_match query with bool_prefix searches the main title and its _2gram and _3gram subfields to suggest titles as users type. section 4.6.6



