Hi, I would like to get the ISO week from the timestamp. I tried using Python but is not possible to import modules on the inline scripts (not sure why). Also, I tried with lucene expressions which would be something like this:
Hi Carlos,
I tried your first solution and it did appear to work for me (I didn't closely check the date to ISO week calculation). But of course Kibana is sending all that in the query which doesn't seem very optimal.
I would think a better solution would to get the ISO week added as the data is ingested into Elasticsearch if that's possible. Are you using logstash, or a beat?
Hi, thanks for your answer. Of course it works (not as precise as the formula, lacks some checks), and of course, is not optimal at all. Actually, the right solution would be this: floor( (doc['timestamp'].date.dayOfYear - doc['timestamp'].date.dayOfWeek + 10) / 7) = week of the year.
with some other checks too for some weird cases. But these expressions are only valid in elastic 5 alpha
Yes, processing this during log collection would be the right solution, but what if you have a whole year of data with dozens of different metrics? Change production data is more dangerous than apply some scripts to numeric fields on sporadic demand. The mere existence of this scripted fields is owing to the human nature, which is not able to predict the query workflow whims of the final user. Hence these scripted fields. Would be perfect if they were able to run client side.
But there is one part of my original question that have to be answered yet, why is there a python support if is not possible to import modules? or is it? how? Would be nice to have all of this well documented with some examples. Why there is support for groovy scripts but not for some modules such as Calendar with is format method that uses SimpleDateFormat to convert dates to different formats such as WEEK_OF_YEAR_FIELD ? </end of this long question>
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.