0
0
Elasticsearchquery~20 mins

Term query in Elasticsearch - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Term Query 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 term query?
Given the following Elasticsearch term query, what documents will it match?
Elasticsearch
{
  "query": {
    "term": {
      "status": {
        "value": "active"
      }
    }
  }
}
ADocuments where the field 'status' exactly matches the string 'active'
BDocuments where the field 'status' starts with 'active'
CDocuments where the field 'status' contains the word 'active' anywhere in the text
DDocuments where the field 'status' is missing or null
Attempts:
2 left
💡 Hint
Remember, term query matches exact values without analyzing the text.
🧠 Conceptual
intermediate
1:30remaining
Which field type is best for term query?
Which Elasticsearch field type is most suitable for using with a term query to match exact values?
Akeyword (not analyzed string field)
Btext (analyzed string field)
Cdate
Dgeo_point
Attempts:
2 left
💡 Hint
Term query works best on fields that are not broken into tokens.
🔧 Debug
advanced
2:30remaining
Why does this term query return no results?
You run this term query but get no results. What is the likely cause?
Elasticsearch
{
  "query": {
    "term": {
      "user": "John Doe"
    }
  }
}
AThe term query only works on numeric fields
BThe term query syntax is invalid and causes a syntax error
CThe field 'user' does not exist in the index
DThe field 'user' is analyzed and the term query expects exact match, so 'John Doe' does not match the analyzed tokens
Attempts:
2 left
💡 Hint
Think about how term query matches exact values and how analyzed fields store data.
📝 Syntax
advanced
2:00remaining
Identify the syntax error in this term query
Which option contains a syntax error in the term query?
A{ "query": { "term": { "status": "active" } } }
B{ "query": { "term": { "status": ["active"] } } }
C{ "query": { "term": { "status": { "value": "active", "boost": 2.0 } } } }
D{ "query": { "term": { "status": { "value": "active" } } } }
Attempts:
2 left
💡 Hint
Check the expected data type for the term query value.
🚀 Application
expert
3:00remaining
How many documents match this term query?
Assume an Elasticsearch index has these documents with field 'category': 1. {"category": "Books"} 2. {"category": "books"} 3. {"category": "Books and More"} 4. {"category": "Books"} Given the term query below, how many documents will match?
Elasticsearch
{
  "query": {
    "term": {
      "category.keyword": "Books"
    }
  }
}
A1
B3
C2
D4
Attempts:
2 left
💡 Hint
Term query on keyword fields is case sensitive and matches exact values only.