Painless Script on Top Hit of Average Aggregation

I want to do some scripting on a top hit average aggregation. (I think the images are pretty much self-explanatory. Script is just an example). But when I do so I get an "Internal Server Error". What am I doing wrong?

1

2

I'm not sure what this is trying to achieve. You're using the top_hits agg to get only the top 1 document (sorted by time, so "latest") and computing an average of that single value (so presumably min or max would work equally well here?).

The advanced panel is where you can merge arbitrary JSON into the request which is where I see you're trying to retrieve a value using a script but this is going wrong. Have you tried debugging the JSON you're trying to merge with by checking out the Inspect->View:Requests menu options in Kibana? Another option may be to create a "scripted field" in your index pattern. Either way, this is likely more a question for the Kibana forum.

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