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 bab70b489..36f57117a 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 @@ -133,17 +133,17 @@ '_global.search._types.AggregationProfileDelegateDebugFilter': '_global/search/_types/profile.ts#L68-L72', '_global.search._types.BoundaryScanner': '_global/search/_types/highlighting.ts#L26-L30', '_global.search._types.Collector': '_global/search/_types/profile.ts#L83-L88', -'_global.search._types.CompletionContext': '_global/search/_types/suggester.ts#L150-L157', -'_global.search._types.CompletionSuggest': '_global/search/_types/suggester.ts#L48-L53', -'_global.search._types.CompletionSuggestOption': '_global/search/_types/suggester.ts#L71-L82', -'_global.search._types.CompletionSuggester': '_global/search/_types/suggester.ts#L125-L131', -'_global.search._types.Context': '_global/search/_types/suggester.ts#L143-L148', -'_global.search._types.DirectGenerator': '_global/search/_types/suggester.ts#L161-L173', +'_global.search._types.CompletionContext': '_global/search/_types/suggester.ts#L152-L159', +'_global.search._types.CompletionSuggest': '_global/search/_types/suggester.ts#L48-L55', +'_global.search._types.CompletionSuggestOption': '_global/search/_types/suggester.ts#L73-L84', +'_global.search._types.CompletionSuggester': '_global/search/_types/suggester.ts#L127-L133', +'_global.search._types.Context': '_global/search/_types/suggester.ts#L145-L150', +'_global.search._types.DirectGenerator': '_global/search/_types/suggester.ts#L163-L175', '_global.search._types.FetchProfile': '_global/search/_types/profile.ts#L136-L143', '_global.search._types.FetchProfileBreakdown': '_global/search/_types/profile.ts#L145-L152', '_global.search._types.FetchProfileDebug': '_global/search/_types/profile.ts#L154-L157', '_global.search._types.FieldCollapse': '_global/search/_types/FieldCollapse.ts#L24-L29', -'_global.search._types.FieldSuggester': '_global/search/_types/suggester.ts#L101-L115', +'_global.search._types.FieldSuggester': '_global/search/_types/suggester.ts#L103-L117', '_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#L87-L90', @@ -156,15 +156,15 @@ '_global.search._types.HitsMetadata': '_global/search/_types/hits.ts#L62-L68', '_global.search._types.InnerHits': '_global/search/_types/hits.ts#L102-L120', '_global.search._types.InnerHitsResult': '_global/search/_types/hits.ts#L80-L82', -'_global.search._types.LaplaceSmoothingModel': '_global/search/_types/suggester.ts#L207-L209', -'_global.search._types.LinearInterpolationSmoothingModel': '_global/search/_types/suggester.ts#L211-L215', +'_global.search._types.LaplaceSmoothingModel': '_global/search/_types/suggester.ts#L209-L211', +'_global.search._types.LinearInterpolationSmoothingModel': '_global/search/_types/suggester.ts#L213-L217', '_global.search._types.NestedIdentity': '_global/search/_types/hits.ts#L84-L88', -'_global.search._types.PhraseSuggest': '_global/search/_types/suggester.ts#L55-L60', -'_global.search._types.PhraseSuggestCollate': '_global/search/_types/suggester.ts#L175-L179', -'_global.search._types.PhraseSuggestCollateQuery': '_global/search/_types/suggester.ts#L181-L184', -'_global.search._types.PhraseSuggestHighlight': '_global/search/_types/suggester.ts#L202-L205', -'_global.search._types.PhraseSuggestOption': '_global/search/_types/suggester.ts#L84-L88', -'_global.search._types.PhraseSuggester': '_global/search/_types/suggester.ts#L186-L200', +'_global.search._types.PhraseSuggest': '_global/search/_types/suggester.ts#L57-L62', +'_global.search._types.PhraseSuggestCollate': '_global/search/_types/suggester.ts#L177-L181', +'_global.search._types.PhraseSuggestCollateQuery': '_global/search/_types/suggester.ts#L183-L186', +'_global.search._types.PhraseSuggestHighlight': '_global/search/_types/suggester.ts#L204-L207', +'_global.search._types.PhraseSuggestOption': '_global/search/_types/suggester.ts#L86-L90', +'_global.search._types.PhraseSuggester': '_global/search/_types/suggester.ts#L188-L202', '_global.search._types.PointInTimeReference': '_global/search/_types/PointInTimeReference.ts#L23-L26', '_global.search._types.Profile': '_global/search/_types/profile.ts#L90-L92', '_global.search._types.QueryBreakdown': '_global/search/_types/profile.ts#L94-L113', @@ -174,21 +174,21 @@ '_global.search._types.ScoreMode': '_global/search/_types/rescoring.ts#L36-L42', '_global.search._types.SearchProfile': '_global/search/_types/profile.ts#L123-L127', '_global.search._types.ShardProfile': '_global/search/_types/profile.ts#L129-L134', -'_global.search._types.SmoothingModelContainer': '_global/search/_types/suggester.ts#L219-L226', +'_global.search._types.SmoothingModelContainer': '_global/search/_types/suggester.ts#L221-L228', '_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#L234-L240', -'_global.search._types.StupidBackoffSmoothingModel': '_global/search/_types/suggester.ts#L228-L230', +'_global.search._types.StringDistance': '_global/search/_types/suggester.ts#L236-L242', +'_global.search._types.StupidBackoffSmoothingModel': '_global/search/_types/suggester.ts#L230-L232', '_global.search._types.Suggest': '_global/search/_types/suggester.ts#L34-L40', '_global.search._types.SuggestBase': '_global/search/_types/suggester.ts#L42-L46', -'_global.search._types.SuggestFuzziness': '_global/search/_types/suggester.ts#L133-L139', -'_global.search._types.SuggestSort': '_global/search/_types/suggester.ts#L242-L245', -'_global.search._types.Suggester': '_global/search/_types/suggester.ts#L96-L99', -'_global.search._types.SuggesterBase': '_global/search/_types/suggester.ts#L117-L121', -'_global.search._types.TermSuggest': '_global/search/_types/suggester.ts#L62-L67', -'_global.search._types.TermSuggestOption': '_global/search/_types/suggester.ts#L90-L94', -'_global.search._types.TermSuggester': '_global/search/_types/suggester.ts#L247-L260', +'_global.search._types.SuggestFuzziness': '_global/search/_types/suggester.ts#L135-L141', +'_global.search._types.SuggestSort': '_global/search/_types/suggester.ts#L244-L247', +'_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#L64-L69', +'_global.search._types.TermSuggestOption': '_global/search/_types/suggester.ts#L92-L96', +'_global.search._types.TermSuggester': '_global/search/_types/suggester.ts#L249-L262', '_global.search._types.TotalHits': '_global/search/_types/hits.ts#L90-L93', '_global.search._types.TotalHitsRelation': '_global/search/_types/hits.ts#L95-L100', '_global.search._types.TrackHits': '_global/search/_types/hits.ts#L122-L130', @@ -2509,10 +2509,10 @@ if (hash.length > 1) { hash = hash.substring(1); } - window.location = "https://github.com/elastic/elasticsearch-specification/tree/135ae054e304239743b5777ad8d41cb2c9091d35/specification/" + (paths[hash] || ""); + window.location = "https://github.com/elastic/elasticsearch-specification/tree/1ac08ee3f920b0193b0983146af077cbd4cadc1e/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 6b9826b35..40ff99348 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 @@ -27,13 +27,16 @@ import co.elastic.clients.elasticsearch.core.SearchResponse; 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.json.JsonData; import co.elastic.clients.json.JsonpDeserializer; import jakarta.json.stream.JsonParser; +import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import java.io.InputStream; +import java.io.StringReader; /** * Test issues related to the API specifications. @@ -42,6 +45,28 @@ */ 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 i066_multiFieldMapping() throws Exception { ElasticsearchClient client = ElasticsearchTestServer.global().client();