Elasticsearch sort by count of nested objects

Viewed 4612

I have the following ES content, basically a list of product with nested offers from sites.

{
"product": {
  "ean": "abc",
  "features": {
     "product_type": "DVD player"
  },
  "color": "Black",
  "manufacturer": "Sony",
  "sitedetails": [
     {
        "name": "amazon.com",
        "sku": "zzz",
        "url": "http://www.amazon.com/dp/zzz"
     },
     {
        "name": "bestbuy.com",
        "sku": "aaa",
        "url": "http://www.bestbuy.com/aaa"
     }
  ],
  "category": "Portable DVD Players"
 },
 product: { etc etc},
 product: { etc etc},
}

How can I sort by the count of sitedetails?

tnx!

3 Answers
Related