Here is an example:
POST /test-scholarship/_doc
{
"student": "George",
"grade": 98
}
I want to add a new field (scholarship) to the above doc.
POST /test-scholarship/_update_by_query
{
"script": "ctx._source.scholarship = 'Yes'",
"query": {
"grade": {
"row": {
"gte": 95
}
}
}
}
Then
GET /test-scholarship/_search
returns:
"hits" : [
{
"_index" : "test-scholarship",
"_type" : "_doc",
"_id" : "ORawAm0BHjv4SKuqp9C8",
"_score" : 1.0,
"_source" : {
"student" : "George",
"grade" : 98,
"scholarship" : "Yes"
}
}
]
Question:
- How can I automate this update_by_query task? I don't want to run this query every once in a while to update my documents with a new field, I want to run this query automatically on my data every day. Is it possible?
I appreciate any feedback or suggestions.