I have a bunch of data in Kibana that I need to clean up by using an scripted field with "painless" which is a version of Java. At the moment I have an preexisting index in my logs with a date in this format "2021-09-27T13:54:17.165Z" I need to find how many days its been since that day until today whenever this search is ran, if its over or at 300 days it needs to return false if its lower true.
I was trying this to get number of days its been:
new Date().getTime() - doc['date'].value;
I was on stack overflow I saw someone said that new Date().getTime() will give you todays date. But I think the issue is that the time format for new Date().getTime() returns time in the format of 1657151078131 but my index date is in "2021-09-27T13:54:17.165Z" I am not sure how to convert it in order to find the displacement of less or more than 300 days.
Any help will be greatly appreciated
#ELK #elasticsearch #kibana #elastic