Take a look at the "time to live"
_ttl field documentation .
You're reinserting all records every 30 minutes and the entire updation process perhaps takes 20 minutes.
So setting _ttl to 55 minutes would automatically purge any document that was not updated in the last reindexing, that is, one whose version has not increased between the reindexing cycles.