Skip to content

[ENHANCEMENT] Add methods for BulkCreateOperation/BulkUpdateOperation without _id #174

Closed
@dodomorandi

Description

@dodomorandi

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.

  1. Add methods to create BulkCreateOperation and BulkUpdateOperation without id. Something like:
    impl<B> BulkCreateOperation<B> {
        pub fn without_id<S>(source: S) -> Self { /* ... */}
    }
    This can be seen as _strange, because you can find builder methods prefixed with with_, but not with without_.
  2. 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.
  3. Use a feature to change the signature of new function for BulkCreateOperation and BulkUpdateOperation (and related fns on BulkOperation). 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions