Comparing 2 dates that are in different fields

Hello everyone,

I have a file with several fields.
I have a field " date.start" and a field "date.end" which contains dates under this format in the json = " 2016-07-01T00:00:00-06:00"

I am trying to create a visualization table to display when date.end < date.start.

When using the filter " date.end < date.start" or "date.end LT date.start" I am getting wrong results.

I saw another topic talking about something similar, the solution proposed was :
{"constant_score":{"filter": {"script": {"script": "doc['REPORTED_ON'].value > doc['DUE_DATE'].value"}}}} but I am not sure to understand how to use it in my case.

I am pretty new to this tool and still learning, any help will be appreciated.

Thanks

  • Rayan

You can create the script you mentioned within Kibana. Under Settings > Indices, select your index and choose the "Scripts" tab. Add a new script and use doc['date.start'].value > doc['date.end'].value". You can then use the new boolean field to select the data.

Though, your filter should work. What is are the types of those fields? You can use the ES API to view the mapping, for Example: http://localhost:9200/topbeat-*?pretty=true