Complete the code to define an edge n-gram tokenizer named "autocomplete_tokenizer".
{
"settings": {
"analysis": {
"tokenizer": {
"autocomplete_tokenizer": {
"type": "[1]",
"min_gram": 1,
"max_gram": 20
}
}
}
}
}The edge_ngram tokenizer generates tokens from the beginning of a word, which is essential for autocomplete functionality.
Complete the analyzer definition to use the edge n-gram tokenizer for autocomplete.
{
"settings": {
"analysis": {
"analyzer": {
"autocomplete": {
"type": "custom",
"tokenizer": "[1]",
"filter": ["lowercase"]
}
}
}
}
}The analyzer uses the previously defined autocomplete_tokenizer to generate edge n-grams for autocomplete.
Fix the error in the mapping to use the autocomplete analyzer for the "name" field.
{
"mappings": {
"properties": {
"name": {
"type": "text",
"analyzer": "[1]"
}
}
}
}The autocomplete analyzer applies the edge n-gram tokenizer and lowercase filter to the "name" field for autocomplete search.
Fill both blanks to define a search analyzer that uses the standard tokenizer and lowercase filter.
{
"settings": {
"analysis": {
"analyzer": {
"search_analyzer": {
"type": "custom",
"tokenizer": "[1]",
"filter": ["[2]"]
}
}
}
}
}The search analyzer uses the standard tokenizer and lowercase filter to process search queries properly.
Fill all three blanks to complete the mapping with both autocomplete and search analyzers for the "title" field.
{
"mappings": {
"properties": {
"title": {
"type": "text",
"analyzer": "[1]",
"search_analyzer": "[2]",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": [3]
}
}
}
}
}
}The title field uses the autocomplete analyzer for indexing and the standard analyzer for searching. The keyword subfield ignores strings longer than 256 characters.