You need to send your existing data to elasticsearch.
That means:
- Read from the database (
SELECT * from TABLE
) - Convert each record to a JSON Document
- Send the json document to elasticsearch, preferably using the
_bulk
API.
Logstash can help for that (have a look at MongoDB Logstash Integration [Solved]). But I'd recommend modifying the application layer if possible and send data to elasticsearch in the same "transaction" as you are sending your data to the database.
I shared most of my thoughts there: Advanced Search for Your Legacy Application - -Xmx128gb -Xms128gb
Have also a look at this "live coding" recording.