Recall & Review
beginner
What is the purpose of using edge n-gram in autocomplete?
Edge n-gram helps break down words into smaller parts starting from the beginning, allowing fast prefix matching for autocomplete suggestions.
Click to reveal answer
beginner
Which Elasticsearch analyzer is commonly used to create edge n-grams?
The
edge_ngram tokenizer or filter is used within a custom analyzer to generate edge n-grams for autocomplete.Click to reveal answer
intermediate
What is the difference between
min_gram and max_gram in edge n-gram settings?min_gram sets the smallest size of the n-gram, and max_gram sets the largest size. For example, min_gram=2 and max_gram=5 generate n-grams of length 2 to 5.Click to reveal answer
intermediate
Why should edge n-gram be applied at index time and not at search time?
Applying edge n-gram at index time creates tokens for fast prefix matching. At search time, using a standard analyzer keeps queries simple and efficient.
Click to reveal answer
advanced
Give an example of a simple Elasticsearch mapping using edge n-gram for autocomplete.
A mapping with a custom analyzer using edge n-gram filter on a text field enables autocomplete. Example:
{
"settings": {
"analysis": {
"analyzer": {
"autocomplete": {
"tokenizer": "standard",
"filter": ["lowercase", "autocomplete_filter"]
}
},
"filter": {
"autocomplete_filter": {
"type": "edge_ngram",
"min_gram": 2,
"max_gram": 10
}
}
}
},
"mappings": {
"properties": {
"name": {
"type": "text",
"analyzer": "autocomplete",
"search_analyzer": "standard"
}
}
}
}Click to reveal answer
What does the edge n-gram tokenizer do in Elasticsearch?
✗ Incorrect
Edge n-gram tokenizer creates tokens that are prefixes of the original word, useful for autocomplete.
Which analyzer setting is best for searching autocomplete queries?
✗ Incorrect
Using the standard analyzer at search time keeps queries simple and matches the indexed edge n-grams efficiently.
If min_gram is set to 3, which of these tokens will NOT be generated for the word 'search'?
✗ Incorrect
With min_gram=3, tokens shorter than 3 characters like 'se' are not generated.
Why is edge n-gram indexing useful for autocomplete?
✗ Incorrect
Edge n-gram indexing creates prefixes that match user input quickly for autocomplete suggestions.
Where should edge n-gram filters be applied in Elasticsearch for autocomplete?
✗ Incorrect
Edge n-gram filters are applied at index time to generate tokens; search time uses a simpler analyzer.
Explain how edge n-gram helps implement autocomplete in Elasticsearch.
Think about how words are broken down and matched during search.
You got /4 concepts.
Describe the key settings needed to configure an edge n-gram analyzer for autocomplete.
Focus on the analyzer and filter configuration in Elasticsearch settings.
You got /5 concepts.