I tested follow mapping - transform script
"mappings": {
"tag": {
"_timestamp": {
"enabled": true
},
"transform": {
"script": "ctx._source.counter = ctx._source.counter == null ? 1 : 2",
"lang": "groovy"
},
...
"counter": {
"type": "long",
"index": "not_analyzed",
"store" : true,
"doc_values": true
},
...
and it worked fine when indexing a new document, the counter
field is set to 1
for each new entry added.
When I want to update/overwrite an existing entry, the script is not executed anymore. In other words, the counter is not set to 2
. Is this correct?
I would like to prevent using scripting inside the update API request (no need for the client to know this is needed), but still have some modifications in documents that are being updated in ES.
I also thought I would be able to check with ctx.op
if a document is created or updated...
Any ideas?
regards,
Sven