0
0
Elasticsearchquery~10 mins

Search-as-you-type field in Elasticsearch - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to define a search-as-you-type field in the mapping.

Elasticsearch
{
  "mappings": {
    "properties": {
      "title": {
        "type": "[1]"
      }
    }
  }
}
Drag options to blanks, or click blank then click option'
Atext
Bkeyword
Ccompletion
Dsearch_as_you_type
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'text' type instead of 'search_as_you_type' for search-as-you-type functionality.
2fill in blank
medium

Complete the code to add a subfield for exact matching inside the search-as-you-type field.

Elasticsearch
{
  "mappings": {
    "properties": {
      "title": {
        "type": "search_as_you_type",
        "fields": {
          "[1]": {
            "type": "keyword"
          }
        }
      }
    }
  }
}
Drag options to blanks, or click blank then click option'
Atext
Bexact
Craw
Dkeyword
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'keyword' as the subfield name instead of a custom name like 'raw'.
3fill in blank
hard

Fix the error in the query to search the search-as-you-type field for the prefix 'elastic'.

Elasticsearch
{
  "query": {
    "prefix": {
      "title.[1]": "elastic"
    }
  }
}
Drag options to blanks, or click blank then click option'
Akeyword
Braw
Cprefix
Dsearch_as_you_type
Attempts:
3 left
💡 Hint
Common Mistakes
Using the main field name without subfield for prefix queries.
4fill in blank
hard

Fill both blanks to complete the mapping with a search-as-you-type field and a subfield for exact matches.

Elasticsearch
{
  "mappings": {
    "properties": {
      "name": {
        "type": "[1]",
        "fields": {
          "[2]": {
            "type": "keyword"
          }
        }
      }
    }
  }
}
Drag options to blanks, or click blank then click option'
Asearch_as_you_type
Btext
Craw
Dkeyword
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping the main field type and subfield name.
5fill in blank
hard

Fill all three blanks to write a query that searches the search-as-you-type field for 'search' and sorts by the exact subfield.

Elasticsearch
{
  "query": {
    "match": {
      "title.[1]": "search"
    }
  },
  "sort": [
    {
      "title.[2]": {
        "order": "[3]"
      }
    }
  ]
}
Drag options to blanks, or click blank then click option'
Araw
Bkeyword
Casc
Dtext
Attempts:
3 left
💡 Hint
Common Mistakes
Using the keyword subfield in the match query instead of the main text field.