Untitled
unknown
plain_text
9 months ago
3.1 kB
7
Indexable
public function esPrepareCollectionRequests($uri, $client, Request ...$requests): void
{
if ($client instanceof EsShopClient || $client instanceof EsShopVariantClient) {
$itemPerpage = $uri['itemsPerPage'] ?: 15;
$page = $uri['page'] ?: 1;
$max_result = $uri['returnMaxItem'] ?: 100;
$result = $this->calculatePagination($max_result, $page);
foreach ($requests as $request) {
$request->setUri('_search');
$client = $request->useHttpCache() ? $this->cacheClient : $this->client;
$options = [
"json" => [
"size" => 0,
"aggs" => [
"filtered_data" => [
"filter" => [
"bool" => [
"must" => [
["term" => ["product_taxons" => $uri['productTaxons.taxon.code']]],
],
]
],
"aggs" => [
"total_unique_idManif" => [
"cardinality" => [
"field" => "idManif.keyword"
]
],
"group_by_idManif" => [
"terms" => [
"field" => "idManif.keyword",
"order" => [
"_key" => "asc"
],
"size" => $result['size'],
"include" => [
"partition" => $result['partition'],
"num_partitions" => $result['num_partitions']
],
],
"aggs" => [
"hits" => [
"top_hits" => [
"size" => 1
]
]
]
]
]
]
]
]
];
}
$json = json_encode($options, JSON_PRETTY_PRINT);
$esRequest = $client->request($request->getMethod(), $request->getUri(), $options);
unset($options['use_http_cache']);
$this->requests[$request->getKey()] = $esRequest;
}
}Editor is loading...
Leave a Comment