Sort the basic of Number of documents

What about TermFacet on field user_id_2?

--

Le 11 août 2012 à 14:39, Chetan Sharma carl@izap.in a écrit :

I am saving user relations in ES Index

i.e

{'id' => 1, 'User_id_1' => '2001', 'relation' => 'friend', 'User_id_2' => '1002'}
{'id' => 2, 'User_id_1' => '2002', 'relation' => 'friend', 'User_id_2' => '1002'}

{'id' => 3, 'User_id_1' => '2002', 'relation' => 'friend', 'User_id_2' => '1001'}
{'id' => 4, 'User_id_1' => '2003', 'relation' => 'friend', 'User_id_2' => '1003'}

no suppose i want to get the user_id_2 who has most friends,

in above case its 1002 as 2001, and 2002 are its friends. (Count = 2)

I just can't figure out the query

Thanks.

--

--