jolicode / elastically

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

Alias is only on the last created index #52

Closed AdrienBr closed 3 years ago

AdrienBr commented 3 years ago

Hi, I'm new here so I'm not sure it is a real problem, but there's something I do not understand :

When I create multiple indices "foobar_{date}" with the alias "foobar", only the last index is aliased. The former indices are not aliased anymore.

I work on V1.0.2 and ES 7.10.0

I hope someone can clarify this to me, thank you !

ternel commented 3 years ago

:wave:

This is normal. Elastically creates a new index everytime you call IndexBuilder->createIndex and change the alias to te latest index with the method markAsLive. If you want to remove old indices because you don't need them anymore, there's a method purgeOldIndices in the IndexBuilder.php. Call it, and old indices will be removed. See the doc here: https://github.com/jolicode/elastically/blob/223752b125f17e7ccb8563adc0657c1eccfa3a94/README.md#demo

damienalexandre commented 3 years ago

This is the intended behavior. You only want ONE index to be "live" at a time because this is where your searches are done.

Does that answer your question? May I recommend reeding https://jolicode.com/blog/introducing-elastically-our-elastica-ally too?

Cheers

AdrienBr commented 3 years ago

Thank you for your quick replies !

Yes you answered my question, I read the entire documentation more carefully and the method I was looking for is migrate

As far as I understand, when I need to update my index while keeping the old data available, I need to call migrate, markAsLive and purgeOldIndices

Thank you Cheers

damienalexandre commented 3 years ago

Yes absolutely :+1: Thanks!