Synchronize entity ids before flushing documents