I have an use case where Mongo DB is my primary data store and search API needs to connect to elasticsearch for getting the list of inventory.
I need to have real time sync between elasticsearch and mongo db for two scenarios.
Scenario:1 : New items gets added to existing inventory (This is relatively easy to solve. I will have a management api that will do concurrent update to Mongo and elasticsearch, so records will be consistent across both)
Scenario:2: Items are limited in an inventory, example 10 items in an inventory and with each purchase count decreases so it rises the condition of realtime update of mongodb and elasticsearch. Say there is a sync difference of 1 min, which means that even if all the items are sold out for some specific inventory, that record be picked up by the search query until next sync, and users will get stale deals in that 1 mins sync delay.