0
0
Elasticsearchquery~10 mins

Deleting documents 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 delete a document by its ID.

Elasticsearch
DELETE /my_index/_doc/[1]
Drag options to blanks, or click blank then click option'
Aindex
B123
Cmy_id
Ddoc
Attempts:
3 left
💡 Hint
Common Mistakes
Using the index name instead of the document ID.
Using doc or other keywords instead of the actual ID.
2fill in blank
medium

Complete the JSON body to delete documents matching a condition.

Elasticsearch
{
  "query": {
    "term": { "status": [1] }
  }
}
Drag options to blanks, or click blank then click option'
A"status"
B"active"
Cactive
D"term"
Attempts:
3 left
💡 Hint
Common Mistakes
Not using quotes around the string value.
Using the field name instead of the value.
3fill in blank
hard

Fix the error in the delete by query request.

Elasticsearch
POST /my_index/_delete_by_query
{
  "query": {
    "match": { "[1]": "obsolete" }
  }
}
Drag options to blanks, or click blank then click option'
Astatus
Bdelete
Cquery
Dobsolete
Attempts:
3 left
💡 Hint
Common Mistakes
Putting the value instead of the field name as the key.
Using keywords like query or delete as field names.
4fill in blank
hard

Fill both blanks to delete documents where age is greater than 30.

Elasticsearch
{
  "query": {
    "range": {
      "age": { "[1]": [2] }
    }
  }
}
Drag options to blanks, or click blank then click option'
Agt
B30
Clt
Dage
Attempts:
3 left
💡 Hint
Common Mistakes
Using lt instead of gt.
Putting the number 30 in quotes.
5fill in blank
hard

Fill all three blanks to delete documents with status 'inactive' and priority less than 5.

Elasticsearch
{
  "query": {
    "bool": {
      "must": [
        { "term": { "status": [1] } },
        { "range": { "priority": { "[2]": [3] } } }
      ]
    }
  }
}
Drag options to blanks, or click blank then click option'
A"inactive"
Blt
C5
D"priority"
Attempts:
3 left
💡 Hint
Common Mistakes
Not quoting the status string.
Putting the number 5 in quotes.
Using wrong range operator like gt.