Use of wait_until for deleteByQuery in java rest client

If you don't perform the delete by query very frequently then you can just set refresh to true and not worry about the tiny segments you end up with. If the delete by query is very large you can set refresh to true and because the delete is already quite expensive compared to the refresh.

If the delete by query is fairly small and fairly frequent then you shouldn't set refresh to true. And you can't set it to wait_for. If that's you it's worth opening an issue.

If you wanted to do the whole scroll/bulk delete thing yourself you could. We did it by hand back in the old days. If you put refresh=wait_for on the bulk requests it'd wait for each one to become visible.

But if you have many bulk requests you'd be waiting a while after each one. It isn't safe to just set refresh=wait_for on the last one. It'll mostly work, but bulk only waits on the shards it touches. If the last bulk doesn't include a shard then we won't wait for it. OTOH if you have a couple of thousand element bulks you may as well perform an explicit refresh after they are all done. And that is what delete by query does when you set refresh to true.