0
0
Elasticsearchquery~5 mins

Autocomplete with edge n-gram in Elasticsearch - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
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?
ABreaks words into suffixes starting from the end
BBreaks words into prefixes of varying lengths starting from the beginning
CRemoves stop words from the text
DConverts all text to uppercase
Which analyzer setting is best for searching autocomplete queries?
AWhitespace analyzer
BEdge n-gram analyzer
CStandard analyzer
DKeyword analyzer
If min_gram is set to 3, which of these tokens will NOT be generated for the word 'search'?
Asearc
Bsea
Csear
Dse
Why is edge n-gram indexing useful for autocomplete?
AIt allows fast prefix matching of user input
BIt compresses the index size
CIt improves spelling correction
DIt filters out irrelevant words
Where should edge n-gram filters be applied in Elasticsearch for autocomplete?
AAt index time analyzer
BAt search time analyzer
CBoth index and search time analyzers
DNeither, use keyword fields
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.