Skip to content

Commit

Permalink
fix: define primary key when adding documents
Browse files Browse the repository at this point in the history
If we do not define the primary key when adding documents, MeiliSearch does not know which should be the primary key

Find more information here:
https://www.meilisearch.com/docs/learn/core_concepts/primary_key#meilisearch-guesses-your-primary-key
  • Loading branch information
malteriechmann authored Feb 23, 2024
1 parent c58ec08 commit 66902ba
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion Classes/Service/IndexService.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function add(Document $document)
try {
if ($this->client->isHealthy()) {
$index = $this->client->index($this->index);
$index->addDocuments($document->toArray());
$index->addDocuments($document->toArray(), 'id');
} else {
$this->logger->warning('MeiliSearch is not healthy.');
}
Expand Down

0 comments on commit 66902ba

Please sign in to comment.