I want to update my existing field with current date and time so I am using below srcipt and update by query API to achieve the same but I am not getting the desired result .
Rather than using the fairly slow update query just to modify one field why not use a pipeline to set the processing time as the document gets indexed (or updated). Something like
{
"description" : "Pipeline for setting the document processing time",
"processors" : [
{
"script" : {
"lang" : "painless",
"inline" : "DateFormat df = new SimpleDateFormat(\"yyyy-MM-dd'T'HH:mm:ss.SSS'Z'\");\ndf.setTimeZone(TimeZone.getTimeZone(\"UTC\"));\nDate date = new Date();\nctx.proctime = df.format(date);"
}
}
]
}
Here the field "proctime" is created and set to the current time for each document indexed through this pipeline processor. All you need is to pass along the pipeline=<my_named_pipe> parameter when indexing documents.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.