Then you need to use/build something which reads the database, transform to JSON and write to elasticsearch.
- An ETL like Logstash with the
- Your own code
Then you can run that every 5 minutes for instance but as I explained, you have to deal with many things:
- It's not real-time
- You need a way to select data that changed since the last run. Probably it relies on a date field in your DB entities
- You need to deal with Deletes. You need for that a specific technical table in your DB probably.
Or you can choose to reindex the full database everytime. Be careful with the time it will take to read entities from your DB. May be you can do such a thing only once per day.
May be you can play with DB triggers though to "wake up" your code.