diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/analysis/MappingCharFilter.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/analysis/MappingCharFilter.java index 02d7f2304..ea69ce323 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/analysis/MappingCharFilter.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/analysis/MappingCharFilter.java @@ -57,7 +57,7 @@ public class MappingCharFilter extends CharFilterBase implements CharFilterDefin private MappingCharFilter(Builder builder) { super(builder); - this.mappings = ApiTypeHelper.unmodifiableRequired(builder.mappings, this, "mappings"); + this.mappings = ApiTypeHelper.unmodifiable(builder.mappings); this.mappingsPath = builder.mappingsPath; } @@ -75,7 +75,7 @@ public CharFilterDefinition.Kind _charFilterDefinitionKind() { } /** - * Required - API name: {@code mappings} + * API name: {@code mappings} */ public final List mappings() { return this.mappings; @@ -120,13 +120,14 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { public static class Builder extends CharFilterBase.AbstractBuilder implements ObjectBuilder { + @Nullable private List mappings; @Nullable private String mappingsPath; /** - * Required - API name: {@code mappings} + * API name: {@code mappings} *

* Adds all elements of list to mappings. */ @@ -136,7 +137,7 @@ public final Builder mappings(List list) { } /** - * Required - API name: {@code mappings} + * API name: {@code mappings} *

* Adds one or more values to mappings. */ diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/core/search/PhraseSuggest.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/core/search/PhraseSuggest.java index 8259e8ed0..ff242d49c 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/core/search/PhraseSuggest.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/core/search/PhraseSuggest.java @@ -31,6 +31,7 @@ import co.elastic.clients.util.ApiTypeHelper; import co.elastic.clients.util.ObjectBuilder; import jakarta.json.stream.JsonGenerator; +import java.util.List; import java.util.Objects; import java.util.function.Function; import javax.annotation.Nullable; @@ -45,14 +46,14 @@ */ @JsonpDeserializable public class PhraseSuggest extends SuggestBase implements SuggestionVariant { - private final PhraseSuggestOption options; + private final List options; // --------------------------------------------------------------------------------------------- private PhraseSuggest(Builder builder) { super(builder); - this.options = ApiTypeHelper.requireNonNull(builder.options, this, "options"); + this.options = ApiTypeHelper.unmodifiableRequired(builder.options, this, "options"); } @@ -71,15 +72,23 @@ public Suggestion.Kind _suggestionKind() { /** * Required - API name: {@code options} */ - public final PhraseSuggestOption options() { + public final List options() { return this.options; } protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { super.serializeInternal(generator, mapper); - generator.writeKey("options"); - this.options.serialize(generator, mapper); + if (ApiTypeHelper.isDefined(this.options)) { + generator.writeKey("options"); + generator.writeStartArray(); + for (PhraseSuggestOption item0 : this.options) { + item0.serialize(generator, mapper); + + } + generator.writeEnd(); + + } } @@ -90,21 +99,35 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { */ public static class Builder extends SuggestBase.AbstractBuilder implements ObjectBuilder { - private PhraseSuggestOption options; + private List options; + + /** + * Required - API name: {@code options} + *

+ * Adds all elements of list to options. + */ + public final Builder options(List list) { + this.options = _listAddAll(this.options, list); + return this; + } /** * Required - API name: {@code options} + *

+ * Adds one or more values to options. */ - public final Builder options(PhraseSuggestOption value) { - this.options = value; + public final Builder options(PhraseSuggestOption value, PhraseSuggestOption... values) { + this.options = _listAdd(this.options, value, values); return this; } /** * Required - API name: {@code options} + *

+ * Adds a value to options using a builder lambda. */ public final Builder options(Function> fn) { - return this.options(fn.apply(new PhraseSuggestOption.Builder()).build()); + return options(fn.apply(new PhraseSuggestOption.Builder()).build()); } @Override @@ -135,7 +158,7 @@ public PhraseSuggest build() { protected static void setupPhraseSuggestDeserializer(ObjectDeserializer op) { SuggestBase.setupSuggestBaseDeserializer(op); - op.add(Builder::options, PhraseSuggestOption._DESERIALIZER, "options"); + op.add(Builder::options, JsonpDeserializer.arrayDeserializer(PhraseSuggestOption._DESERIALIZER), "options"); } diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/core/search/TermSuggest.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/core/search/TermSuggest.java index c397b4683..c4811738f 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/core/search/TermSuggest.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/core/search/TermSuggest.java @@ -31,6 +31,7 @@ import co.elastic.clients.util.ApiTypeHelper; import co.elastic.clients.util.ObjectBuilder; import jakarta.json.stream.JsonGenerator; +import java.util.List; import java.util.Objects; import java.util.function.Function; import javax.annotation.Nullable; @@ -45,14 +46,14 @@ */ @JsonpDeserializable public class TermSuggest extends SuggestBase implements SuggestionVariant { - private final TermSuggestOption options; + private final List options; // --------------------------------------------------------------------------------------------- private TermSuggest(Builder builder) { super(builder); - this.options = ApiTypeHelper.requireNonNull(builder.options, this, "options"); + this.options = ApiTypeHelper.unmodifiableRequired(builder.options, this, "options"); } @@ -71,15 +72,23 @@ public Suggestion.Kind _suggestionKind() { /** * Required - API name: {@code options} */ - public final TermSuggestOption options() { + public final List options() { return this.options; } protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { super.serializeInternal(generator, mapper); - generator.writeKey("options"); - this.options.serialize(generator, mapper); + if (ApiTypeHelper.isDefined(this.options)) { + generator.writeKey("options"); + generator.writeStartArray(); + for (TermSuggestOption item0 : this.options) { + item0.serialize(generator, mapper); + + } + generator.writeEnd(); + + } } @@ -90,21 +99,35 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { */ public static class Builder extends SuggestBase.AbstractBuilder implements ObjectBuilder { - private TermSuggestOption options; + private List options; + + /** + * Required - API name: {@code options} + *

+ * Adds all elements of list to options. + */ + public final Builder options(List list) { + this.options = _listAddAll(this.options, list); + return this; + } /** * Required - API name: {@code options} + *

+ * Adds one or more values to options. */ - public final Builder options(TermSuggestOption value) { - this.options = value; + public final Builder options(TermSuggestOption value, TermSuggestOption... values) { + this.options = _listAdd(this.options, value, values); return this; } /** * Required - API name: {@code options} + *

+ * Adds a value to options using a builder lambda. */ public final Builder options(Function> fn) { - return this.options(fn.apply(new TermSuggestOption.Builder()).build()); + return options(fn.apply(new TermSuggestOption.Builder()).build()); } @Override @@ -135,7 +158,7 @@ public TermSuggest build() { protected static void setupTermSuggestDeserializer(ObjectDeserializer op) { SuggestBase.setupSuggestBaseDeserializer(op); - op.add(Builder::options, TermSuggestOption._DESERIALIZER, "options"); + op.add(Builder::options, JsonpDeserializer.arrayDeserializer(TermSuggestOption._DESERIALIZER), "options"); } 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 12bb497d5..c7bfa89e3 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 @@ -132,17 +132,17 @@ '_global.search._types.BoundaryScanner': '_global/search/_types/highlighting.ts#L26-L30', '_global.search._types.BuiltinHighlighterType': '_global/search/_types/highlighting.ts#L82-L87', '_global.search._types.Collector': '_global/search/_types/profile.ts#L85-L90', -'_global.search._types.CompletionContext': '_global/search/_types/suggester.ts#L153-L160', -'_global.search._types.CompletionSuggest': '_global/search/_types/suggester.ts#L49-L54', -'_global.search._types.CompletionSuggestOption': '_global/search/_types/suggester.ts#L72-L84', -'_global.search._types.CompletionSuggester': '_global/search/_types/suggester.ts#L127-L133', -'_global.search._types.Context': '_global/search/_types/suggester.ts#L145-L151', -'_global.search._types.DirectGenerator': '_global/search/_types/suggester.ts#L164-L176', +'_global.search._types.CompletionContext': '_global/search/_types/suggester.ts#L155-L162', +'_global.search._types.CompletionSuggest': '_global/search/_types/suggester.ts#L49-L56', +'_global.search._types.CompletionSuggestOption': '_global/search/_types/suggester.ts#L74-L86', +'_global.search._types.CompletionSuggester': '_global/search/_types/suggester.ts#L129-L135', +'_global.search._types.Context': '_global/search/_types/suggester.ts#L147-L153', +'_global.search._types.DirectGenerator': '_global/search/_types/suggester.ts#L166-L178', '_global.search._types.FetchProfile': '_global/search/_types/profile.ts#L138-L145', '_global.search._types.FetchProfileBreakdown': '_global/search/_types/profile.ts#L147-L154', '_global.search._types.FetchProfileDebug': '_global/search/_types/profile.ts#L156-L159', '_global.search._types.FieldCollapse': '_global/search/_types/FieldCollapse.ts#L24-L28', -'_global.search._types.FieldSuggester': '_global/search/_types/suggester.ts#L103-L117', +'_global.search._types.FieldSuggester': '_global/search/_types/suggester.ts#L105-L119', '_global.search._types.Highlight': '_global/search/_types/highlighting.ts#L56-L59', '_global.search._types.HighlightBase': '_global/search/_types/highlighting.ts#L32-L54', '_global.search._types.HighlightField': '_global/search/_types/highlighting.ts#L89-L92', @@ -155,15 +155,15 @@ '_global.search._types.HitsMetadata': '_global/search/_types/hits.ts#L66-L72', '_global.search._types.InnerHits': '_global/search/_types/hits.ts#L107-L125', '_global.search._types.InnerHitsResult': '_global/search/_types/hits.ts#L85-L87', -'_global.search._types.LaplaceSmoothingModel': '_global/search/_types/suggester.ts#L210-L212', -'_global.search._types.LinearInterpolationSmoothingModel': '_global/search/_types/suggester.ts#L214-L218', +'_global.search._types.LaplaceSmoothingModel': '_global/search/_types/suggester.ts#L212-L214', +'_global.search._types.LinearInterpolationSmoothingModel': '_global/search/_types/suggester.ts#L216-L220', '_global.search._types.NestedIdentity': '_global/search/_types/hits.ts#L89-L93', -'_global.search._types.PhraseSuggest': '_global/search/_types/suggester.ts#L56-L61', -'_global.search._types.PhraseSuggestCollate': '_global/search/_types/suggester.ts#L178-L182', -'_global.search._types.PhraseSuggestCollateQuery': '_global/search/_types/suggester.ts#L184-L187', -'_global.search._types.PhraseSuggestHighlight': '_global/search/_types/suggester.ts#L205-L208', -'_global.search._types.PhraseSuggestOption': '_global/search/_types/suggester.ts#L86-L90', -'_global.search._types.PhraseSuggester': '_global/search/_types/suggester.ts#L189-L203', +'_global.search._types.PhraseSuggest': '_global/search/_types/suggester.ts#L58-L63', +'_global.search._types.PhraseSuggestCollate': '_global/search/_types/suggester.ts#L180-L184', +'_global.search._types.PhraseSuggestCollateQuery': '_global/search/_types/suggester.ts#L186-L189', +'_global.search._types.PhraseSuggestHighlight': '_global/search/_types/suggester.ts#L207-L210', +'_global.search._types.PhraseSuggestOption': '_global/search/_types/suggester.ts#L88-L92', +'_global.search._types.PhraseSuggester': '_global/search/_types/suggester.ts#L191-L205', '_global.search._types.PointInTimeReference': '_global/search/_types/PointInTimeReference.ts#L23-L26', '_global.search._types.Profile': '_global/search/_types/profile.ts#L92-L94', '_global.search._types.QueryBreakdown': '_global/search/_types/profile.ts#L96-L115', @@ -173,21 +173,21 @@ '_global.search._types.ScoreMode': '_global/search/_types/rescoring.ts#L36-L42', '_global.search._types.SearchProfile': '_global/search/_types/profile.ts#L125-L129', '_global.search._types.ShardProfile': '_global/search/_types/profile.ts#L131-L136', -'_global.search._types.SmoothingModelContainer': '_global/search/_types/suggester.ts#L222-L229', +'_global.search._types.SmoothingModelContainer': '_global/search/_types/suggester.ts#L224-L231', '_global.search._types.SourceConfig': '_global/search/_types/SourceFilter.ts#L33-L37', '_global.search._types.SourceConfigParam': '_global/search/_types/SourceFilter.ts#L39-L45', '_global.search._types.SourceFilter': '_global/search/_types/SourceFilter.ts#L23-L31', -'_global.search._types.StringDistance': '_global/search/_types/suggester.ts#L237-L243', -'_global.search._types.StupidBackoffSmoothingModel': '_global/search/_types/suggester.ts#L231-L233', +'_global.search._types.StringDistance': '_global/search/_types/suggester.ts#L239-L245', +'_global.search._types.StupidBackoffSmoothingModel': '_global/search/_types/suggester.ts#L233-L235', '_global.search._types.Suggest': '_global/search/_types/suggester.ts#L35-L41', '_global.search._types.SuggestBase': '_global/search/_types/suggester.ts#L43-L47', -'_global.search._types.SuggestFuzziness': '_global/search/_types/suggester.ts#L135-L141', -'_global.search._types.SuggestSort': '_global/search/_types/suggester.ts#L245-L248', -'_global.search._types.Suggester': '_global/search/_types/suggester.ts#L98-L101', -'_global.search._types.SuggesterBase': '_global/search/_types/suggester.ts#L119-L123', -'_global.search._types.TermSuggest': '_global/search/_types/suggester.ts#L63-L68', -'_global.search._types.TermSuggestOption': '_global/search/_types/suggester.ts#L92-L96', -'_global.search._types.TermSuggester': '_global/search/_types/suggester.ts#L250-L263', +'_global.search._types.SuggestFuzziness': '_global/search/_types/suggester.ts#L137-L143', +'_global.search._types.SuggestSort': '_global/search/_types/suggester.ts#L247-L250', +'_global.search._types.Suggester': '_global/search/_types/suggester.ts#L100-L103', +'_global.search._types.SuggesterBase': '_global/search/_types/suggester.ts#L121-L125', +'_global.search._types.TermSuggest': '_global/search/_types/suggester.ts#L65-L70', +'_global.search._types.TermSuggestOption': '_global/search/_types/suggester.ts#L94-L98', +'_global.search._types.TermSuggester': '_global/search/_types/suggester.ts#L252-L265', '_global.search._types.TotalHits': '_global/search/_types/hits.ts#L95-L98', '_global.search._types.TotalHitsRelation': '_global/search/_types/hits.ts#L100-L105', '_global.search._types.TrackHits': '_global/search/_types/hits.ts#L127-L135', @@ -2323,10 +2323,10 @@ if (hash.length > 1) { hash = hash.substring(1); } - window.location = "https://github.com/elastic/elasticsearch-specification/tree/cda51c1e6118ea3ba2bb973b77fbf5dc32badebc/specification/" + (paths[hash] || ""); + window.location = "https://github.com/elastic/elasticsearch-specification/tree/984c21945c71f1a658355803d43a7add2dac7265/specification/" + (paths[hash] || ""); - Please see the Elasticsearch API specification. + Please see the Elasticsearch API specification. diff --git a/java-client/src/test/java/co/elastic/clients/elasticsearch/spec_issues/SpecIssuesTest.java b/java-client/src/test/java/co/elastic/clients/elasticsearch/spec_issues/SpecIssuesTest.java index ab9b94c35..6ae3c6227 100644 --- a/java-client/src/test/java/co/elastic/clients/elasticsearch/spec_issues/SpecIssuesTest.java +++ b/java-client/src/test/java/co/elastic/clients/elasticsearch/spec_issues/SpecIssuesTest.java @@ -29,6 +29,7 @@ import co.elastic.clients.elasticsearch.indices.CreateIndexRequest; import co.elastic.clients.elasticsearch.indices.GetFieldMappingRequest; import co.elastic.clients.elasticsearch.indices.GetFieldMappingResponse; +import co.elastic.clients.elasticsearch.indices.IndexSettings; import co.elastic.clients.elasticsearch.model.ModelTestCase; import co.elastic.clients.elasticsearch.snapshot.RestoreResponse; import co.elastic.clients.json.JsonData; @@ -47,6 +48,27 @@ */ public class SpecIssuesTest extends ModelTestCase { + @Test + public void i0328_charFilter() throws Exception { + // Both mappings and mappings_path are optional + String json = + "{\n" + + " \"analysis\": { \n" + + " \"char_filter\": {\n" + + " \"multi_char_filter\": {\n" + + " \"type\": \"mapping\",\n" + +// " \"mappings\": [\n" + +// " \"xyz => xyz\"\n" + +// " ],\n" + + " \"mappings_path\": \"analysis/multi-char-replacement.txt\"\n" + + " }\n" + + " }\n" + + " }\n" + + "}"; + + IndexSettings.of(b -> b.withJson(new StringReader(json))); + } + @Disabled("Not fixed yet") @Test public void i0201_restoreResponse() throws Exception {