ruflin / Elastica

Elastica is a PHP client for elasticsearch
http://elastica.io/
MIT License
2.26k stars 736 forks source link

Error to Create Index, Settings, Analysis #1741

Open EliuFlorez opened 4 years ago

EliuFlorez commented 4 years ago

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.");
}`

ruflin commented 4 years ago

You can create indices from Elastica. Could you share in detail what the part is you couldn't create?