31 private $connectionManager;
41 private $storeManager;
46 private $clientConfig;
51 private $searchIndexNameResolver;
56 private $productRepository;
61 $this->client = $this->connectionManager->getConnection();
78 $result = $this->searchByName(
'Configurable Product');
79 self::assertGreaterThanOrEqual(2,
$result);
92 $result = $this->searchByName(
'12345');
95 $specificProduct = $this->productRepository->get(
'configurable_12345');
96 self::assertEquals($specificProduct->getId(),
$result[0][
'_id']);
103 private function searchByName(
$text)
105 $storeId = $this->storeManager->getDefaultStoreView()->getId();
107 'index' => $this->searchIndexNameResolver->getIndexName(
$storeId,
'catalogsearch_fulltext'),
108 'type' => $this->clientConfig->getEntityType(),
112 'minimum_should_match' => 1,
124 $queryResult = $this->client->query($searchQuery);
125 return isset($queryResult[
'hits'][
'hits']) ? $queryResult[
'hits'][
'hits'] : [];
133 private function reindexAll()
138 $indexer->load(
'catalogsearch_fulltext');
testSearchSpecificProduct()
static getObjectManager()