Elastica
Elastica copied to clipboard
Error to Create Index, Settings, Analysis
Hi guys I have an error trying to create index with your settings and analysis.
Can indexes be created from Elastica or cannot and do I have to do it from console?
JSON:
{ "settings": { "index": { "number_of_shards": 2, "number_of_replicas": 1 }, "analysis": { "analyzer": { "categoryIdAnalyzer": { "type": "custom", "tokenizer": "whitespace" }, "std_lang": { "type": "standard", "stopwords": "_english_" } }, "filter": [] } }, ...
Code `// Create Index $elasticaIndex->create([], true);
// Settings Index if (isset($indexMapping['settings']['index'])) { $elasticaIndex->setSettings($indexMapping['settings']['index']); }
// Settings Analysis if (isset($indexMapping['settings']['analysis'])) { $elasticaIndex->analyze($indexMapping['settings']['analysis']); }
// Define mapping $mapping = new Mapping($indexMapping['mappings']['properties']);
// Response
if ($response = $elasticaIndex->setMapping($mapping)) {
print('CreateIndex-Success: '.$value. PHP_EOL);
$return = !$response->hasError();
} else {
print('CreateIndex-Error: '.$value. PHP_EOL);
$logger = $this->container->get("logger");
$logger->critical("Elasticsearch Index Creation Failed.");
}`
You can create indices from Elastica. Could you share in detail what the part is you couldn't create?