The following Scripted Field code is throwing an error,
def month = doc['signed_date'].date.monthOfYear;
I want to extract the months as a separate column. What am I doing wrong here?
Kindly help.
The following Scripted Field code is throwing an error,
def month = doc['signed_date'].date.monthOfYear;
I want to extract the months as a separate column. What am I doing wrong here?
Kindly help.
monthOfYear
is not a function that is available in painless. You can access date pieces with the functions at https://www.elastic.co/guide/en/elasticsearch/painless/master/painless-datetime.html#_datetime_pieces.
doc['timestamp'].value.getMonthValue()
is an example of a scripted field that returns the month of the year from the Kibana's web logs sample data set.
If you want the month as a string instead of a number, you could use doc['timestamp'].value.getMonth()
. That method is not listed in the docs but the docs say the datetime type is ZonedDateTime
and looking at the Java docs for ZonedDateTime shows some additional getter methods not mentioned in the painless documentation.
@Nathan_Reese Thank you soo much. Very useful doc!!
This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
© 2020. All Rights Reserved - Elasticsearch
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.