1

I have an use case where an Elasticsearch index and a MySQL Database should be remain synchronized and meet the following conditions.

1) Whenever I insert/update/delete in Elasticsearch index it should be synchronized with the Database(MySQL).

2) This synchronization should be done instantly.

3) For the Elasticsearch Index I am doing insert/update/delete at any time with any number of requests.

How can I do this using Elasticsearch?

Thanks!!

4
  • 1
    Shouldn't it be the other way around ? You put the data into MySql and then index it into ES ? Commented Feb 21, 2014 at 8:41
  • In my use case I have the above set of method. So the other way is not possible Commented Feb 21, 2014 at 8:46
  • That is a pity, because MySQL is (nearly) ACID while ElasticSearch is not. It really should be the other way around. Commented Feb 21, 2014 at 8:49
  • Did you check this - github.com/elasticsearch/elasticsearch/blob/master/src/main/… , this is a listener which gets invoked once the index gets updated , see if you can override the postIndex method and then sync up the MySql DB Commented Feb 21, 2014 at 8:53

1 Answer 1

2

Check this out - Listener for ES

So this is essentially a listener which gets invoked when the index gets updated / deleted . So override the method postCreate ,postIndex and postDelete and accordingly update the MySQl DB

Sign up to request clarification or add additional context in comments.

3 Comments

Thank you for you answer Rocky.Let me try this
Hi Rocky. Do we want to create any River for this to do the sync?
AFAIK River is used for data flowing into ES , in your case its the other way around , so I doubt if River would be of any help here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.