0
0
Elasticsearchquery~10 mins

Updating 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 update a document by setting the field 'status' to 'active'.

Elasticsearch
{
  "doc": {
    "status": "[1]"
  }
}
Drag options to blanks, or click blank then click option'
Adeleted
Binactive
Cactive
Dpending
Attempts:
3 left
💡 Hint
Common Mistakes
Choosing a status that does not represent an active state.
Using a value not in the options.
2fill in blank
medium

Complete the code to update a document by incrementing the 'views' field by 1 using a script.

Elasticsearch
{
  "script": {
    "source": "ctx._source.views [1] 1"
  }
}
Drag options to blanks, or click blank then click option'
A-=
B/=
C*=
D+=
Attempts:
3 left
💡 Hint
Common Mistakes
Using '-=' which would decrease the value.
Using '*=' or '/=' which would multiply or divide the value.
3fill in blank
hard

Fix the error in the update request by completing the missing part to specify the document ID.

Elasticsearch
POST /my_index/_update/[1]
{
  "doc": {
    "field": "value"
  }
}
Drag options to blanks, or click blank then click option'
A1
Bmy_index
C_update
Ddoc
Attempts:
3 left
💡 Hint
Common Mistakes
Using the index name instead of the document ID.
Using keywords like '_update' or 'doc' as the ID.
4fill in blank
hard

Fill in the blank to update the 'price' field by multiplying it by 1.1 using a script.

Elasticsearch
{
  "script": {
    "source": "ctx._source.price [1] 1.1"
  }
}
Drag options to blanks, or click blank then click option'
A+=
B*=
C-=
D/=
Attempts:
3 left
💡 Hint
Common Mistakes
Using addition or subtraction operators instead of multiplication.
Using division operator which would reduce the price.
5fill in blank
hard

Fill all three blanks to update a document by setting 'status' to 'sold', incrementing 'sales' by 1, and adding a tag 'featured'.

Elasticsearch
{
  "script": {
    "source": "ctx._source.status = '[1]'; ctx._source.sales [2] 1; ctx._source.tags.add('[3]')"
  }
}
Drag options to blanks, or click blank then click option'
Asold
B+=
Cfeatured
D-=
Attempts:
3 left
💡 Hint
Common Mistakes
Using '-=' instead of '+=' for incrementing sales.
Using wrong strings for status or tag.