0

I am trying to figure out how to sort one field based on the values of other fields in the index. My final objective is Suppose we have two fields in our objects: ex "val" and "user". Both are not unique. I wanted to take average of val for each unique user and sort them out. ex. user: 23, val : 1 user: 24, val: 4 user: 23, val: 8 In output: 1.)user 23 ------ 4.5 (Average) 2.)user 24 ------ 4 (Average)

The following can be done in kibana using metric table. It might be possible by aggregation but am not able to make sense out of the documentation.

Thanks

Aditya Patel
  • 569
  • 1
  • 10
  • 28

1 Answers1

0

As per my understanding you can do the following:-

Go to Visualize Page.

Select Data Table.

Select using a new search.

Then click on Split Rows.

Select aggregation as Terms & select field as user (in your case) & order by Top N (as needed).

Then select order by Custom Metric & select aggregation as average & field as val (in your case).

Yuvraj Gupta
  • 2,475
  • 16
  • 26
  • Hi,Thanks for the reply. But I am looking for a way to do it in elasticsearch itself and not use kibana. I presumed if it can be done in kibana than you can probably right a query of it as well. – Aditya Patel Jul 23 '15 at 05:14
  • I do not know about it. Maybe this thread can solve your problem:- http://stackoverflow.com/questions/26934243/elasticsearch-average-aggregation-in-results – Yuvraj Gupta Jul 23 '15 at 06:26