I want to append some data to a document in Elasticsearch and set a timestamp using MVEL.
this is what I am currently trying. But it does not work.
{"error":"ElasticSearchIllegalArgumentException[failed to execute script]; nested: PropertyAccessException[[Error: could not access property (Timestamp) in: java.lang.Long]\n[Near : {... Timestamp ....}]\n ^\n[Line: 1, Column: 1]]; ","status":400}
How can I access the Timestamp field (it is successfully created via a mapping)
{
"script": "
valueSet.Timestamp = time();
if (ctx._source[\"values\"] == null) { ctx._source.values = valueSet} else {ctx._source.values += valueSet}
",
"params": {
"valueSet":
[
{
"Timestamp": "",
"value": "100.00"
}
]
}
}
UPDATE:
Found out how to access the valueSet
{
"script": "
valueSet[0].value = 'test';
if (ctx._source[\"values\"] == null) { ctx._source.values = valueSet} else {ctx._source.values += valueSet}
",
"params": {
"valueSet":
[
{
"Timestamp": "",
"value": "100.00"
}
]
}
}
The above will override the "100.00" to "test".