createShopIndex example


        $shopId = (int) $input->getArgument('shopId');
        $type = $input->getArgument('type');
        $query = $input->getArgument('query');
        $analyzer = $input->getArgument('analyzer');

        $shop = $this->container->get(ShopGatewayInterface::class)->get($shopId);
        if (!$shop instanceof ShopStruct) {
            throw new StructNotFoundException(ShopStruct::class$shopId);
        }
        $client = $this->container->get(Client::class);
        $index = $this->container->get(IndexFactory::class)->createShopIndex($shop$type);

        $analyzed = $client->indices()->analyze([
            'index' => $index->getName(),
            'analyzer' => $analyzer,
            'text' => $query,
        ]);

        $tokens = $analyzed['tokens'];

        $table = new Table($output);
        $table->setHeaders(['Token', 'Start', 'End', 'Type', 'position'])
            
$io = new SymfonyStyle($input$output);

        if (empty($backlogs)) {
            $io->success('Backlog is empty');

            return 0;
        }

        foreach ($this->identifierSelector->getShops() as $shop) {
            foreach ($this->mappings as $mapping) {
                $index = $this->indexFactory->createShopIndex($shop$mapping->getType());

                $this->backlogProcessor->process($index$backlogs);
            }
        }
        $last = $backlogs[array_key_last($backlogs)];
        $this->backlogReader->setLastBacklogId($last->getId());

        $io->success(sprintf('Synchronized %d items', \count($backlogs)));

        return 0;
    }
}
$this->client = $client;
        $this->indexFactory = $indexFactory;
        $this->handlerRegistry = $handlerRegistry;
    }

    /** * {@inheritdoc} */
    public function search(Criteria $criteria, ShopContextInterface $context)
    {
        $search = $this->buildSearch($criteria$context);
        $index = $this->indexFactory->createShopIndex($context->getShop(), ProductMapping::TYPE);

        $arguments = [
            'index' => $index->getName(),
            'body' => $search->toArray(),
            'rest_total_hits_as_int' => true,
            'track_total_hits' => true,
        ];

        $data = $this->client->search($arguments);

        $products = $this->createProducts($data);

        


        $groupIds = $this->getGroupIds($ids);

        $search = new EsSearch();
        $search->addQuery(new IdsQuery($groupIds), BoolQuery::FILTER);
        $search->addQuery(new TermQuery('filterable', true), BoolQuery::FILTER);
        $search->addSort(new FieldSort('name', 'asc'));
        $search->setFrom(0);
        $search->setSize(self::AGGREGATION_SIZE);

        $index = $this->indexFactory->createShopIndex($context->getShop(), PropertyMapping::TYPE);

        $arguments = [
            'index' => $index->getName(),
            'body' => $search->toArray(),
            'rest_total_hits_as_int' => true,
            'track_total_hits' => true,
        ];

        $data = $this->client->search(
            $arguments
        );

        
protected function execute(InputInterface $input, OutputInterface $output)
    {
        $shopId = $input->getArgument('shopId');
        $type = $input->getArgument('type');
        $indexName = $input->getArgument('index');

        /** @var Shop $shop */
        $shop = $this->container->get(ShopGatewayInterface::class)->get($shopId);

        /** @var ShopIndex $index */
        $index = $this->container->get(IndexFactory::class)
            ->createShopIndex($shop$type);

        /** @var Client $client */
        $client = $this->container->get(Client::class);

        $exist = $client->indices()->exists(['index' => $indexName]);
        if (!$exist) {
            throw new RuntimeException(sprintf('Index "%s" does not exist', $indexName));
        }

        $actions = [
            ['add' => ['index' => $indexName, 'alias' => $index->getName()]],
        ];
Home | Imprint | This part of the site doesn't use cookies.