meilisearch / meilisearch-php

PHP wrapper for the Meilisearch API

Home Page:https://meilisearch.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Primary key is not set for indexes

thijndehaas opened this issue · comments

Description
Every time I create the index the primary key is not set. I found this out because the index has duplicate product IDs.

Expected behavior
Primary key being id

Current behavior
Primary key being null

Screenshots or Logs
afbeelding
afbeelding

Environment (please complete the following information):

  • OS: Debian 5.10.70-1 (2021-09-30) x86_64
  • Meilisearch version: v.0.29.1
  • meilisearch-php version: v0.24.1 and v0.25.0

Hi @thijndehaas, thanks for raising the issue!

As you can check the source here:
https://github.com/meilisearch/meilisearch-php/blob/main/src/Endpoints/Indexes.php#L101-L109

    public function getPrimaryKey(): ?string
    {
        return $this->primaryKey;
    }

    public function fetchPrimaryKey(): ?string
    {
        return $this->fetchInfo()->getPrimaryKey();
    }

the method getPrimaryKey does not trigger an HTTP call, but the fetchPrimaryKey does. Can you try this one? I believe your $index is storing an old reference or a not updated one to the brand new index you created.

Hi @brunoocasali, thank you this returns id!

However this is one of our results, they have identical values, only the updated column has changed.
afbeelding

I have now cleared the entire data.ms folder and started with a clean set-up. I will check if the duplicates will come back.

@oluademola have you ever seen behavior like this? I'm inclined to treat that as a Meilisearch engine bug...

Hello @brunoocasali. I believe the same. We had a user report a similar issue on the Slack community channel, but we could not reproduce the problem 😞.

Hi @thijndehaas, I'll close this issue then. If there is something related to the PHP package I'll reopen it :)

Thanks a lot for your help ❤️