jolicode / elastically

🔍 JoliCode's Elastica wrapper to bootstrap Elasticsearch PHP integrations
248 stars 37 forks source link

purgeOldIndices don't work due to prefix beeing doubled. #48

Closed ThibautSF closed 3 years ago

ThibautSF commented 3 years ago

Hi,

Each time I call purgeOldIndices, I get a PHP Fatal Error : Uncaught Elastica\\Exception\\ResponseException: no such index [085476ba4ddd6f761f52520af314195c36b39a5711c27daf5978982311cf8369_085476ba4ddd6f761f52520af314195c36b39a5711c27daf5978982311cf8369_eln_pageattach_2020-11-04-091603]

My index name is eln_pageattach and my prefix is 085476ba4ddd6f761f52520af314195c36b39a5711c27daf5978982311cf8369.

As we can see, the prefix is now double, because 085476ba4ddd6f761f52520af314195c36b39a5711c27daf5978982311cf8369_eln_pageattach_2020-11-04-091603 is the real index.

This is caused by getIndex with real name:

            if ($livePassed && $afterLiveCounter > 1) {
                // Remove
                $this->client->getIndex($realIndexName)->delete();
                $operations[] = sprintf('%s deleted.', $realIndexName);
            }

Because getIndex always adds the prefix.

damienalexandre commented 3 years ago

Can you try dev-master? It should have been fixed in 2a67fce.

Thanks!

ThibautSF commented 3 years ago

Indeed.

I made a local override with this commit (while waiting for the next update).

Thanks