Are you aware about the fact that upgrading nopCommerce may break plugins? - I am not sure why you want to build up the plugin with nopcommerce 3.70. Now it is time to use nopcommerce 4.0- there may arise issue on upgrading the nopcommerce version. I am suggesting you to build up the plug in with nopcommece 4.0. What to say?
In case of update elastic search data from database, the search index should be updated with new entries, deletions and changes made to the database. Isn't it?- This be easily managed by Feeder Process.
First, I will retrieve all product_hashes from Elasticsearch. I will create and store hashes ourselves and use them to quickly see if a product has changed. We compare hashes stored in the search index with hashes computed from the products in the database. This saves the overhead of retrieving complete documents.
Next I will iterate over all the products in the database and compute new hashes. If the hash is not present in the product_hashes it means the product is new or has been updated: I will index it. Afterwards, I take all the product hashes that I did not encounter (these represent deleted products) and delete them from index.
To obtain data from database,I will define a simple model for a data. the cache-rows method returns a hash of the respective data attributes.
I will create a class which implements IPlugin interface. nopCommerce has BasePlugin class which already implements some IPlugin methods, allow to avoid source code duplication.