Inside of the script context for an Update By Query, is there any way (other than parsing the raw strings), to access the doc values for date fields? I'm trying to write a script to handle some dates on some of our objects, and we have a number of different supported input formats, which are all handled by the field mapping on the index.
I would be happy to either access to doc value field as a string, or as an actual Object in Painless. I've tried doc['field_name'], but this returned as "Variable [doc] is not defined." I tried adding the "docvalue_fields" line in the update_by_query request, but it does not appear to help.
If the above is not possible, can someone point to a working parseBest example using a DateTimeFormatter? I see the call is supported, but my attempts to use it have failed. I used it similarly to how I would in Java: TemporalAccessor temporalAccessor = dtf.parseBest(date, OffsetDateTime::from, LocalDateTime::from);
Unfortunately, two compounding issues have occurred here. Currently, Painless doesn't support either varargs. To resolve this use an array in place of the varargs. However, method references cannot be stored as part of local variables, but there is another work around. If you create a method, you can return the result of a method reference and then create an array in place of the varargs argument.
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.