diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/_helpers/bulk/IngesterOperation.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/_helpers/bulk/IngesterOperation.java index 36d51642ca..2271a01c6d 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/_helpers/bulk/IngesterOperation.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/_helpers/bulk/IngesterOperation.java @@ -24,7 +24,9 @@ import co.elastic.clients.elasticsearch.core.bulk.CreateOperation; import co.elastic.clients.elasticsearch.core.bulk.DeleteOperation; import co.elastic.clients.elasticsearch.core.bulk.IndexOperation; +import co.elastic.clients.elasticsearch.core.bulk.UpdateAction; import co.elastic.clients.elasticsearch.core.bulk.UpdateOperation; +import co.elastic.clients.elasticsearch.core.bulk.WriteOperation; import co.elastic.clients.json.JsonEnum; import co.elastic.clients.json.JsonpMapper; import co.elastic.clients.util.BinaryData; @@ -83,11 +85,12 @@ public boolean canRetry() { return repeatableOp.canRetry(); } + @SuppressWarnings("unchecked") private static IngesterOperation createOperation(RetryableBulkOperation repeatableOp, JsonpMapper mapper) { CreateOperation create = repeatableOp.operation().create(); RetryableBulkOperation newOperation; - long size = basePropertiesSize(create); + long size = writePropertiesSize(create); if (create.document() instanceof BinaryData) { newOperation = repeatableOp; @@ -96,20 +99,20 @@ private static IngesterOperation createOperation(RetryableBul } else { BinaryData binaryDoc = BinaryData.of(create.document(), mapper); size += binaryDoc.size(); - newOperation = new RetryableBulkOperation<>(BulkOperation.of(bo -> bo.create(idx -> { - copyCreateProperties(create, idx); - return idx.document(binaryDoc); - })),repeatableOp.context(),repeatableOp.retries()); + newOperation = new RetryableBulkOperation<>( + BulkOperation.of(bo -> bo.create(create.rebuild().document(binaryDoc).build())), + repeatableOp.context(), repeatableOp.retries()); } return new IngesterOperation<>(newOperation, size); } + @SuppressWarnings("unchecked") private static IngesterOperation indexOperation(RetryableBulkOperation repeatableOp, JsonpMapper mapper) { IndexOperation index = repeatableOp.operation().index(); RetryableBulkOperation newOperation; - long size = basePropertiesSize(index); + long size = writePropertiesSize(index); if (index.document() instanceof BinaryData) { newOperation = repeatableOp; @@ -118,15 +121,15 @@ private static IngesterOperation indexOperation(RetryableBulk } else { BinaryData binaryDoc = BinaryData.of(index.document(), mapper); size += binaryDoc.size(); - newOperation = new RetryableBulkOperation<>(BulkOperation.of(bo -> bo.index(idx -> { - copyIndexProperties(index, idx); - return idx.document(binaryDoc); - })),repeatableOp.context(),repeatableOp.retries()); + newOperation = new RetryableBulkOperation<>( + BulkOperation.of(bo -> bo.index(index.rebuild().document(binaryDoc).build())), + repeatableOp.context(), repeatableOp.retries()); } return new IngesterOperation<>(newOperation, size); } + @SuppressWarnings("unchecked") private static IngesterOperation updateOperation(RetryableBulkOperation repeatableOp, JsonpMapper mapper) { UpdateOperation update = repeatableOp.operation().update(); RetryableBulkOperation newOperation; @@ -142,13 +145,9 @@ private static IngesterOperation updateOperation(RetryableBul } else { BinaryData action = BinaryData.of(update.action(), mapper); size += action.size(); - newOperation = new RetryableBulkOperation<>(BulkOperation.of(bo -> bo.update(u -> { - copyBaseProperties(update, u); - return u - .binaryAction(action) - .requireAlias(update.requireAlias()) - .retryOnConflict(update.retryOnConflict()); - })),repeatableOp.context(),repeatableOp.retries()); + newOperation = new RetryableBulkOperation<>( + BulkOperation.of(bo -> bo.update(update.rebuild().action((UpdateAction) null).binaryAction(action).build())), + repeatableOp.context(), repeatableOp.retries()); } return new IngesterOperation<>(newOperation, size); @@ -159,30 +158,6 @@ private static IngesterOperation deleteOperation(RetryableBul return new IngesterOperation<>(repeatableOp, basePropertiesSize(delete)); } - - private static void copyBaseProperties(BulkOperationBase op, BulkOperationBase.AbstractBuilder builder) { - builder - .id(op.id()) - .index(op.index()) - .ifPrimaryTerm(op.ifPrimaryTerm()) - .ifSeqNo(op.ifSeqNo()) - .routing(op.routing()) - .version(op.version()) - .versionType(op.versionType()); - } - - private static void copyIndexProperties(IndexOperation op, IndexOperation.Builder builder) { - copyBaseProperties(op, builder); - builder.pipeline(op.pipeline()); - builder.requireAlias(op.requireAlias()); - } - - private static void copyCreateProperties(CreateOperation op, CreateOperation.Builder builder) { - copyBaseProperties(op, builder); - builder.pipeline(op.pipeline()); - builder.requireAlias(op.requireAlias()); - } - private static int size(String name, @Nullable Boolean value) { if (value != null) { return name.length() + 12; // 12 added chars for "name":"false", @@ -257,4 +232,10 @@ private static int basePropertiesSize(BulkOperationBase op) { size("version_type", op.versionType()) + 4; // Open/closing brace, 2 newlines } + + private static int writePropertiesSize(WriteOperation op) { + return basePropertiesSize(op) + + size("pipeline", op.pipeline()) + + size("require_alias", op.requireAlias()); + } } diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/doc-files/api-spec.html b/java-client/src/main/java/co/elastic/clients/elasticsearch/doc-files/api-spec.html index eeb3897c2e..32ba79edeb 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/doc-files/api-spec.html +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/doc-files/api-spec.html @@ -1530,19 +1530,19 @@ 'graph.explore.Request': 'graph/explore/GraphExploreRequest.ts#L28-L87', 'graph.explore.Response': 'graph/explore/GraphExploreResponse.ts#L25-L33', 'ilm._types.Actions': 'ilm/_types/Phase.ts#L39-L93', -'ilm._types.AllocateAction': 'ilm/_types/Phase.ts#L151-L157', -'ilm._types.DeleteAction': 'ilm/_types/Phase.ts#L167-L169', +'ilm._types.AllocateAction': 'ilm/_types/Phase.ts#L162-L168', +'ilm._types.DeleteAction': 'ilm/_types/Phase.ts#L178-L180', 'ilm._types.DownsampleAction': 'ilm/_types/Phase.ts#L115-L118', 'ilm._types.ForceMergeAction': 'ilm/_types/Phase.ts#L126-L129', -'ilm._types.MigrateAction': 'ilm/_types/Phase.ts#L159-L161', +'ilm._types.MigrateAction': 'ilm/_types/Phase.ts#L170-L172', 'ilm._types.Phase': 'ilm/_types/Phase.ts#L26-L29', 'ilm._types.Phases': 'ilm/_types/Phase.ts#L31-L37', 'ilm._types.Policy': 'ilm/_types/Policy.ts#L23-L29', 'ilm._types.RolloverAction': 'ilm/_types/Phase.ts#L99-L113', -'ilm._types.SearchableSnapshotAction': 'ilm/_types/Phase.ts#L131-L149', +'ilm._types.SearchableSnapshotAction': 'ilm/_types/Phase.ts#L131-L160', 'ilm._types.SetPriorityAction': 'ilm/_types/Phase.ts#L95-L97', 'ilm._types.ShrinkAction': 'ilm/_types/Phase.ts#L120-L124', -'ilm._types.WaitForSnapshotAction': 'ilm/_types/Phase.ts#L163-L165', +'ilm._types.WaitForSnapshotAction': 'ilm/_types/Phase.ts#L174-L176', 'ilm.delete_lifecycle.Request': 'ilm/delete_lifecycle/DeleteLifecycleRequest.ts#L24-L60', 'ilm.delete_lifecycle.Response': 'ilm/delete_lifecycle/DeleteLifecycleResponse.ts#L22-L25', 'ilm.explain_lifecycle.LifecycleExplain': 'ilm/explain_lifecycle/types.ts#L75-L78', @@ -1573,7 +1573,8 @@ 'ilm.stop.Response': 'ilm/stop/StopIlmResponse.ts#L22-L25', 'indices._types.Alias': 'indices/_types/Alias.ts#L22-L52', 'indices._types.AliasDefinition': 'indices/_types/AliasDefinition.ts#L22-L54', -'indices._types.CacheQueries': 'indices/_types/IndexSettings.ts#L464-L466', +'indices._types.CacheQueries': 'indices/_types/IndexSettings.ts#L465-L467', +'indices._types.CacheRequests': 'indices/_types/IndexSettings.ts#L473-L481', 'indices._types.DataStream': 'indices/_types/DataStream.ts#L55-L151', 'indices._types.DataStreamFailureStore': 'indices/_types/DataStreamFailureStore.ts#L22-L37', 'indices._types.DataStreamFailureStoreTemplate': 'indices/_types/DataStreamFailureStore.ts#L39-L54', @@ -1591,7 +1592,7 @@ 'indices._types.FailureStoreLifecycle': 'indices/_types/DataStreamFailureStore.ts#L56-L72', 'indices._types.FailureStoreLifecycleTemplate': 'indices/_types/DataStreamFailureStore.ts#L74-L90', 'indices._types.FielddataFrequencyFilter': 'indices/_types/FielddataFrequencyFilter.ts#L22-L26', -'indices._types.IndexCheckOnStartup': 'indices/_types/IndexSettings.ts#L291-L298', +'indices._types.IndexCheckOnStartup': 'indices/_types/IndexSettings.ts#L292-L299', 'indices._types.IndexMode': 'indices/_types/DataStream.ts#L42-L47', 'indices._types.IndexRouting': 'indices/_types/IndexRouting.ts#L23-L26', 'indices._types.IndexRoutingAllocation': 'indices/_types/IndexRouting.ts#L28-L39', @@ -1602,71 +1603,72 @@ 'indices._types.IndexRoutingRebalance': 'indices/_types/IndexRouting.ts#L46-L48', 'indices._types.IndexRoutingRebalanceOptions': 'indices/_types/IndexRouting.ts#L57-L62', 'indices._types.IndexSegmentSort': 'indices/_types/IndexSegmentSort.ts#L22-L27', -'indices._types.IndexSettingBlocks': 'indices/_types/IndexSettings.ts#L272-L278', -'indices._types.IndexSettings': 'indices/_types/IndexSettings.ts#L71-L186', -'indices._types.IndexSettingsAnalysis': 'indices/_types/IndexSettings.ts#L368-L374', -'indices._types.IndexSettingsLifecycle': 'indices/_types/IndexSettings.ts#L305-L345', -'indices._types.IndexSettingsLifecycleStep': 'indices/_types/IndexSettings.ts#L347-L353', -'indices._types.IndexSettingsTimeSeries': 'indices/_types/IndexSettings.ts#L376-L387', -'indices._types.IndexSettingsUnassigned': 'indices/_types/IndexSettings.ts#L355-L357', -'indices._types.IndexSettingsUnassignedNodeLeft': 'indices/_types/IndexSettings.ts#L359-L366', +'indices._types.IndexSettingBlocks': 'indices/_types/IndexSettings.ts#L273-L279', +'indices._types.IndexSettings': 'indices/_types/IndexSettings.ts#L71-L187', +'indices._types.IndexSettingsAnalysis': 'indices/_types/IndexSettings.ts#L369-L375', +'indices._types.IndexSettingsLifecycle': 'indices/_types/IndexSettings.ts#L306-L346', +'indices._types.IndexSettingsLifecycleStep': 'indices/_types/IndexSettings.ts#L348-L354', +'indices._types.IndexSettingsTimeSeries': 'indices/_types/IndexSettings.ts#L377-L388', +'indices._types.IndexSettingsUnassigned': 'indices/_types/IndexSettings.ts#L356-L358', +'indices._types.IndexSettingsUnassignedNodeLeft': 'indices/_types/IndexSettings.ts#L360-L367', 'indices._types.IndexState': 'indices/_types/IndexState.ts#L27-L40', 'indices._types.IndexTemplate': 'indices/_types/IndexTemplate.ts#L34-L111', 'indices._types.IndexTemplateDataStreamConfiguration': 'indices/_types/IndexTemplate.ts#L113-L124', 'indices._types.IndexTemplateSummary': 'indices/_types/IndexTemplate.ts#L126-L153', 'indices._types.IndexTemplateSummaryWithRollover': 'indices/_types/IndexTemplate.ts#L155-L159', 'indices._types.IndexTemplateWithRollover': 'indices/_types/IndexTemplate.ts#L161-L163', -'indices._types.IndexVersioning': 'indices/_types/IndexSettings.ts#L300-L303', -'indices._types.IndexingPressure': 'indices/_types/IndexSettings.ts#L623-L625', -'indices._types.IndexingPressureMemory': 'indices/_types/IndexSettings.ts#L627-L634', -'indices._types.IndexingSlowlogSettings': 'indices/_types/IndexSettings.ts#L636-L641', -'indices._types.IndexingSlowlogTresholds': 'indices/_types/IndexSettings.ts#L643-L650', -'indices._types.IndicesBlockOptions': 'indices/_types/IndexSettings.ts#L280-L289', +'indices._types.IndexVersioning': 'indices/_types/IndexSettings.ts#L301-L304', +'indices._types.IndexingPressure': 'indices/_types/IndexSettings.ts#L638-L640', +'indices._types.IndexingPressureMemory': 'indices/_types/IndexSettings.ts#L642-L649', +'indices._types.IndexingSlowlogSettings': 'indices/_types/IndexSettings.ts#L651-L656', +'indices._types.IndexingSlowlogTresholds': 'indices/_types/IndexSettings.ts#L658-L665', +'indices._types.IndicesBlockOptions': 'indices/_types/IndexSettings.ts#L281-L290', 'indices._types.ManagedBy': 'indices/_types/DataStream.ts#L34-L39', -'indices._types.MappingLimitSettings': 'indices/_types/IndexSettings.ts#L468-L483', -'indices._types.MappingLimitSettingsDepth': 'indices/_types/IndexSettings.ts#L506-L513', -'indices._types.MappingLimitSettingsDimensionFields': 'indices/_types/IndexSettings.ts#L543-L549', -'indices._types.MappingLimitSettingsFieldNameLength': 'indices/_types/IndexSettings.ts#L534-L541', -'indices._types.MappingLimitSettingsNestedFields': 'indices/_types/IndexSettings.ts#L515-L523', -'indices._types.MappingLimitSettingsNestedObjects': 'indices/_types/IndexSettings.ts#L525-L532', -'indices._types.MappingLimitSettingsSourceFields': 'indices/_types/IndexSettings.ts#L551-L553', -'indices._types.MappingLimitSettingsTotalFields': 'indices/_types/IndexSettings.ts#L485-L504', -'indices._types.Merge': 'indices/_types/IndexSettings.ts#L389-L391', -'indices._types.MergeScheduler': 'indices/_types/IndexSettings.ts#L393-L396', +'indices._types.MappingLimitSettings': 'indices/_types/IndexSettings.ts#L483-L498', +'indices._types.MappingLimitSettingsDepth': 'indices/_types/IndexSettings.ts#L521-L528', +'indices._types.MappingLimitSettingsDimensionFields': 'indices/_types/IndexSettings.ts#L558-L564', +'indices._types.MappingLimitSettingsFieldNameLength': 'indices/_types/IndexSettings.ts#L549-L556', +'indices._types.MappingLimitSettingsNestedFields': 'indices/_types/IndexSettings.ts#L530-L538', +'indices._types.MappingLimitSettingsNestedObjects': 'indices/_types/IndexSettings.ts#L540-L547', +'indices._types.MappingLimitSettingsSourceFields': 'indices/_types/IndexSettings.ts#L566-L568', +'indices._types.MappingLimitSettingsTotalFields': 'indices/_types/IndexSettings.ts#L500-L519', +'indices._types.Merge': 'indices/_types/IndexSettings.ts#L390-L392', +'indices._types.MergeScheduler': 'indices/_types/IndexSettings.ts#L394-L397', 'indices._types.NumericFielddata': 'indices/_types/NumericFielddata.ts#L22-L24', 'indices._types.NumericFielddataFormat': 'indices/_types/NumericFielddataFormat.ts#L20-L23', -'indices._types.Queries': 'indices/_types/IndexSettings.ts#L460-L462', +'indices._types.Queries': 'indices/_types/IndexSettings.ts#L461-L463', +'indices._types.Requests': 'indices/_types/IndexSettings.ts#L469-L471', 'indices._types.RetentionLease': 'indices/_types/IndexSettings.ts#L67-L69', 'indices._types.RetentionSource': 'indices/_types/DataStreamLifecycle.ts#L67-L72', 'indices._types.SamplingMethod': 'indices/_types/Downsample.ts#L33-L36', -'indices._types.SearchIdle': 'indices/_types/IndexSettings.ts#L263-L266', +'indices._types.SearchIdle': 'indices/_types/IndexSettings.ts#L264-L267', 'indices._types.SegmentSortMissing': 'indices/_types/IndexSegmentSort.ts#L43-L46', 'indices._types.SegmentSortMode': 'indices/_types/IndexSegmentSort.ts#L36-L41', 'indices._types.SegmentSortOrder': 'indices/_types/IndexSegmentSort.ts#L29-L34', -'indices._types.SettingsAnalyze': 'indices/_types/IndexSettings.ts#L253-L256', -'indices._types.SettingsHighlight': 'indices/_types/IndexSettings.ts#L248-L251', -'indices._types.SettingsQueryString': 'indices/_types/IndexSettings.ts#L268-L270', -'indices._types.SettingsSearch': 'indices/_types/IndexSettings.ts#L258-L261', -'indices._types.SettingsSimilarity': 'indices/_types/IndexSettings.ts#L188-L200', -'indices._types.SettingsSimilarityBm25': 'indices/_types/IndexSettings.ts#L206-L211', -'indices._types.SettingsSimilarityBoolean': 'indices/_types/IndexSettings.ts#L202-L204', -'indices._types.SettingsSimilarityDfi': 'indices/_types/IndexSettings.ts#L213-L216', -'indices._types.SettingsSimilarityDfr': 'indices/_types/IndexSettings.ts#L218-L223', -'indices._types.SettingsSimilarityIb': 'indices/_types/IndexSettings.ts#L225-L230', -'indices._types.SettingsSimilarityLmd': 'indices/_types/IndexSettings.ts#L232-L235', -'indices._types.SettingsSimilarityLmj': 'indices/_types/IndexSettings.ts#L237-L240', -'indices._types.SettingsSimilarityScripted': 'indices/_types/IndexSettings.ts#L242-L246', -'indices._types.SlowlogSettings': 'indices/_types/IndexSettings.ts#L561-L566', -'indices._types.SlowlogTresholdLevels': 'indices/_types/IndexSettings.ts#L573-L578', -'indices._types.SlowlogTresholds': 'indices/_types/IndexSettings.ts#L568-L571', +'indices._types.SettingsAnalyze': 'indices/_types/IndexSettings.ts#L254-L257', +'indices._types.SettingsHighlight': 'indices/_types/IndexSettings.ts#L249-L252', +'indices._types.SettingsQueryString': 'indices/_types/IndexSettings.ts#L269-L271', +'indices._types.SettingsSearch': 'indices/_types/IndexSettings.ts#L259-L262', +'indices._types.SettingsSimilarity': 'indices/_types/IndexSettings.ts#L189-L201', +'indices._types.SettingsSimilarityBm25': 'indices/_types/IndexSettings.ts#L207-L212', +'indices._types.SettingsSimilarityBoolean': 'indices/_types/IndexSettings.ts#L203-L205', +'indices._types.SettingsSimilarityDfi': 'indices/_types/IndexSettings.ts#L214-L217', +'indices._types.SettingsSimilarityDfr': 'indices/_types/IndexSettings.ts#L219-L224', +'indices._types.SettingsSimilarityIb': 'indices/_types/IndexSettings.ts#L226-L231', +'indices._types.SettingsSimilarityLmd': 'indices/_types/IndexSettings.ts#L233-L236', +'indices._types.SettingsSimilarityLmj': 'indices/_types/IndexSettings.ts#L238-L241', +'indices._types.SettingsSimilarityScripted': 'indices/_types/IndexSettings.ts#L243-L247', +'indices._types.SlowlogSettings': 'indices/_types/IndexSettings.ts#L576-L581', +'indices._types.SlowlogTresholdLevels': 'indices/_types/IndexSettings.ts#L588-L593', +'indices._types.SlowlogTresholds': 'indices/_types/IndexSettings.ts#L583-L586', 'indices._types.SoftDeletes': 'indices/_types/IndexSettings.ts#L52-L65', -'indices._types.SourceMode': 'indices/_types/IndexSettings.ts#L555-L559', -'indices._types.Storage': 'indices/_types/IndexSettings.ts#L580-L591', -'indices._types.StorageType': 'indices/_types/IndexSettings.ts#L593-L621', +'indices._types.SourceMode': 'indices/_types/IndexSettings.ts#L570-L574', +'indices._types.Storage': 'indices/_types/IndexSettings.ts#L595-L606', +'indices._types.StorageType': 'indices/_types/IndexSettings.ts#L608-L636', 'indices._types.TemplateMapping': 'indices/_types/TemplateMapping.ts#L27-L34', -'indices._types.Translog': 'indices/_types/IndexSettings.ts#L398-L420', -'indices._types.TranslogDurability': 'indices/_types/IndexSettings.ts#L422-L437', -'indices._types.TranslogRetention': 'indices/_types/IndexSettings.ts#L439-L458', +'indices._types.Translog': 'indices/_types/IndexSettings.ts#L399-L421', +'indices._types.TranslogDurability': 'indices/_types/IndexSettings.ts#L423-L438', +'indices._types.TranslogRetention': 'indices/_types/IndexSettings.ts#L440-L459', 'indices.add_block.AddIndicesBlockStatus': 'indices/add_block/IndicesAddBlockResponse.ts#L30-L33', 'indices.add_block.Request': 'indices/add_block/IndicesAddBlockRequest.ts#L25-L96', 'indices.add_block.Response': 'indices/add_block/IndicesAddBlockResponse.ts#L22-L28', @@ -3574,10 +3576,10 @@ if (hash.length > 1) { hash = hash.substring(1); } - window.location = "https://github.com/elastic/elasticsearch-specification/tree/c947a13e96ea20d5a40c639f0b2bbd2a9f7790df/specification/" + (paths[hash] || ""); + window.location = "https://github.com/elastic/elasticsearch-specification/tree/84a2141415f45cd5078d0785c5686f801d479e6f/specification/" + (paths[hash] || ""); - Please see the Elasticsearch API specification. + Please see the Elasticsearch API specification. diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/ilm/SearchableSnapshotAction.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/ilm/SearchableSnapshotAction.java index 338973b577..545f2ec6ff 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/ilm/SearchableSnapshotAction.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/ilm/SearchableSnapshotAction.java @@ -68,6 +68,9 @@ public class SearchableSnapshotAction implements JsonpSerializable { @Nullable private final Boolean forceMergeIndex; + @Nullable + private final Boolean forceMergeOnClone; + @Nullable private final Integer totalShardsPerNode; @@ -80,6 +83,7 @@ private SearchableSnapshotAction(Builder builder) { this.snapshotRepository = ApiTypeHelper.requireNonNull(builder.snapshotRepository, this, "snapshotRepository"); this.forceMergeIndex = builder.forceMergeIndex; + this.forceMergeOnClone = builder.forceMergeOnClone; this.totalShardsPerNode = builder.totalShardsPerNode; this.replicateFor = builder.replicateFor; @@ -104,6 +108,20 @@ public final Boolean forceMergeIndex() { return this.forceMergeIndex; } + /** + * If true, and the index has replicas, ILM first clones the index + * with zero replicas and force merges the clone, so that replicas are not + * merged redundantly. If false, the managed index is force merged + * directly. Not allowed when force_merge_index is + * false. + *

+ * API name: {@code force_merge_on_clone} + */ + @Nullable + public final Boolean forceMergeOnClone() { + return this.forceMergeOnClone; + } + /** * The maximum number of shards, including primaries and replicas, that can be * allocated to any single node for the mounted index. Must be at least 1. @@ -148,6 +166,11 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { generator.writeKey("force_merge_index"); generator.write(this.forceMergeIndex); + } + if (this.forceMergeOnClone != null) { + generator.writeKey("force_merge_on_clone"); + generator.write(this.forceMergeOnClone); + } if (this.totalShardsPerNode != null) { generator.writeKey("total_shards_per_node"); @@ -181,6 +204,9 @@ public static class Builder extends WithJsonObjectBuilderBase @Nullable private Boolean forceMergeIndex; + @Nullable + private Boolean forceMergeOnClone; + @Nullable private Integer totalShardsPerNode; @@ -192,6 +218,7 @@ public Builder() { private Builder(SearchableSnapshotAction instance) { this.snapshotRepository = instance.snapshotRepository; this.forceMergeIndex = instance.forceMergeIndex; + this.forceMergeOnClone = instance.forceMergeOnClone; this.totalShardsPerNode = instance.totalShardsPerNode; this.replicateFor = instance.replicateFor; @@ -212,6 +239,20 @@ public final Builder forceMergeIndex(@Nullable Boolean value) { return this; } + /** + * If true, and the index has replicas, ILM first clones the index + * with zero replicas and force merges the clone, so that replicas are not + * merged redundantly. If false, the managed index is force merged + * directly. Not allowed when force_merge_index is + * false. + *

+ * API name: {@code force_merge_on_clone} + */ + public final Builder forceMergeOnClone(@Nullable Boolean value) { + this.forceMergeOnClone = value; + return this; + } + /** * The maximum number of shards, including primaries and replicas, that can be * allocated to any single node for the mounted index. Must be at least 1. @@ -289,6 +330,7 @@ protected static void setupSearchableSnapshotActionDeserializer( op.add(Builder::snapshotRepository, JsonpDeserializer.stringDeserializer(), "snapshot_repository"); op.add(Builder::forceMergeIndex, JsonpDeserializer.booleanDeserializer(), "force_merge_index"); + op.add(Builder::forceMergeOnClone, JsonpDeserializer.booleanDeserializer(), "force_merge_on_clone"); op.add(Builder::totalShardsPerNode, JsonpDeserializer.integerDeserializer(), "total_shards_per_node"); op.add(Builder::replicateFor, Time._DESERIALIZER, "replicate_for"); diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/indices/CacheRequests.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/indices/CacheRequests.java new file mode 100644 index 0000000000..3f370f4d0a --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/indices/CacheRequests.java @@ -0,0 +1,176 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package co.elastic.clients.elasticsearch.indices; + +import co.elastic.clients.json.JsonpDeserializable; +import co.elastic.clients.json.JsonpDeserializer; +import co.elastic.clients.json.JsonpMapper; +import co.elastic.clients.json.JsonpSerializable; +import co.elastic.clients.json.JsonpUtils; +import co.elastic.clients.json.ObjectBuilderDeserializer; +import co.elastic.clients.json.ObjectDeserializer; +import co.elastic.clients.util.ObjectBuilder; +import co.elastic.clients.util.WithJsonObjectBuilderBase; +import jakarta.json.stream.JsonGenerator; +import java.lang.Boolean; +import java.util.Objects; +import java.util.function.Function; +import javax.annotation.Nullable; + +//---------------------------------------------------------------- +// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. +//---------------------------------------------------------------- +// +// This code is generated from the Elasticsearch API specification +// at https://github.com/elastic/elasticsearch-specification +// +// Manual updates to this file will be lost when the code is +// re-generated. +// +// If you find a property that is missing or wrongly typed, please +// open an issue or a PR on the API specification repository. +// +//---------------------------------------------------------------- + +// typedef: indices._types.CacheRequests + +/** + * + * @see API + * specification + */ +@JsonpDeserializable +public class CacheRequests implements JsonpSerializable { + @Nullable + private final Boolean enable; + + // --------------------------------------------------------------------------------------------- + + private CacheRequests(Builder builder) { + + this.enable = builder.enable; + + } + + public static CacheRequests of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * Whether the shard request cache is enabled for the index. This setting is + * dynamic and can be updated on an existing index. + *

+ * API name: {@code enable} + */ + @Nullable + public final Boolean enable() { + return this.enable; + } + + /** + * Serialize this object to JSON. + */ + public void serialize(JsonGenerator generator, JsonpMapper mapper) { + generator.writeStartObject(); + serializeInternal(generator, mapper); + generator.writeEnd(); + } + + protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { + + if (this.enable != null) { + generator.writeKey("enable"); + generator.write(this.enable); + + } + + } + + @Override + public String toString() { + return JsonpUtils.toString(this); + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link CacheRequests}. + */ + + public static class Builder extends WithJsonObjectBuilderBase implements ObjectBuilder { + @Nullable + private Boolean enable; + + public Builder() { + } + private Builder(CacheRequests instance) { + this.enable = instance.enable; + + } + /** + * Whether the shard request cache is enabled for the index. This setting is + * dynamic and can be updated on an existing index. + *

+ * API name: {@code enable} + */ + public final Builder enable(@Nullable Boolean value) { + this.enable = value; + return this; + } + + @Override + protected Builder self() { + return this; + } + + /** + * Builds a {@link CacheRequests}. + * + * @throws NullPointerException + * if some of the required fields are null. + */ + public CacheRequests build() { + _checkSingleUse(); + + return new CacheRequests(this); + } + } + + /** + * @return New {@link Builder} initialized with field values of this instance + */ + public Builder rebuild() { + return new Builder(this); + } + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link CacheRequests} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy(Builder::new, + CacheRequests::setupCacheRequestsDeserializer); + + protected static void setupCacheRequestsDeserializer(ObjectDeserializer op) { + + op.add(Builder::enable, JsonpDeserializer.booleanDeserializer(), "enable"); + + } + +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/indices/IndexSettings.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/indices/IndexSettings.java index 5d4394eee8..78e86c8ddd 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/indices/IndexSettings.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/indices/IndexSettings.java @@ -230,6 +230,9 @@ public class IndexSettings implements JsonpSerializable { @Nullable private final Queries queries; + @Nullable + private final Requests requests; + private final Map similarity; @Nullable @@ -303,6 +306,7 @@ private IndexSettings(Builder builder) { this.settings = builder.settings; this.timeSeries = builder.timeSeries; this.queries = builder.queries; + this.requests = builder.requests; this.similarity = ApiTypeHelper.unmodifiable(builder.similarity); this.mapping = builder.mapping; this.indexingSlowlog = builder.indexingSlowlog; @@ -744,6 +748,14 @@ public final Queries queries() { return this.queries; } + /** + * API name: {@code requests} + */ + @Nullable + public final Requests requests() { + return this.requests; + } + /** * Configure custom similarity settings to customize how search results are * scored. @@ -1078,6 +1090,11 @@ else if (isExpNullAutoExpandReplicas) { generator.writeKey("queries"); this.queries.serialize(generator, mapper); + } + if (this.requests != null) { + generator.writeKey("requests"); + this.requests.serialize(generator, mapper); + } if (ApiTypeHelper.isDefined(this.similarity)) { generator.writeKey("similarity"); @@ -1312,6 +1329,9 @@ public final Builder otherSettings(String key, JsonData value) { @Nullable private Queries queries; + @Nullable + private Requests requests; + @Nullable private Map similarity; @@ -1383,6 +1403,7 @@ private Builder(IndexSettings instance) { this.settings = instance.settings; this.timeSeries = instance.timeSeries; this.queries = instance.queries; + this.requests = instance.requests; this.similarity = instance.similarity; this.mapping = instance.mapping; this.indexingSlowlog = instance.indexingSlowlog; @@ -1981,6 +2002,21 @@ public final Builder queries(Function> f return this.queries(fn.apply(new Queries.Builder()).build()); } + /** + * API name: {@code requests} + */ + public final Builder requests(@Nullable Requests value) { + this.requests = value; + return this; + } + + /** + * API name: {@code requests} + */ + public final Builder requests(Function> fn) { + return this.requests(fn.apply(new Requests.Builder()).build()); + } + /** * Configure custom similarity settings to customize how search results are * scored. @@ -2183,6 +2219,7 @@ protected static void setupIndexSettingsDeserializer(ObjectDeserializerAPI + * specification + */ +@JsonpDeserializable +public class Requests implements JsonpSerializable { + @Nullable + private final CacheRequests cache; + + // --------------------------------------------------------------------------------------------- + + private Requests(Builder builder) { + + this.cache = builder.cache; + + } + + public static Requests of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * API name: {@code cache} + */ + @Nullable + public final CacheRequests cache() { + return this.cache; + } + + /** + * Serialize this object to JSON. + */ + public void serialize(JsonGenerator generator, JsonpMapper mapper) { + generator.writeStartObject(); + serializeInternal(generator, mapper); + generator.writeEnd(); + } + + protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { + + if (this.cache != null) { + generator.writeKey("cache"); + this.cache.serialize(generator, mapper); + + } + + } + + @Override + public String toString() { + return JsonpUtils.toString(this); + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link Requests}. + */ + + public static class Builder extends WithJsonObjectBuilderBase implements ObjectBuilder { + @Nullable + private CacheRequests cache; + + public Builder() { + } + private Builder(Requests instance) { + this.cache = instance.cache; + + } + /** + * API name: {@code cache} + */ + public final Builder cache(@Nullable CacheRequests value) { + this.cache = value; + return this; + } + + /** + * API name: {@code cache} + */ + public final Builder cache(Function> fn) { + return this.cache(fn.apply(new CacheRequests.Builder()).build()); + } + + @Override + protected Builder self() { + return this; + } + + /** + * Builds a {@link Requests}. + * + * @throws NullPointerException + * if some of the required fields are null. + */ + public Requests build() { + _checkSingleUse(); + + return new Requests(this); + } + } + + /** + * @return New {@link Builder} initialized with field values of this instance + */ + public Builder rebuild() { + return new Builder(this); + } + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link Requests} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy(Builder::new, + Requests::setupRequestsDeserializer); + + protected static void setupRequestsDeserializer(ObjectDeserializer op) { + + op.add(Builder::cache, CacheRequests._DESERIALIZER, "cache"); + + } + +} diff --git a/java-client/src/test/java/co/elastic/clients/elasticsearch/_helpers/bulk/BulkIngesterTest.java b/java-client/src/test/java/co/elastic/clients/elasticsearch/_helpers/bulk/BulkIngesterTest.java index 106417b071..c463b6ec50 100644 --- a/java-client/src/test/java/co/elastic/clients/elasticsearch/_helpers/bulk/BulkIngesterTest.java +++ b/java-client/src/test/java/co/elastic/clients/elasticsearch/_helpers/bulk/BulkIngesterTest.java @@ -22,11 +22,13 @@ import co.elastic.clients.elasticsearch.ElasticsearchAsyncClient; import co.elastic.clients.elasticsearch.ElasticsearchClient; import co.elastic.clients.elasticsearch.ElasticsearchTestServer; +import co.elastic.clients.elasticsearch._types.VersionType; import co.elastic.clients.elasticsearch.core.BulkRequest; import co.elastic.clients.elasticsearch.core.BulkResponse; import co.elastic.clients.elasticsearch.core.bulk.BulkOperation; import co.elastic.clients.elasticsearch.core.bulk.BulkResponseItem; import co.elastic.clients.elasticsearch.core.bulk.OperationType; +import co.elastic.clients.elasticsearch.core.bulk.UpdateOperation; import co.elastic.clients.elasticsearch.end_to_end.RequestTest; import co.elastic.clients.elasticsearch.indices.IndicesStatsResponse; import co.elastic.clients.json.JsonpMapper; @@ -458,6 +460,76 @@ public void pipelineTest() { assertEquals(json, create1Str); } + @Test + public void sizeIncludesPropertiesTest() { + JsonpMapper mapper = new SimpleJsonpMapper(); + + BulkOperation plain = BulkOperation.of(o -> o.index(i -> i.index("some_idx").document("Some doc"))); + long plainSize = IngesterOperation.of(new RetryableBulkOperation<>(plain, null, null), mapper).size(); + + List withProperty = List.of( + BulkOperation.of(o -> o.index(i -> i.index("some_idx").pipeline("pipe").document("Some doc"))), + BulkOperation.of(o -> o.index(i -> i.index("some_idx").requireAlias(true).document("Some doc"))), + BulkOperation.of(o -> o.create(c -> c.index("some_idx").pipeline("pipe").document("Some doc"))), + BulkOperation.of(o -> o.create(c -> c.index("some_idx").requireAlias(true).document("Some doc"))) + ); + + for (BulkOperation op : withProperty) { + long size = IngesterOperation.of(new RetryableBulkOperation<>(op, null, null), mapper).size(); + assertTrue(size > plainSize, JsonpUtils.toJsonString(op, mapper)); + } + } + + @Test + public void allPropertiesKeptTest() { + JsonpMapper mapper = new SimpleJsonpMapper(); + + BulkOperation index = BulkOperation.of(o -> o.index(i -> i + .index("some_idx") + .id("some_id") + .routing("r") + .ifSeqNo(1L) + .ifPrimaryTerm(2L) + .version(3L) + .versionType(VersionType.External) + .dynamicTemplates("field", "template") + .pipeline("pipe") + .requireAlias(true) + .document("Some doc") + )); + + BulkOperation create = BulkOperation.of(o -> o.create(c -> c + .index("some_idx") + .id("some_id") + .version(3L) + .versionType(VersionType.External) + .dynamicTemplates("field", "template") + .pipeline("pipe") + .document("Some doc") + )); + + BulkOperation update = BulkOperation.of(o -> o.update(u -> u + .index("some_idx") + .id("some_id") + .ifSeqNo(1L) + .ifPrimaryTerm(2L) + .retryOnConflict(3) + .requireAlias(true) + .action(a -> a.doc("Some doc")) + )); + + for (BulkOperation op : List.of(index, create, update)) { + BulkOperation ingested = IngesterOperation.of(new RetryableBulkOperation<>(op, null, null), mapper) + .repeatableOperation().operation(); + assertEquals(JsonpUtils.toJsonString(op, mapper), JsonpUtils.toJsonString(ingested, mapper)); + } + + UpdateOperation ingestedUpdate = IngesterOperation.of(new RetryableBulkOperation<>(update, null, null), mapper) + .repeatableOperation().operation().update(); + assertNull(ingestedUpdate.action()); + assertNotNull(ingestedUpdate.binaryAction()); + } + @Test public void endToEndTest() throws Exception { String index = "bulk-ingester-test";