0
0
Elasticsearchquery~20 mins

Text vs keyword field types in Elasticsearch - Practice Questions

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Elasticsearch Text vs Keyword Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
What is the output of this Elasticsearch query?

Given the following mapping and query, what will be the result count?

{
  "mappings": {
    "properties": {
      "name": { "type": "text" },
      "category": { "type": "keyword" }
    }
  }
}

POST /products/_search
{
  "query": {
    "term": { "category": "electronics" }
  }
}
AReturns no documents because 'term' query does not work on keyword fields
BReturns all documents where the category exactly matches 'electronics'
CReturns documents where the name contains the word 'electronics'
DReturns documents where the category contains the word 'electronics' anywhere
Attempts:
2 left
💡 Hint

Remember that keyword fields are not analyzed and match exact values.

🧠 Conceptual
intermediate
2:00remaining
Why use 'text' type instead of 'keyword' for a field?

Which reason best explains why you would choose text type over keyword type for a field in Elasticsearch?

ATo enable full-text search with tokenization and analysis
BTo store exact values for filtering and sorting
CTo reduce index size by storing unanalyzed data
DTo improve performance of term queries
Attempts:
2 left
💡 Hint

Think about when you want to search inside the text rather than match exact values.

🔧 Debug
advanced
2:00remaining
Why does this term query return zero results?

Given this mapping and query, why does the term query return zero results?

{
  "mappings": {
    "properties": {
      "description": { "type": "text" }
    }
  }
}

POST /items/_search
{
  "query": {
    "term": { "description": "fast car" }
  }
}
ABecause the term query syntax is incorrect and should use 'match' instead
BBecause the index is empty and has no documents
CBecause the field 'description' is missing from the mapping
DBecause 'description' is a text field and term queries require exact matches, so 'fast car' as a whole does not match
Attempts:
2 left
💡 Hint

Think about how term queries work on text fields.

📝 Syntax
advanced
2:00remaining
Which mapping snippet correctly defines a field for exact filtering and full-text search?

Choose the correct mapping snippet that allows a field to be searched as full text and also filtered exactly.

A{ "title": { "type": "text", "fields": { "raw": { "type": "keyword" } } } }
B{ "title": { "type": "keyword", "fields": { "raw": { "type": "text" } } } }
C{ "title": { "type": "text" } }
D{ "title": { "type": "keyword" } }
Attempts:
2 left
💡 Hint

Think about multi-fields and how to support both search and filtering.

🚀 Application
expert
2:00remaining
How many unique values can be efficiently filtered using a keyword field?

In Elasticsearch, what is the practical limit on the number of unique values in a keyword field before performance degrades significantly?

AKeyword fields should only have a single unique value for best performance
BThere is no limit; keyword fields handle millions of unique values efficiently
CUp to a few thousand unique values is efficient; beyond that, performance may degrade
DKeyword fields are not used for filtering unique values
Attempts:
2 left
💡 Hint

Consider how Elasticsearch stores keyword terms and the impact on memory.