Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

hfalucas's avatar

Laravel with Elasticsearch and keep it sync with MySQL

Hi guys,

I would really appreciate some guidance with this Elasticsearch and MySQL thing. So I am about to start a project and I've been reading about Elasticsearch, but want to use it with MySQL. Given this what is the best approach to keep both synced?

1) Every time I create a record I have to do it in both MySQL and ES? 2) Have no idea...

Please someone point me in the right direction.

Thanks in advance.

0 likes
8 replies
webular's avatar

fyi - codesq - your link has an extra "," in it -- which makes it 404

anam's avatar

@freekmurze Thank you for the package. how do you sync data between MYSQL and Elasticsearch? As i understand, I have to save data twice during saving and updating. However, i don't understand, how do I use old data i already have in mysql database. Do you know any method to do that?

anam's avatar

@hfalucas thank you. Is there any way to copy whole mysql database and transform in to Elasticsearch indexes?

Post::addAllToIndex();

I think above approach is slower.

Please or to participate in this conversation.