Description
Is your feature request related to a problem? Please describe.
As already mentioned in #154, the fact that _id
is a mandatory field for the API
, but since Elasticsearch 7.6 these parameters are not required anymore for create
and update
bulk operations. If someone wants to create a new document with a generated _id
, the API cannot be used.
Describe the solution you'd like
There are some alternatives available, I thing that all of them have pros and cons.
- Add methods to create
BulkCreateOperation
andBulkUpdateOperation
withoutid
. Something like:This can be seen as _strange, because you can find builder methods prefixed withimpl<B> BulkCreateOperation<B> { pub fn without_id<S>(source: S) -> Self { /* ... */} }
with_
, but not withwithout_
. - The same as before, but the methods are only available if a feature is available. This avoids the usage of the API with old versions of Elasticsearch server without noticing. On the other hand, this makes the code a bit harder to maintain.
- Use a feature to change the signature of
new
function forBulkCreateOperation
andBulkUpdateOperation
(and related fns onBulkOperation
). This is probably the most controversial solution, because, even if this cannot be considered a breaking change (a user must add a feature to break API compatibility), it is obviously not the best idea in term of semantic versioning. Moreover, this could be even more tricky than point 2 to maintain.
As you can see, I did not express a preference for a solution: I understand that the versioning policy in this case makes things difficult, and my desire is just a way to use the API. AFAIK, the only way in which I can rely on id
auto-generation is manually creating the body for create
bulk operations, making the current API partially unusable.
If you think my criticisms are valid, and we are able to choose a solution for a possible implementation (maybe even something different from my proposal), I will be happy to help with a PR.