Gogo
Gogo

Reputation: 603

Creating indexes for Elasticquent in Laravel

Do I have to create indexes like this Book::createIndex($shards = null, $replicas = null); for every model in my Laravel project?

I succesfully created App\Law::createIndex($shards = null, $replicas = null);, but when I try to create App\LawType::createIndex($shards = null, $replicas = null); it shows an error:

Elasticsearch\Common\Exceptions\BadRequest400Exception with message '{"error":{" root_cause":[{"type":"index_already_exists_exception","reason":"already exists", "index":"default"}],"type":"index_already_exists_exception","reason":"already ex ists","index":"default"},"status":400}'

Upvotes: 2

Views: 3034

Answers (1)

Val
Val

Reputation: 217334

Laravel only creates a single index, whose default name is default but a custom name can also be configured via the settings called elasticquent.default_index.

After that, each model will be stored in a different type within that index using putMapping.

Upvotes: 2

Related Questions