/** * {@inheritdoc} */ public function search(Criteria $criteria, ShopContextInterface $context) { $search = $this->buildSearch($criteria, $context); $index = $this->indexFactory->createShopIndex($context->getShop()); $data = $this->client->search(['index' => $index->getName(), 'type' => ProductMapping::TYPE, 'body' => $search->toArray()]); $products = $this->createProducts($data); $result = new ProductNumberSearchResult($products, $data['hits']['total'], []); if (isset($data['hits']['max_score'])) { $result->addAttribute('elastic_search', new Attribute(['max_score' => $data['hits']['max_score']])); } foreach ($this->handlers as $handler) { if (!$handler instanceof ResultHydratorInterface) { continue; } $handler->hydrate($data, $result, $criteria, $context); } return $result; }