From 14a6743588712309914e13ea584299a5e71806fe Mon Sep 17 00:00:00 2001 From: Laura Trotta Date: Mon, 5 Oct 2026 10:35:18 +0000 Subject: [PATCH] [codegen] update to latest spec --- .../_types/query_dsl/KqlQuery.java | 278 ++++++++++++++++++ .../elasticsearch/_types/query_dsl/Query.java | 30 ++ .../_types/query_dsl/QueryBuilders.java | 16 + .../elasticsearch/doc-files/api-spec.html | 21 +- 4 files changed, 335 insertions(+), 10 deletions(-) create mode 100644 java-client/src/main/java/co/elastic/clients/elasticsearch/_types/query_dsl/KqlQuery.java diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/query_dsl/KqlQuery.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/query_dsl/KqlQuery.java new file mode 100644 index 0000000000..22ec6a6bf5 --- /dev/null +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/query_dsl/KqlQuery.java @@ -0,0 +1,278 @@ +/* + * 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._types.query_dsl; + +import co.elastic.clients.json.JsonpDeserializable; +import co.elastic.clients.json.JsonpDeserializer; +import co.elastic.clients.json.JsonpMapper; +import co.elastic.clients.json.ObjectBuilderDeserializer; +import co.elastic.clients.json.ObjectDeserializer; +import co.elastic.clients.util.ApiTypeHelper; +import co.elastic.clients.util.ObjectBuilder; +import jakarta.json.stream.JsonGenerator; +import java.lang.Boolean; +import java.lang.String; +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: _types.query_dsl.KqlQuery + +/** + * Returns documents matching a provided Kibana Query Language (KQL) expression. + * The expression is parsed and rewritten into standard Query DSL. + * + * @see API + * specification + */ +@JsonpDeserializable +public class KqlQuery extends QueryBase implements QueryVariant { + @Nullable + private final Boolean caseInsensitive; + + @Nullable + private final String defaultField; + + private final String query; + + @Nullable + private final String timeZone; + + // --------------------------------------------------------------------------------------------- + + private KqlQuery(Builder builder) { + super(builder); + + this.caseInsensitive = builder.caseInsensitive; + this.defaultField = builder.defaultField; + this.query = ApiTypeHelper.requireNonNull(builder.query, this, "query"); + this.timeZone = builder.timeZone; + + } + + public static KqlQuery of(Function> fn) { + return fn.apply(new Builder()).build(); + } + + /** + * Query variant kind. + */ + @Override + public Query.Kind _queryKind() { + return Query.Kind.Kql; + } + + /** + * If true, performs case-insensitive matching for field names and + * keyword or text terms. + *

+ * API name: {@code case_insensitive} + */ + @Nullable + public final Boolean caseInsensitive() { + return this.caseInsensitive; + } + + /** + * Default field, or field pattern with wildcards, to target when a bare term + * does not specify a field. Defaults to the + * index.query.default_field index setting, which has a default + * value of *. + *

+ * API name: {@code default_field} + */ + @Nullable + public final String defaultField() { + return this.defaultField; + } + + /** + * Required - The KQL expression to parse. + *

+ * API name: {@code query} + */ + public final String query() { + return this.query; + } + + /** + * Coordinated Universal Time (UTC) offset or IANA time zone used to interpret + * date literals in the expression. + *

+ * API name: {@code time_zone} + */ + @Nullable + public final String timeZone() { + return this.timeZone; + } + + protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { + + super.serializeInternal(generator, mapper); + if (this.caseInsensitive != null) { + generator.writeKey("case_insensitive"); + generator.write(this.caseInsensitive); + + } + if (this.defaultField != null) { + generator.writeKey("default_field"); + generator.write(this.defaultField); + + } + generator.writeKey("query"); + generator.write(this.query); + + if (this.timeZone != null) { + generator.writeKey("time_zone"); + generator.write(this.timeZone); + + } + + } + + // --------------------------------------------------------------------------------------------- + + /** + * Builder for {@link KqlQuery}. + */ + + public static class Builder extends QueryBase.AbstractBuilder implements ObjectBuilder { + @Nullable + private Boolean caseInsensitive; + + @Nullable + private String defaultField; + + private String query; + + @Nullable + private String timeZone; + + public Builder() { + } + private Builder(KqlQuery instance) { + this.caseInsensitive = instance.caseInsensitive; + this.defaultField = instance.defaultField; + this.query = instance.query; + this.timeZone = instance.timeZone; + + } + /** + * If true, performs case-insensitive matching for field names and + * keyword or text terms. + *

+ * API name: {@code case_insensitive} + */ + public final Builder caseInsensitive(@Nullable Boolean value) { + this.caseInsensitive = value; + return this; + } + + /** + * Default field, or field pattern with wildcards, to target when a bare term + * does not specify a field. Defaults to the + * index.query.default_field index setting, which has a default + * value of *. + *

+ * API name: {@code default_field} + */ + public final Builder defaultField(@Nullable String value) { + this.defaultField = value; + return this; + } + + /** + * Required - The KQL expression to parse. + *

+ * API name: {@code query} + */ + public final Builder query(String value) { + this.query = value; + return this; + } + + /** + * Coordinated Universal Time (UTC) offset or IANA time zone used to interpret + * date literals in the expression. + *

+ * API name: {@code time_zone} + */ + public final Builder timeZone(@Nullable String value) { + this.timeZone = value; + return this; + } + + @Override + protected Builder self() { + return this; + } + + /** + * Builds a {@link KqlQuery}. + * + * @throws NullPointerException + * if some of the required fields are null. + */ + public KqlQuery build() { + _checkSingleUse(); + + return new KqlQuery(this); + } + } + + /** + * @return New {@link Builder} initialized with field values of this instance + */ + public Builder rebuild() { + return new Builder(this); + } + // --------------------------------------------------------------------------------------------- + + /** + * Json deserializer for {@link KqlQuery} + */ + public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy(Builder::new, + KqlQuery::setupKqlQueryDeserializer); + + protected static void setupKqlQueryDeserializer(ObjectDeserializer op) { + QueryBase.setupQueryBaseDeserializer(op); + op.add(Builder::caseInsensitive, JsonpDeserializer.booleanDeserializer(), "case_insensitive"); + op.add(Builder::defaultField, JsonpDeserializer.stringDeserializer(), "default_field"); + op.add(Builder::query, JsonpDeserializer.stringDeserializer(), "query"); + op.add(Builder::timeZone, JsonpDeserializer.stringDeserializer(), "time_zone"); + + } + +} diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/query_dsl/Query.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/query_dsl/Query.java index d1f8186b59..db135901f8 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/query_dsl/Query.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/query_dsl/Query.java @@ -119,6 +119,8 @@ public enum Kind implements JsonEnum { Knn("knn"), + Kql("kql"), + Match("match"), MatchAll("match_all"), @@ -602,6 +604,23 @@ public KnnQuery knn() { return TaggedUnionUtils.get(this, Kind.Knn); } + /** + * Is this variant instance of kind {@code kql}? + */ + public boolean isKql() { + return _kind == Kind.Kql; + } + + /** + * Get the {@code kql} variant value. + * + * @throws IllegalStateException + * if the current variant is not of the {@code kql} kind. + */ + public KqlQuery kql() { + return TaggedUnionUtils.get(this, Kind.Kql); + } + /** * Is this variant instance of kind {@code match}? */ @@ -1569,6 +1588,16 @@ public ObjectBuilder knn(Function kql(KqlQuery v) { + this._kind = Kind.Kql; + this._value = v; + return this; + } + + public ObjectBuilder kql(Function> fn) { + return this.kql(fn.apply(new KqlQuery.Builder()).build()); + } + public ObjectBuilder match(MatchQuery v) { this._kind = Kind.Match; this._value = v; @@ -2038,6 +2067,7 @@ protected static void setupQueryDeserializer(ObjectDeserializer op) { op.add(Builder::ids, IdsQuery._DESERIALIZER, "ids"); op.add(Builder::intervals, IntervalsQuery._DESERIALIZER, "intervals"); op.add(Builder::knn, KnnQuery._DESERIALIZER, "knn"); + op.add(Builder::kql, KqlQuery._DESERIALIZER, "kql"); op.add(Builder::match, MatchQuery._DESERIALIZER, "match"); op.add(Builder::matchAll, MatchAllQuery._DESERIALIZER, "match_all"); op.add(Builder::matchBoolPrefix, MatchBoolPrefixQuery._DESERIALIZER, "match_bool_prefix"); diff --git a/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/query_dsl/QueryBuilders.java b/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/query_dsl/QueryBuilders.java index 3b1beb1511..7c4da70ca2 100644 --- a/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/query_dsl/QueryBuilders.java +++ b/java-client/src/main/java/co/elastic/clients/elasticsearch/_types/query_dsl/QueryBuilders.java @@ -389,6 +389,22 @@ public static Query knn(Function> fn) return builder.build(); } + /** + * Creates a builder for the {@link KqlQuery kql} {@code Query} variant. + */ + public static KqlQuery.Builder kql() { + return new KqlQuery.Builder(); + } + + /** + * Creates a Query of the {@link KqlQuery kql} {@code Query} variant. + */ + public static Query kql(Function> fn) { + Query.Builder builder = new Query.Builder(); + builder.kql(fn.apply(new KqlQuery.Builder()).build()); + return builder.build(); + } + /** * Creates a builder for the {@link MatchQuery match} {@code Query} variant. */ 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 948fa5ebf9..088b41ef12 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 @@ -968,9 +968,9 @@ '_types.query_dsl.BoolQuery': '_types/query_dsl/compound.ts#L29-L56', '_types.query_dsl.BoostingQuery': '_types/query_dsl/compound.ts#L58-L74', '_types.query_dsl.ChildScoreMode': '_types/query_dsl/joining.ts#L25-L39', -'_types.query_dsl.CombinedFieldsOperator': '_types/query_dsl/abstractions.ts#L513-L516', -'_types.query_dsl.CombinedFieldsQuery': '_types/query_dsl/abstractions.ts#L466-L500', -'_types.query_dsl.CombinedFieldsZeroTerms': '_types/query_dsl/abstractions.ts#L518-L527', +'_types.query_dsl.CombinedFieldsOperator': '_types/query_dsl/abstractions.ts#L522-L525', +'_types.query_dsl.CombinedFieldsQuery': '_types/query_dsl/abstractions.ts#L475-L509', +'_types.query_dsl.CombinedFieldsZeroTerms': '_types/query_dsl/abstractions.ts#L527-L536', '_types.query_dsl.CommonTermsQuery': '_types/query_dsl/fulltext.ts#L34-L44', '_types.query_dsl.ConstantScoreQuery': '_types/query_dsl/compound.ts#L76-L86', '_types.query_dsl.DateDecayFunction': '_types/query_dsl/compound.ts#L211-L211', @@ -983,8 +983,8 @@ '_types.query_dsl.DistanceFeatureQuery': '_types/query_dsl/specialized.ts#L76-L85', '_types.query_dsl.DistanceFeatureQueryBase': '_types/query_dsl/specialized.ts#L39-L59', '_types.query_dsl.ExistsQuery': '_types/query_dsl/term.ts#L37-L45', -'_types.query_dsl.FieldAndFormat': '_types/query_dsl/abstractions.ts#L529-L543', -'_types.query_dsl.FieldLookup': '_types/query_dsl/abstractions.ts#L430-L447', +'_types.query_dsl.FieldAndFormat': '_types/query_dsl/abstractions.ts#L538-L552', +'_types.query_dsl.FieldLookup': '_types/query_dsl/abstractions.ts#L439-L456', '_types.query_dsl.FieldValueFactorModifier': '_types/query_dsl/compound.ts#L331-L374', '_types.query_dsl.FieldValueFactorScoreFunction': '_types/query_dsl/compound.ts#L151-L170', '_types.query_dsl.FunctionBoostMode': '_types/query_dsl/compound.ts#L303-L329', @@ -1017,6 +1017,7 @@ '_types.query_dsl.IntervalsRange': '_types/query_dsl/fulltext.ts#L237-L264', '_types.query_dsl.IntervalsRegexp': '_types/query_dsl/fulltext.ts#L266-L281', '_types.query_dsl.IntervalsWildcard': '_types/query_dsl/fulltext.ts#L319-L334', +'_types.query_dsl.KqlQuery': '_types/query_dsl/KqlQuery.ts#L24-L48', '_types.query_dsl.Like': '_types/query_dsl/specialized.ts#L198-L203', '_types.query_dsl.LikeDocument': '_types/query_dsl/specialized.ts#L174-L196', '_types.query_dsl.LongNumberRangeQuery': '_types/query_dsl/term.ts#L170-L170', @@ -1038,8 +1039,8 @@ '_types.query_dsl.PinnedDoc': '_types/query_dsl/specialized.ts#L269-L278', '_types.query_dsl.PinnedQuery': '_types/query_dsl/specialized.ts#L247-L267', '_types.query_dsl.PrefixQuery': '_types/query_dsl/term.ts#L98-L120', -'_types.query_dsl.QueryBase': '_types/query_dsl/abstractions.ts#L453-L464', -'_types.query_dsl.QueryContainer': '_types/query_dsl/abstractions.ts#L97-L428', +'_types.query_dsl.QueryBase': '_types/query_dsl/abstractions.ts#L462-L473', +'_types.query_dsl.QueryContainer': '_types/query_dsl/abstractions.ts#L98-L437', '_types.query_dsl.QueryStringQuery': '_types/query_dsl/fulltext.ts#L650-L773', '_types.query_dsl.RandomScoreFunction': '_types/query_dsl/compound.ts#L145-L149', '_types.query_dsl.RangeQuery': '_types/query_dsl/term.ts#L174-L185', @@ -1086,7 +1087,7 @@ '_types.query_dsl.UntypedRangeQuery': '_types/query_dsl/term.ts#L146-L155', '_types.query_dsl.WeightedTokensQuery': '_types/query_dsl/WeightedTokensQuery.ts#L25-L33', '_types.query_dsl.WildcardQuery': '_types/query_dsl/term.ts#L304-L324', -'_types.query_dsl.WrapperQuery': '_types/query_dsl/abstractions.ts#L502-L511', +'_types.query_dsl.WrapperQuery': '_types/query_dsl/abstractions.ts#L511-L520', '_types.query_dsl.ZeroTermsQuery': '_types/query_dsl/fulltext.ts#L639-L648', 'async_search._types.AsyncSearch': 'async_search/_types/AsyncSearch.ts#L30-L56', 'async_search._types.AsyncSearchDocumentResponseBase': 'async_search/_types/AsyncSearchResponseBase.ts#L54-L58', @@ -3570,10 +3571,10 @@ if (hash.length > 1) { hash = hash.substring(1); } - window.location = "https://github.com/elastic/elasticsearch-specification/tree/ad07e24d224fcd526ebde387edfa4d9975684a21/specification/" + (paths[hash] || ""); + window.location = "https://github.com/elastic/elasticsearch-specification/tree/1fd90d0d3bddf481cce98d9127fa0f0718fbc5bb/specification/" + (paths[hash] || ""); - Please see the Elasticsearch API specification. + Please see the Elasticsearch API specification.