In my sport index, I have the following documents indexed as football_team 
type:

https://gist.github.com/tugberkugurlu/4fd750a5ada3ee5de17a#file-index-js

Here, each football team has a name and some strength values. Besides that, 
there is a player_ids collection for each team. The team stregth has been 
calculated by taking the avarage of players' strengths during the ETL 
process. You can also see that there are multiple football teams with the 
same name here but the player_ids collection is different.

When we run the following query:

https://gist.github.com/tugberkugurlu/4fd750a5ada3ee5de17a#file-search_query-js

We will get the following result:

https://gist.github.com/tugberkugurlu/4fd750a5ada3ee5de17a#file-search_result-js

Which is expected. However, what I would like to get here is top 1 row of 
each group (grouped by the team name). The result I would like to get for 
the above query is this:

https://gist.github.com/tugberkugurlu/4fd750a5ada3ee5de17a#file-expected_result-js

Any idea?

Also, Here is the whole question in 
gist: 
https://gist.github.com/tugberkugurlu/4fd750a5ada3ee5de17a#file-football_teams-md

Tugberk

-- 
You received this message because you are subscribed to the Google Groups 
"elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elasticsearch+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elasticsearch/73eefd0e-c555-4f70-9e67-5da05b04f32b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to