DateRange Aggregation w/ a Script that produces the Dates instead of a static date field

ES: 6.1.1
NEST: 6.1.0

Is it possible to create a DateRange Aggregation where, instead of specifying a field, I can specify a script which will produce a Date from a number of source fields? In my case, there's a "good, better, best" set of dates in 3 different fields (all optional expect the "good") in my documents that I'd like to choose from dynamically as each hit is produced. That is, if the "best" is populated, I'll return that one and so on.

My web searches so far haven't produced any results so I'm doubtful it's possible but thought I'd raise the use case and see.

Hey,

how about using a script in a terms for this, as this is basically just a question how to name the buckets then.

--Alex

Hey Alex,

Thanks for the suggestion. I actually ended up using a regular range aggregation where I can specify a script and my params are in terms of milliseconds as well as the script calculations which use my "good, better, best" date fields in milliseconds. With this I can achieve the same effect w/o any date parsing, etc. and w/o date_range supporting scripts.

I also created a companion script for the resulting range filters that we implement based on the aggregations we produce.

1 Like

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.