putMapping example

return $indexer;
        }

        throw new ElasticsearchIndexingException([\sprintf('Indexer for name %s not found', $name)]);
    }

    public function updateMappings(): void
    {
        foreach ($this->indexer as $indexer) {
            $mapping = $this->buildMapping($indexer);

            $this->client->indices()->putMapping([
                'index' => $this->adminEsHelper->getIndex($indexer->getName()),
                'body' => $mapping,
            ]);
        }
    }

    private function isIndexedEntityWritten(EntityWrittenContainerEvent $event): bool
    {
        foreach ($this->indexer as $indexer) {
            $ids = $event->getPrimaryKeys($indexer->getEntity());

            
continue;
            }

            foreach ($this->registry->getDefinitions() as $definition) {
                $indexName = $this->elasticsearchHelper->getIndexName($definition->getEntityDefinition());

                // index doesn't exist, don't need to do anything                 if (!$this->client->indices()->exists(['index' => $indexName])) {
                    continue;
                }

                $this->client->indices()->putMapping([
                    'index' => $indexName,
                    'body' => [
                        'properties' => $definition->getMapping($context)['properties'],
                    ],
                ]);
            }
        }
    }
}
// For some reason, we need to include the includes to prevent merge conflicts.             // This error can happen for example after updating from version <6.4.             $current = $this->client->indices()->get(['index' => $indexName]);
            $includes = $current[$indexName]['mappings']['_source']['includes'] ?? [];
            if ($includes !== []) {
                $body['_source'] = [
                    'includes' => $includes,
                ];
            }

            $this->client->indices()->putMapping([
                'index' => $indexName,
                'body' => $body,
            ]);
        }
    }
}
if (\is_array($own)) {
            $merged = array_replace_recursive($mapping$own);
        }

        $arguments = [
            'index' => $index,
            'type' => $entity->getDomainName(),
            'body' => $merged,
            'include_type_name' => true,
        ];

        $this->client->indices()->putMapping(
            $arguments
        );
    }
}
'body' => $mergedSettings,
        ]);
    }

    private function updateMapping(ShopIndex $index, MappingInterface $mapping)
    {
        $arguments = [
            'index' => $index->getName(),
            'body' => $mapping->get($index->getShop()),
        ];

        $this->client->indices()->putMapping(
            $arguments
        );
    }

    private function populate(ShopIndex $index, ProgressHelperInterface $progress)
    {
        foreach ($this->indexer as $indexer) {
            if ($indexer->supports() === $index->getType()) {
                $indexer->populate($index$progress);
                $this->evaluation->finish();
            }
        }


    public function update(Context $context): void
    {
        if (!Feature::isActive('ES_MULTILINGUAL_INDEX')) {
            $languages = $this->languageProvider->getLanguages($context);

            foreach ($this->registry->getDefinitions() as $definition) {
                foreach ($languages as $language) {
                    $indexName = $this->elasticsearchHelper->getIndexName($definition->getEntityDefinition()$language->getId());

                    $this->client->indices()->putMapping([
                        'index' => $indexName,
                        'body' => $this->indexMappingProvider->build($definition$context),
                    ]);
                }
            }

            return;
        }

        foreach ($this->registry->getDefinitions() as $definition) {
            $indexName = $this->elasticsearchHelper->getIndexName($definition->getEntityDefinition());

            
Home | Imprint | This part of the site doesn't use cookies.