Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

`rebuild()` of bulk operations (`IndexOperation`, `CreateOperation`, `UpdateOperation`) drops most fields

オープン
#1,353 コメント 1 件 リアクション 0 件 担当者 1 名 GitHub で見る

@l-trotta がすでに取り組んでいます。

2026年10月15日 から。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
50/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
elasticsearch, java
領域
api

調査の方向性

The bug is in the private Builder(IndexOperation), Builder(CreateOperation) and Builder(UpdateOperation) constructors, which copy too few fields. Those classes inherit from BulkOperationBase and WriteOperation, and the reproducer in the issue shows which properties go missing. The likely cause is the code generator, so check whether the fix belongs in the generated sources or in the generator. Done means op.rebuild().build() equals op for all three operation types, with the builder typed as Builder<TDocument>.

索引モデルが issue の本文から書いたものです。

説明

Area: Generator Category: Bug
Java API client version

9.5.4 (also current main)

Java version

25

Elasticsearch Version

9.5.4

Problem description

(full disclosure: analysis by copilot)

rebuild() should return a builder "initialized with field values of this instance". For the bulk operation classes it doesn't: most fields are lost.

Expected: op.rebuild().build() is equal to op.

Actual:

  • IndexOperation and CreateOperation: the private Builder(IndexOperation<TDocument> instance) / Builder(CreateOperation<TDocument> instance) constructors are empty. Nothing is copied:

    • fields inherited from BulkOperationBase: id, index, routing, ifSeqNo, ifPrimaryTerm, version, versionType;
    • fields inherited from WriteOperation: pipeline, requireAlias, dynamicTemplates;
    • their own fields: document and tDocumentSerializer.

    Because document is required, rebuild().build() throws a MissingRequiredPropertyException. If you set a new document first (for example .document(binaryData)), it builds without errors, but without _id, _index, routing and so on.

  • UpdateOperation: only requireAlias and retryOnConflict are copied. The inherited BulkOperationBase fields, action, binaryAction and the serializers are lost.

This looks like a code generator problem. Fields inherited from a generated base class are never copied, and neither are fields of the generic type parameter. Request classes without a base class, such as IndexRequest, copy their fields correctly.

Reproducer:

IndexOperation<Map<String, Object>> op = IndexOperation.of(b -> b
    .index("my-index")
    .id("1")
    .routing("r1")
    .ifSeqNo(5L)
    .ifPrimaryTerm(1L)
    .pipeline("my-pipeline")
    .document(Map.of("field", "value")));

// throws MissingRequiredPropertyException: Missing required property 'IndexOperation.document'
op.rebuild().build();

// builds without errors, but all values are lost
IndexOperation<?> copy = op.rebuild().document(Map.of("field", "value")).build();
System.out.println(copy.index());   // null, expected "my-index"
System.out.println(copy.id());      // null, expected "1"
System.out.println(copy.routing()); // null, expected "r1"
System.out.println(copy.pipeline()); // null, expected "my-pipeline"

CreateOperation behaves the same. For UpdateOperation, rebuild().build() does not throw, but only requireAlias and retryOnConflict are kept:

UpdateOperation<Object, Object> op = UpdateOperation.of(b -> b
    .index("my-index")
    .id("1")
    .routing("r1")
    .retryOnConflict(3)
    .action(a -> a.docAsUpsert(true)));

UpdateOperation<?, ?> copy = op.rebuild().build();
System.out.println(copy.index());           // null, expected "my-index"
System.out.println(copy.id());              // null, expected "1"
System.out.println(copy.routing());         // null, expected "r1"
System.out.println(copy.retryOnConflict()); // 3
System.out.println(copy.action());          // null

Context: I hit this in Spring Data Elasticsearch. Like the client's own BulkIngester, it needs to replace the document of an operation with a pre-serialized BinaryData so that it can measure its size. The obvious way is op.rebuild().document(binaryData).build(), but that silently drops _id and _index. So we copy all properties by hand, as IngesterOperation.copyIndexProperties() / copyBaseProperties() do.
see https://github.com/spring-projects/spring-data-elasticsearch/pull/3357

Note: rebuild() also returns the raw type Builder instead of Builder<TDocument>, so callers get unchecked warnings.

主要言語
Java
スター
525
フォーク
299
平均マージ
13時間 9分
マージ済み PR(30日)
5

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

elastic/elasticsearch-java のほかの issue

elastic/elasticsearch-java の issue をすべて見る

似ている issue

Java の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。