title: ElasticSearch: returning only first result from logical group
body: <p>I have an ElasticSearch index, where products are stored - like of an online shop. Now I want to introduce product variants in my shop, but I cannot change the index to use some nested or parent/child datatypes, because there are a lot of other tools, that already use this index (I do not want to adjust these tools also). We could only add some extra field.
  -> I cannot rebuilt the index and group variants to logical groups on index time.</p>
  
  <p>What is the best option to get such groups of items on query time?
  Another problem: a lot of product are non-variant, so result of my query must return a mix from variants (grouped) and non-variant separate items - they must be sorted alltogether by _score.
  Possible option: it is OK, if we do not get all items of a variant group, but only the best result from each variant group. But we must ensure, that we do not get items of a variant group as separate search results.</p>
  
  <p>Maybe we can achieve it with multiple queries - like first some aggregation over variant_id, after it another query to get all items </p>
  
  <p>Example:
  The following lines are indexed:</p>
  
  <pre><code>{"title": "Samsung TV xxx"}
  {"title": "Philips TV yyy"}
  {"title": "Nike shoe MyRun", "size": 40, "variant_group": 5}
  {"title": "Nike shoe MyRun", "size": 42, "variant_group": 5}
  {"title": "Adidas shoe YourRun", "size": 39, "variant_group": 10}
  {"title": "Adidas shoe YourRun", "size": 40, "variant_group": 10}
  {"title": "Adidas shoe YourRun", "size": 46, "variant_group": 10}
  {"title": "Dictionary book"}
  </code></pre>
  
  <p>My query, that matches all these items, should return these documents:</p>
  
  <pre><code>{"title": "Samsung TV xxx"}
  {"title": "Philips TV yyy"}
  [
      {"title": "Nike shoe MyRun", "size": 40, "variant_group": 5}
      {"title": "Nike shoe MyRun", "size": 42, "variant_group": 5}
  ]
  [
      {"title": "Adidas shoe YourRun", "size": 39, "variant_group": 10}
      {"title": "Adidas shoe YourRun", "size": 40, "variant_group": 10}
      {"title": "Adidas shoe YourRun", "size": 46, "variant_group": 10}
      {"title": "Dictionary book"}
  ]
  {"title": "Dictionary book"}
  </code></pre>
  
  <p>OR (the best result from each variant group):</p>
  
  <pre><code>{"title": "Samsung TV xxx"}
  {"title": "Philips TV yyy"}
  {"title": "Nike shoe MyRun", "size": 40, "variant_group": 5}
  {"title": "Adidas shoe YourRun", "size": 39, "variant_group": 10}
  {"title": "Dictionary book"}
  </code></pre>