老师,这里不能直接拿 ES 里的商品数据吗
// 通过 collect 函数将返回结果转为集合,并通过集合的 pluck 方法取到返回的商品 ID 数组
$productIds = collect($result['hits']['hits'])->pluck('_id')->all();
// 通过 whereIn 方法从数据库中读取商品数据
$products = Product::query()
->whereIn('id', $productIds)
->get();
ES里面不是有商品数据吗?为什么还要根据Id重新去查一遍呢
推荐文章: