Collapse inner hits

I use collapse to get goods with the lowest price:

GET xxx/sku/_search
{
  "from": 0,
  "size": 10,
  "sort": [
    {
      "firstUpTime": {
        "order": "desc"
      }
    }
  ],
  "collapse": {
    "field": "goodsWebSpu",
    "inner_hits": {
      "name": "skus",
      "size": 1,
      "sort": [
        {
          "displayPrice": {
            "order": "asc"
          }
        }
      ]
    }
  }
}

It works correctly but it's too expensive for the cluster to execute this query.

The office document says,

The expansion of the group is done by sending an additional query for each inner_hit request for each collapsed hit returned in the response. This can significantly slow things down if you have too many groups and/or inner_hit requests.

My test result:

Is there any more efficient way to do this?

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.