I'm having a lot of version conflict when trying to updatebyquery with a painless script, even though the documents are not updated by anything else at the same time (my script is the only write on the cluster at this time).
Most of the documents that should be updated by this script are indexed a few minutes before by the same process (outside the cluster of course, in PHP), so I tried to call the refresh API before executing the updatebyquery, to be sure they are available for search. I think the refresh API does not wait for the refresh to finish to return, so I even test to add a sleep in my script after the refresh (2 min) to increase the chances of the refresh being finished.
Anyway, almost every time it's working on a lot of data, there is version conflicts. This makes no sense as the refresh seems to be finished and nothing else is indexing at the same time.
My script is updating a lot of fields and adding a nested entry on documents that are children of other docs (parents are not updated in this query), I don't know if this is relevant but I thought it might be linked in some way...
There is probably something I'm missing in how the updatebyquery works, so if anyone as a clue, it will be really appreciated.