I would like to get an advice on how to deal with document visibility if I need to update a document soon after I add it.
My code writes many documents into a rolling index and a few min later update them with updateByQuery with additional info (I use updateByQuery since the rolling index may roll between calls). In some cases the update is too fast and the document is not visible so fail to update it. What should be the best practice in this case?
What do you think will be the best practice in this case?
unfortunately, there's no magic solution here due to your use case
the best bet is to use option 2 - ?wait_for
. there is a performance impact, but then you know for sure that you have consistency for your next operations
alternatively, maybe there's a different architecture you can use. but that would require understanding more information on your use case, and probably put into another question