elastic / elasticsearch

Free and Open Source, Distributed, RESTful Search Engine
https://www.elastic.co/products/elasticsearch
Other
69.63k stars 24.64k forks source link

Add scripting support for ranges #50190

Open not-napoleon opened 4 years ago

not-napoleon commented 4 years ago

This is intended to be a starting discussion about the options and possibilities for range scripting. While working on aggregation support for range fields, we've encountered a couple of situations that seem better served by scripting than by new aggregations or aggregation parameters. A couple of examples:

To support this, several things need to happen:

elasticmachine commented 4 years ago

Pinging @elastic/es-analytics-geo (:Analytics/Aggregations)

elasticmachine commented 4 years ago

Pinging @elastic/es-core-infra (:Core/Infra/Scripting)

nik9000 commented 4 years ago

I think #47469 will complicate this somewhat.

not-napoleon commented 4 years ago

I think #47469 will complicate this somewhat.

Can you elaborate? I don't think the doc value formatter gets applied to script outputs or inputs (other than missing values, but missing already doesn't work with ranges in general, in part because of that issue).

nik9000 commented 4 years ago

I thought there was some issue where we assumed that the value of a field in the response matched the value of the field on disk. I thought this would change the value of a range to a date or number. But maybe it won't do that anyway.

not-napoleon commented 4 years ago

That's...possible, I'm not sure. I do remember I had to do some jank to get DateHistogram over ranges to format the bucket keys correctly, and this might hit something similar. My instinct is we should be able to work around that without fully solving the formatter issue though. Or, at least, that's my hope. I'm worried that #47469 is going to require a query syntax change and thus will need some deprecation plan, and I really don't want to block scripted ranges on that. But if we have to, we have to. 🤞 it doesn't come to that...