0
0
Elasticsearchquery~10 mins

Term query 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 create a term query that searches for documents where the field 'user' exactly matches 'kimchy'.

Elasticsearch
{
  "query": {
    "term": {
      "user": [1]
    }
  }
}
Drag options to blanks, or click blank then click option'
A"kimchy"
B"match"
C"user"
D"term"
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'match' instead of the exact value.
Putting the field name as the value.
Using the query type as the value.
2fill in blank
medium

Complete the code to create a term query that searches for documents where the field 'status' exactly matches the value 'active'.

Elasticsearch
{
  "query": {
    "term": {
      "status": [1]
    }
  }
}
Drag options to blanks, or click blank then click option'
A"status"
B"inactive"
C"active"
D"term"
Attempts:
3 left
💡 Hint
Common Mistakes
Using the field name as the value.
Using the query type as the value.
Using a different string like "inactive".
3fill in blank
hard

Fix the error in the term query to correctly search for documents where 'age' is exactly 30.

Elasticsearch
{
  "query": {
    "term": {
      "age": [1]
    }
  }
}
Drag options to blanks, or click blank then click option'
A"30"
B"age"
C"term"
D30
Attempts:
3 left
💡 Hint
Common Mistakes
Putting the number 30 inside quotes, making it a string.
Using the field name as the value.
Using the query type as the value.
4fill in blank
hard

Fill both blanks to create a term query that searches for documents where the field 'category' exactly matches 'books'.

Elasticsearch
{
  "query": {
    [1]: {
      [2]: "books"
    }
  }
}
Drag options to blanks, or click blank then click option'
A"term"
B"match"
C"category"
D"query"
Attempts:
3 left
💡 Hint
Common Mistakes
Using "match" instead of "term".
Using the field name as the outer key.
Swapping the keys.
5fill in blank
hard

Fill all three blanks to create a term query that searches for documents where the field 'status' exactly matches 'pending'.

Elasticsearch
{
  [1]: {
    [2]: {
      [3]: "pending"
    }
  }
}
Drag options to blanks, or click blank then click option'
A"term"
B"query"
C"status"
D"match"
Attempts:
3 left
💡 Hint
Common Mistakes
Using "match" instead of "term".
Swapping the order of keys.
Using the field name as the top-level key.