I have data in the mongo db like below.
"last-date": "2020-01-30T07:30:00Z"
"type": "certificate"
"daysleft": "7"
I had inserted this kind of records in to elasticsearch. I wanted to daily monitor the number of daysleft for the certificate after differentiating with current date and update the same record which is existing in elasticsearch.
my expectations are like below on the below dates it should dispaly the differece by calculating lastdate - Time.now(). Every second or every day it has to be updated once
2020-01-24 it should show 6
2020-01-25 it should show 5
2020-01-26 it should show 4
2020-01-27 it should show 3
2020-01-28 it should show 2
2020-01-24 it should show 1
2020-01-30 it should show 0
Is it possible to do in kibana or elasticsearch. If yes how can I achieve it. Help is really appreciated.
I may be missing some context here, but wouldn't it be easier, if you adapted your query by searching for documents with a certain last_date using the range query. This way there would be no need for updating that field, and you could probably simply omit it.
Thanks for the reply i will explain you my scenario.
I have documents in mongo db which has created_from and created_to both are timestamps.
I have to calculate the time difference between these two fields and display it as validity.
Then I have to keep track of the validity till it get expires. for example if validity between two "created_from and created to is 10 days"
while indexing data to elasticsearch i will have these three fields created_from and created_to and validity.
Then I need to find Number of days left for expiry i.e field "time_left" is validity - time.now(). I have to perform this step daily so I updated it as time.now().
Then I have to display the count of records which are falling under which range like > or < or <=.
I wanted to calculate with fields so how can I do it. created_to will be the future date which will be 30 or 90 days greater than today
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.