3

Consider the follow list of products, at the moment these are sorted by name, this gives an unfair result which could lead to the following output (Giving 1 company the top of results, based on their 'fortunate' productnaming only)

Company x Product 1
Company x Product 2
Company x Product 3
Company y Product a
Company z Product a
Company y Product b
Company z Product b
Company y Product c
Company z Product c

How can I sort this using elasticsearch so that it comes out in "round robin" order, that is, select each unique item once before repeats. So the above list would come out like this:

Company x Product 1
Company y Product a
Company z Product a
Company x Product 2
Company y Product b
Company z Product b
Company x Product 3
Company y Product c
Company z Product c

I have found this question asked for LINQ : LINQ order by "round robin"

Community
  • 1
  • 1
  • Is Elasticsearch necessary for this solution? There is script-based sorting, but that's as far as I can help: http://www.elasticsearch.org/guide/reference/api/search/sort/ – Paul Bellora Jun 22 '13 at 01:43

1 Answers1

1

Unless you find some kind of script solution, your best bet is to perform several elasticsearch searches and merge the results manually. You can at least perform all the searches in a single request using the Multi Search API.

Andrew Macheret
  • 1,367
  • 13
  • 9