admin管理员组

文章数量:1243250

I'm wondering how to calculate (and build a bar-graph dashboard on top of it) average of list elements across documents/records that I have in ElasticSearch. Let me try to explain with a simple version:

Say I have three documents in ES, with each document having two array fields ('runners' - an array of strings, and 'runners_times' - an array of numbers, where elements in runners and runners_times are sorted so that the first element from the first list corresponds to the first element in the second list, so from document 1: person_a = 100, person_b = 120). Say my three documents/records in ES look like this:

  1. runners: [person_a, person_b], runners_times: [100, 120]
  2. runners: [person_a, person_c], runners_times: [90, 110]
  3. runners: [person_b, person_c], runners_times: [100, 130]

Now, what I want is a bar-graph that gives a list of all unique runners across all three documents (so, in this case, 'person_a', 'person_b', and 'person_c') with their corresponding average times. So, in my case, that would be:

person_a: 95 person_b: 110 person_c: 120

Any tip would be great. Thanks a lot :-)

I'm able to get a list of all unique value in runners, but I'm not sure how to get an average of that person's times, since they are in a separate list.

Should I perhaps try with dictionaries? {'person_a': 100, 'person_b': 120} maybe? I tried that, too, but dictionaries get saved as a list of unfolded fields instead.

本文标签: kibanaAverage of list elements across many documentsrecords in ElasticSearchStack Overflow