Support Update By Query with slices auto
https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-update-by-query.html#docs-update-by-query-slice According to the doc, we should be able to use the value auto with the param slices
@Philippus I don't understand the error on the scala-2_12 CI. Can you help me?
Actually, it partially breaks compatibility because I assume most of people use the DSL
def slices(slices: Int): UpdateByQueryRequest = copy(slices = Some(NumericSlices(slices))).
We can also add an implicit conversion Int -> Slices in the scope to avoid breaking changes.
The drawback having 2 different params for the slices is that a user can use both in same time, so which one should we keep? It can be confusing.
What do you think?
We can add a new parameter like numericOrAutoSlices: Option[Slices] = None and deprecate the old parameter. The new parameter should take precedence over the deprecated one. The methods then can look like this:
def slices(slices: Int): ReindexRequest = copy(numericOrAutoSlices = NumericSlices(slices).some)
def slicesAuto(): ReindexRequest = copy(numericOrAutoSlices = AutoSlices.some)
and in the handlers we could do something like this:
request.numericOrAutoSlices.foreach {
case AutoSlices => params.put("slices", "auto")
case NumericSlices(slices) => params.put("slices", slices.toString)
}
if (request.numericOrAutoSlices.isEmpty)
request.slices.foreach(params.put("slices", _))
I'll merge this PR, and create a follow-up to change the api a bit as I described but numericOrAutoSlices will probably become slicing to keep it a bit shorter.