From aa96041ab887f60b725136b83ca9c2020b9faf51 Mon Sep 17 00:00:00 2001 From: Chris Danisch Date: Wed, 4 Sep 2024 09:16:07 -0700 Subject: [PATCH 1/3] Fixes https://github.com/opensearch-project/opensearch-java/issues/1172 Calling `toBuilder` on classes which implement `QueryBase` will now preserve `boost` and `queryName`. Signed-off-by: Chris Danisch --- CHANGELOG.md | 1 + .../opensearch/_types/query_dsl/BoolQuery.java | 8 +++++++- .../opensearch/_types/query_dsl/BoostingQuery.java | 2 +- .../_types/query_dsl/CombinedFieldsQuery.java | 4 +++- .../_types/query_dsl/CommonTermsQuery.java | 4 +++- .../_types/query_dsl/ConstantScoreQuery.java | 2 +- .../opensearch/_types/query_dsl/DisMaxQuery.java | 2 +- .../_types/query_dsl/DistanceFeatureQuery.java | 2 +- .../opensearch/_types/query_dsl/ExistsQuery.java | 2 +- .../_types/query_dsl/FunctionScoreQuery.java | 4 +++- .../opensearch/_types/query_dsl/FuzzyQuery.java | 4 +++- .../_types/query_dsl/GeoBoundingBoxQuery.java | 4 +++- .../_types/query_dsl/GeoDistanceQuery.java | 2 +- .../opensearch/_types/query_dsl/GeoShapeQuery.java | 2 +- .../opensearch/_types/query_dsl/HasChildQuery.java | 4 +++- .../opensearch/_types/query_dsl/HasParentQuery.java | 8 +++++++- .../opensearch/_types/query_dsl/HybridQuery.java | 2 +- .../client/opensearch/_types/query_dsl/IdsQuery.java | 2 +- .../opensearch/_types/query_dsl/IntervalsQuery.java | 2 +- .../client/opensearch/_types/query_dsl/KnnQuery.java | 2 +- .../_types/query_dsl/MatchBoolPrefixQuery.java | 4 +++- .../_types/query_dsl/MatchPhrasePrefixQuery.java | 4 +++- .../_types/query_dsl/MatchPhraseQuery.java | 8 +++++++- .../opensearch/_types/query_dsl/MatchQuery.java | 4 +++- .../_types/query_dsl/MoreLikeThisQuery.java | 4 +++- .../opensearch/_types/query_dsl/MultiMatchQuery.java | 4 +++- .../opensearch/_types/query_dsl/NestedQuery.java | 8 +++++++- .../opensearch/_types/query_dsl/NeuralQuery.java | 9 ++++++++- .../opensearch/_types/query_dsl/ParentIdQuery.java | 2 +- .../opensearch/_types/query_dsl/PercolateQuery.java | 4 +++- .../opensearch/_types/query_dsl/PinnedQuery.java | 2 +- .../opensearch/_types/query_dsl/PrefixQuery.java | 8 +++++++- .../_types/query_dsl/QueryStringQuery.java | 4 +++- .../opensearch/_types/query_dsl/RangeQuery.java | 12 +++++++++++- .../_types/query_dsl/RankFeatureQuery.java | 8 +++++++- .../opensearch/_types/query_dsl/RegexpQuery.java | 4 +++- .../opensearch/_types/query_dsl/ScriptQuery.java | 2 +- .../_types/query_dsl/ScriptScoreQuery.java | 2 +- .../_types/query_dsl/SimpleQueryStringQuery.java | 4 +++- .../_types/query_dsl/SpanContainingQuery.java | 2 +- .../_types/query_dsl/SpanFieldMaskingQuery.java | 2 +- .../opensearch/_types/query_dsl/SpanFirstQuery.java | 2 +- .../_types/query_dsl/SpanMultiTermQuery.java | 2 +- .../opensearch/_types/query_dsl/SpanNearQuery.java | 2 +- .../opensearch/_types/query_dsl/SpanNotQuery.java | 2 +- .../opensearch/_types/query_dsl/SpanOrQuery.java | 2 +- .../opensearch/_types/query_dsl/SpanTermQuery.java | 2 +- .../opensearch/_types/query_dsl/SpanWithinQuery.java | 2 +- .../opensearch/_types/query_dsl/TermQuery.java | 2 +- .../opensearch/_types/query_dsl/TermsQuery.java | 2 +- .../opensearch/_types/query_dsl/TermsSetQuery.java | 4 +++- .../opensearch/_types/query_dsl/TypeQuery.java | 2 +- .../opensearch/_types/query_dsl/WildcardQuery.java | 9 ++++++++- .../opensearch/_types/query_dsl/WrapperQuery.java | 2 +- .../opensearch/_types/query_dsl/XyShapeQuery.java | 2 +- ...oostringQueryTest.java => BoostingQueryTest.java} | 2 +- .../opensearch/_types/query_dsl/MatchQueryTest.java | 2 +- 57 files changed, 149 insertions(+), 56 deletions(-) rename java-client/src/test/java/org/opensearch/client/opensearch/_types/query_dsl/{BoostringQueryTest.java => BoostingQueryTest.java} (94%) diff --git a/CHANGELOG.md b/CHANGELOG.md index 661fe4f9be..4cdc06f158 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,6 +29,7 @@ This section is for maintaining a changelog for all breaking changes for the cli ### Fixed - Fix version and build ([#254](https://github.com/opensearch-project/opensearch-java/pull/254)) +- Fix queries not preserving boost and name when converted to builders ### Security diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/BoolQuery.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/BoolQuery.java index d8d4a6f915..19582b652a 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/BoolQuery.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/BoolQuery.java @@ -172,7 +172,13 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { } public Builder toBuilder() { - return new Builder().filter(filter).minimumShouldMatch(minimumShouldMatch).must(must).mustNot(mustNot).should(should); + return new Builder().queryName(queryName()) + .boost(boost()) + .filter(filter) + .minimumShouldMatch(minimumShouldMatch) + .must(must) + .mustNot(mustNot) + .should(should); } // --------------------------------------------------------------------------------------------- diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/BoostingQuery.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/BoostingQuery.java index 4aa7ed3a2a..e1fbd1d333 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/BoostingQuery.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/BoostingQuery.java @@ -111,7 +111,7 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { } public Builder toBuilder() { - return new Builder().negativeBoost(negativeBoost).negative(negative).positive(positive); + return new Builder().queryName(queryName()).boost(boost()).negativeBoost(negativeBoost).negative(negative).positive(positive); } // --------------------------------------------------------------------------------------------- diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/CombinedFieldsQuery.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/CombinedFieldsQuery.java index 35c8571c36..b23fd579b7 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/CombinedFieldsQuery.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/CombinedFieldsQuery.java @@ -174,7 +174,9 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { } public Builder toBuilder() { - return new Builder().fields(fields) + return new Builder().queryName(queryName()) + .boost(boost()) + .fields(fields) .query(query) .autoGenerateSynonymsPhraseQuery(autoGenerateSynonymsPhraseQuery) .operator(operator) diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/CommonTermsQuery.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/CommonTermsQuery.java index e0bd23f71d..c9f2fa459b 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/CommonTermsQuery.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/CommonTermsQuery.java @@ -183,7 +183,9 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { } public Builder toBuilder() { - return new Builder().field(field) + return new Builder().queryName(queryName()) + .boost(boost()) + .field(field) .analyzer(analyzer) .cutoffFrequency(cutoffFrequency) .highFreqOperator(highFreqOperator) diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/ConstantScoreQuery.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/ConstantScoreQuery.java index a958275eb5..c7c8584bb0 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/ConstantScoreQuery.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/ConstantScoreQuery.java @@ -85,7 +85,7 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { } public Builder toBuilder() { - return new Builder().filter(filter); + return new Builder().queryName(queryName()).boost(boost()).filter(filter); } // --------------------------------------------------------------------------------------------- diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/DisMaxQuery.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/DisMaxQuery.java index f03de385e9..992a8e38ba 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/DisMaxQuery.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/DisMaxQuery.java @@ -112,7 +112,7 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { } public Builder toBuilder() { - return new Builder().queries(queries).tieBreaker(tieBreaker); + return new Builder().queryName(queryName()).boost(boost()).queries(queries).tieBreaker(tieBreaker); } // --------------------------------------------------------------------------------------------- diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/DistanceFeatureQuery.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/DistanceFeatureQuery.java index 781c750ebf..bbabab152f 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/DistanceFeatureQuery.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/DistanceFeatureQuery.java @@ -112,7 +112,7 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { } public Builder toBuilder() { - return new Builder().origin(origin).pivot(pivot).field(field); + return new Builder().queryName(queryName()).boost(boost()).origin(origin).pivot(pivot).field(field); } // --------------------------------------------------------------------------------------------- diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/ExistsQuery.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/ExistsQuery.java index 1a5b8f0e8c..dda35daf5e 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/ExistsQuery.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/ExistsQuery.java @@ -85,7 +85,7 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { } public Builder toBuilder() { - return new Builder().field(field); + return new Builder().queryName(queryName()).boost(boost()).field(field); } // --------------------------------------------------------------------------------------------- diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/FunctionScoreQuery.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/FunctionScoreQuery.java index 34124bbaa8..e29f6a5914 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/FunctionScoreQuery.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/FunctionScoreQuery.java @@ -178,7 +178,9 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { } public Builder toBuilder() { - return new Builder().boostMode(boostMode) + return new Builder().queryName(queryName()) + .boost(boost()) + .boostMode(boostMode) .functions(functions) .maxBoost(maxBoost) .minScore(minScore) diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/FuzzyQuery.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/FuzzyQuery.java index 91fc3b1a66..2e35f8a47a 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/FuzzyQuery.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/FuzzyQuery.java @@ -186,7 +186,9 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { } public Builder toBuilder() { - return new Builder().field(field) + return new Builder().queryName(queryName()) + .boost(boost()) + .field(field) .value(value) .maxExpansions(maxExpansions) .prefixLength(prefixLength) diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/GeoBoundingBoxQuery.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/GeoBoundingBoxQuery.java index 272ab31a7e..166ef9b0b7 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/GeoBoundingBoxQuery.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/GeoBoundingBoxQuery.java @@ -149,7 +149,9 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { } public Builder toBuilder() { - return new Builder().field(field) + return new Builder().queryName(queryName()) + .boost(boost()) + .field(field) .boundingBox(boundingBox) .type(type) .validationMethod(validationMethod) diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/GeoDistanceQuery.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/GeoDistanceQuery.java index 31b14157bb..ce781186aa 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/GeoDistanceQuery.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/GeoDistanceQuery.java @@ -147,7 +147,7 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { } public Builder toBuilder() { - return new Builder().field(field).location(location); + return new Builder().queryName(queryName()).boost(boost()).field(field).location(location); } // --------------------------------------------------------------------------------------------- diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/GeoShapeQuery.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/GeoShapeQuery.java index 0047aaac67..15a77d4d8b 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/GeoShapeQuery.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/GeoShapeQuery.java @@ -113,7 +113,7 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { } public Builder toBuilder() { - return new Builder().field(field).shape(shape); + return new Builder().queryName(queryName()).boost(boost()).field(field).shape(shape); } // --------------------------------------------------------------------------------------------- diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/HasChildQuery.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/HasChildQuery.java index 2e2cdd1cf1..c5314b0359 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/HasChildQuery.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/HasChildQuery.java @@ -184,7 +184,9 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { } public Builder toBuilder() { - return new Builder().ignoreUnmapped(ignoreUnmapped) + return new Builder().queryName(queryName()) + .boost(boost()) + .ignoreUnmapped(ignoreUnmapped) .innerHits(innerHits) .maxChildren(maxChildren) .minChildren(minChildren) diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/HasParentQuery.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/HasParentQuery.java index 4019246161..d3fa6d0bc4 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/HasParentQuery.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/HasParentQuery.java @@ -152,7 +152,13 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { } public Builder toBuilder() { - return new Builder().ignoreUnmapped(ignoreUnmapped).innerHits(innerHits).parentType(parentType).query(query).score(score); + return new Builder().queryName(queryName()) + .boost(boost()) + .ignoreUnmapped(ignoreUnmapped) + .innerHits(innerHits) + .parentType(parentType) + .query(query) + .score(score); } // --------------------------------------------------------------------------------------------- diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/HybridQuery.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/HybridQuery.java index 932cbb93d6..1e20cf9462 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/HybridQuery.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/HybridQuery.java @@ -56,7 +56,7 @@ public Query.Kind _queryKind() { } public HybridQuery.Builder toBuilder() { - return new HybridQuery.Builder().queries(queries); + return new HybridQuery.Builder().queryName(queryName()).boost(boost()).queries(queries); } public static class Builder extends QueryBase.AbstractBuilder implements ObjectBuilder { diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/IdsQuery.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/IdsQuery.java index 687158d529..0799fb5519 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/IdsQuery.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/IdsQuery.java @@ -95,7 +95,7 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { } public Builder toBuilder() { - return new Builder().values(values); + return new Builder().queryName(queryName()).boost(boost()).values(values); } // --------------------------------------------------------------------------------------------- diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/IntervalsQuery.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/IntervalsQuery.java index d5c655db15..d13b9e6523 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/IntervalsQuery.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/IntervalsQuery.java @@ -252,7 +252,7 @@ public void serialize(JsonGenerator generator, JsonpMapper mapper) { } public Builder toBuilder() { - return new Builder()._kind(_kind)._value(_value).field(field); + return new Builder().queryName(queryName()).boost(boost())._kind(_kind)._value(_value).field(field); } public static class Builder extends QueryBase.AbstractBuilder implements ObjectBuilder { diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/KnnQuery.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/KnnQuery.java index 175fe6e11a..89a02bf5ee 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/KnnQuery.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/KnnQuery.java @@ -108,7 +108,7 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { } public Builder toBuilder() { - return new Builder().field(field).vector(vector).k(k).filter(filter); + return new Builder().queryName(queryName()).boost(boost()).field(field).vector(vector).k(k).filter(filter); } /** diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/MatchBoolPrefixQuery.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/MatchBoolPrefixQuery.java index b370342728..ba2571a34c 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/MatchBoolPrefixQuery.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/MatchBoolPrefixQuery.java @@ -235,7 +235,9 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { } public Builder toBuilder() { - return new Builder().field(field) + return new Builder().queryName(queryName()) + .boost(boost()) + .field(field) .analyzer(analyzer) .fuzziness(fuzziness) .fuzzyRewrite(fuzzyRewrite) diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/MatchPhrasePrefixQuery.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/MatchPhrasePrefixQuery.java index bba0cf42f7..2c568ba401 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/MatchPhrasePrefixQuery.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/MatchPhrasePrefixQuery.java @@ -168,7 +168,9 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { } public Builder toBuilder() { - return new Builder().field(field) + return new Builder().queryName(queryName()) + .boost(boost()) + .field(field) .analyzer(analyzer) .maxExpansions(maxExpansions) .query(query) diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/MatchPhraseQuery.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/MatchPhraseQuery.java index 2e7ac94bec..953a0d31a2 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/MatchPhraseQuery.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/MatchPhraseQuery.java @@ -151,7 +151,13 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { } public Builder toBuilder() { - return new Builder().field(field).analyzer(analyzer).query(query).slop(slop).zeroTermsQuery(zeroTermsQuery); + return new Builder().queryName(queryName()) + .boost(boost()) + .field(field) + .analyzer(analyzer) + .query(query) + .slop(slop) + .zeroTermsQuery(zeroTermsQuery); } // --------------------------------------------------------------------------------------------- diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/MatchQuery.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/MatchQuery.java index cab702a5b2..346ad19d19 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/MatchQuery.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/MatchQuery.java @@ -307,7 +307,9 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { } public Builder toBuilder() { - return new Builder().field(field) + return new Builder().queryName(queryName()) + .boost(boost()) + .field(field) .analyzer(analyzer) .autoGenerateSynonymsPhraseQuery(autoGenerateSynonymsPhraseQuery) .cutoffFrequency(cutoffFrequency) diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/MoreLikeThisQuery.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/MoreLikeThisQuery.java index f75d0dce97..4781ab1a74 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/MoreLikeThisQuery.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/MoreLikeThisQuery.java @@ -415,7 +415,9 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { } public Builder toBuilder() { - return new Builder().analyzer(analyzer) + return new Builder().queryName(queryName()) + .boost(boost()) + .analyzer(analyzer) .boostTerms(boostTerms) .failOnUnsupportedField(failOnUnsupportedField) .fields(fields) diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/MultiMatchQuery.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/MultiMatchQuery.java index 192fbc5b70..df54323426 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/MultiMatchQuery.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/MultiMatchQuery.java @@ -363,7 +363,9 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { } public Builder toBuilder() { - return new Builder().analyzer(analyzer) + return new Builder().queryName(queryName()) + .boost(boost()) + .analyzer(analyzer) .autoGenerateSynonymsPhraseQuery(autoGenerateSynonymsPhraseQuery) .cutoffFrequency(cutoffFrequency) .fields(fields) diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/NestedQuery.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/NestedQuery.java index 997d553728..5b091462cb 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/NestedQuery.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/NestedQuery.java @@ -151,7 +151,13 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { } public Builder toBuilder() { - return new Builder().ignoreUnmapped(ignoreUnmapped).innerHits(innerHits).path(path).query(query).scoreMode(scoreMode); + return new Builder().queryName(queryName()) + .boost(boost()) + .ignoreUnmapped(ignoreUnmapped) + .innerHits(innerHits) + .path(path) + .query(query) + .scoreMode(scoreMode); } // --------------------------------------------------------------------------------------------- diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/NeuralQuery.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/NeuralQuery.java index baadf3e849..f8ba7fe012 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/NeuralQuery.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/NeuralQuery.java @@ -152,7 +152,14 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { } public Builder toBuilder() { - return new Builder().field(field).queryText(queryText).queryImage(queryImage).k(k).modelId(modelId).filter(filter); + return new Builder().queryName(queryName()) + .boost(boost()) + .field(field) + .queryText(queryText) + .queryImage(queryImage) + .k(k) + .modelId(modelId) + .filter(filter); } /** diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/ParentIdQuery.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/ParentIdQuery.java index 62d0212560..4cb32ce28c 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/ParentIdQuery.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/ParentIdQuery.java @@ -124,7 +124,7 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { } public Builder toBuilder() { - return new Builder().id(id).ignoreUnmapped(ignoreUnmapped).type(type); + return new Builder().queryName(queryName()).boost(boost()).id(id).ignoreUnmapped(ignoreUnmapped).type(type); } // --------------------------------------------------------------------------------------------- diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/PercolateQuery.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/PercolateQuery.java index 947b08889a..b1af736db0 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/PercolateQuery.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/PercolateQuery.java @@ -228,7 +228,9 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { } public Builder toBuilder() { - return new Builder().document(document) + return new Builder().queryName(queryName()) + .boost(boost()) + .document(document) .documents(documents) .field(field) .id(id) diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/PinnedQuery.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/PinnedQuery.java index eabd1d8222..e96b0393cb 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/PinnedQuery.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/PinnedQuery.java @@ -197,7 +197,7 @@ public void serialize(JsonGenerator generator, JsonpMapper mapper) { } public Builder toBuilder() { - return new Builder()._kind(_kind)._value(_value).organic(organic); + return new Builder().queryName(queryName()).boost(boost())._kind(_kind)._value(_value).organic(organic); } public static class Builder extends QueryBase.AbstractBuilder { diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/PrefixQuery.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/PrefixQuery.java index b64fbd5328..b921c33ed9 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/PrefixQuery.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/PrefixQuery.java @@ -135,7 +135,13 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { } public Builder toBuilder() { - return new Builder().field(field).value(value).rewrite(rewrite).value(value).caseInsensitive(caseInsensitive); + return new Builder().queryName(queryName()) + .boost(boost()) + .field(field) + .value(value) + .rewrite(rewrite) + .value(value) + .caseInsensitive(caseInsensitive); } // --------------------------------------------------------------------------------------------- diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/QueryStringQuery.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/QueryStringQuery.java index d1c074b648..275340f5ef 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/QueryStringQuery.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/QueryStringQuery.java @@ -497,7 +497,9 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { } public Builder toBuilder() { - return new Builder().allowLeadingWildcard(allowLeadingWildcard) + return new Builder().queryName(queryName()) + .boost(boost()) + .allowLeadingWildcard(allowLeadingWildcard) .analyzer(analyzer) .analyzeWildcard(analyzeWildcard) .autoGenerateSynonymsPhraseQuery(autoGenerateSynonymsPhraseQuery) diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/RangeQuery.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/RangeQuery.java index 60e85dc4c3..1ac2af8a6b 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/RangeQuery.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/RangeQuery.java @@ -225,7 +225,17 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { } public Builder toBuilder() { - return new Builder().field(field).gt(gt).gte(gte).lt(lt).lte(lte).from(from).to(to).format(format).timeZone(timeZone); + return new Builder().queryName(queryName()) + .boost(boost()) + .field(field) + .gt(gt) + .gte(gte) + .lt(lt) + .lte(lte) + .from(from) + .to(to) + .format(format) + .timeZone(timeZone); } // --------------------------------------------------------------------------------------------- diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/RankFeatureQuery.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/RankFeatureQuery.java index c2d01d2e80..2720a6581d 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/RankFeatureQuery.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/RankFeatureQuery.java @@ -155,7 +155,13 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { } public Builder toBuilder() { - return new Builder().field(field).saturation(saturation).log(log).linear(linear).sigmoid(sigmoid); + return new Builder().queryName(queryName()) + .boost(boost()) + .field(field) + .saturation(saturation) + .log(log) + .linear(linear) + .sigmoid(sigmoid); } // --------------------------------------------------------------------------------------------- diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/RegexpQuery.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/RegexpQuery.java index 25c9b0445f..a4f086f4de 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/RegexpQuery.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/RegexpQuery.java @@ -168,7 +168,9 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { } public Builder toBuilder() { - return new Builder().field(field) + return new Builder().queryName(queryName()) + .boost(boost()) + .field(field) .value(value) .caseInsensitive(caseInsensitive) .flags(flags) diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/ScriptQuery.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/ScriptQuery.java index 252d6a3217..2c409f7a87 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/ScriptQuery.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/ScriptQuery.java @@ -86,7 +86,7 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { } public Builder toBuilder() { - return new Builder().script(script); + return new Builder().queryName(queryName()).boost(boost()).script(script); } // --------------------------------------------------------------------------------------------- diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/ScriptScoreQuery.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/ScriptScoreQuery.java index 126309de89..c62acadb5d 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/ScriptScoreQuery.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/ScriptScoreQuery.java @@ -117,7 +117,7 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { } public Builder toBuilder() { - return new Builder().minScore(minScore).query(query).script(script); + return new Builder().queryName(queryName()).boost(boost()).minScore(minScore).query(query).script(script); } // --------------------------------------------------------------------------------------------- diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/SimpleQueryStringQuery.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/SimpleQueryStringQuery.java index 803230a525..aee6201230 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/SimpleQueryStringQuery.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/SimpleQueryStringQuery.java @@ -294,7 +294,9 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { } public Builder toBuilder() { - return new Builder().analyzer(analyzer) + return new Builder().queryName(queryName()) + .boost(boost()) + .analyzer(analyzer) .analyzeWildcard(analyzeWildcard) .autoGenerateSynonymsPhraseQuery(autoGenerateSynonymsPhraseQuery) .defaultOperator(defaultOperator) diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/SpanContainingQuery.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/SpanContainingQuery.java index 0a24e78415..f7b3182802 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/SpanContainingQuery.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/SpanContainingQuery.java @@ -106,7 +106,7 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { } public Builder toBuilder() { - return new Builder().big(big).little(little); + return new Builder().queryName(queryName()).boost(boost()).big(big).little(little); } // --------------------------------------------------------------------------------------------- diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/SpanFieldMaskingQuery.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/SpanFieldMaskingQuery.java index 3908eb21a4..e290e5050d 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/SpanFieldMaskingQuery.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/SpanFieldMaskingQuery.java @@ -106,7 +106,7 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { } public Builder toBuilder() { - return new Builder().field(field).query(query); + return new Builder().queryName(queryName()).boost(boost()).field(field).query(query); } // --------------------------------------------------------------------------------------------- diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/SpanFirstQuery.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/SpanFirstQuery.java index 0f7646a8de..37f41dcbc8 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/SpanFirstQuery.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/SpanFirstQuery.java @@ -106,7 +106,7 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { } public Builder toBuilder() { - return new Builder().end(end).match(match); + return new Builder().queryName(queryName()).boost(boost()).end(end).match(match); } // --------------------------------------------------------------------------------------------- diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/SpanMultiTermQuery.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/SpanMultiTermQuery.java index be51d14fc4..61b0e4f065 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/SpanMultiTermQuery.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/SpanMultiTermQuery.java @@ -96,7 +96,7 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { } public Builder toBuilder() { - return new Builder().match(match); + return new Builder().queryName(queryName()).boost(boost()).match(match); } // --------------------------------------------------------------------------------------------- diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/SpanNearQuery.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/SpanNearQuery.java index 69ce1fc39f..c5ae19e8ac 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/SpanNearQuery.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/SpanNearQuery.java @@ -137,7 +137,7 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { } public Builder toBuilder() { - return new Builder().clauses(clauses).inOrder(inOrder).slop(slop); + return new Builder().queryName(queryName()).boost(boost()).clauses(clauses).inOrder(inOrder).slop(slop); } // --------------------------------------------------------------------------------------------- diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/SpanNotQuery.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/SpanNotQuery.java index a37941b53f..e386047019 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/SpanNotQuery.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/SpanNotQuery.java @@ -159,7 +159,7 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { } public Builder toBuilder() { - return new Builder().dist(dist).exclude(exclude).include(include).post(post).pre(pre); + return new Builder().queryName(queryName()).boost(boost()).dist(dist).exclude(exclude).include(include).post(post).pre(pre); } // --------------------------------------------------------------------------------------------- diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/SpanOrQuery.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/SpanOrQuery.java index a38b1b9159..1dfa770976 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/SpanOrQuery.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/SpanOrQuery.java @@ -102,7 +102,7 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { } public Builder toBuilder() { - return new Builder().clauses(clauses); + return new Builder().queryName(queryName()).boost(boost()).clauses(clauses); } // --------------------------------------------------------------------------------------------- diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/SpanTermQuery.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/SpanTermQuery.java index 0d8772fe3c..9949273bee 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/SpanTermQuery.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/SpanTermQuery.java @@ -107,7 +107,7 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { } public Builder toBuilder() { - return new Builder().field(field).value(value); + return new Builder().queryName(queryName()).boost(boost()).field(field).value(value); } // --------------------------------------------------------------------------------------------- diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/SpanWithinQuery.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/SpanWithinQuery.java index 3a1c6a8cf4..7ac32054df 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/SpanWithinQuery.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/SpanWithinQuery.java @@ -106,7 +106,7 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { } public Builder toBuilder() { - return new Builder().big(big).little(little); + return new Builder().queryName(queryName()).boost(boost()).big(big).little(little); } // --------------------------------------------------------------------------------------------- diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/TermQuery.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/TermQuery.java index 589ec8da8b..71429e0c6e 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/TermQuery.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/TermQuery.java @@ -119,7 +119,7 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { } public Builder toBuilder() { - return new Builder().field(field).value(value).caseInsensitive(caseInsensitive); + return new Builder().queryName(queryName()).boost(boost()).field(field).value(value).caseInsensitive(caseInsensitive); } // --------------------------------------------------------------------------------------------- diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/TermsQuery.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/TermsQuery.java index 0319969897..8b07686120 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/TermsQuery.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/TermsQuery.java @@ -94,7 +94,7 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { } public Builder toBuilder() { - return new Builder().field(field).terms(terms); + return new Builder().queryName(queryName()).boost(boost()).field(field).terms(terms); } // --------------------------------------------------------------------------------------------- diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/TermsSetQuery.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/TermsSetQuery.java index 78e365173e..f7de749940 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/TermsSetQuery.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/TermsSetQuery.java @@ -144,7 +144,9 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { } public Builder toBuilder() { - return new Builder().field(field) + return new Builder().queryName(queryName()) + .boost(boost()) + .field(field) .minimumShouldMatchField(minimumShouldMatchField) .minimumShouldMatchScript(minimumShouldMatchScript) .terms(terms); diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/TypeQuery.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/TypeQuery.java index 215eccca14..9e3ea963b4 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/TypeQuery.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/TypeQuery.java @@ -85,7 +85,7 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { } public Builder toBuilder() { - return new Builder().value(value); + return new Builder().queryName(queryName()).boost(boost()).value(value); } // --------------------------------------------------------------------------------------------- diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/WildcardQuery.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/WildcardQuery.java index 724f933829..50e346bc72 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/WildcardQuery.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/WildcardQuery.java @@ -168,7 +168,14 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { } public Builder toBuilder() { - return new Builder().field(field).value(value).caseInsensitive(caseInsensitive).rewrite(rewrite).value(value).wildcard(wildcard); + return new Builder().queryName(queryName()) + .boost(boost()) + .field(field) + .value(value) + .caseInsensitive(caseInsensitive) + .rewrite(rewrite) + .value(value) + .wildcard(wildcard); } // --------------------------------------------------------------------------------------------- diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/WrapperQuery.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/WrapperQuery.java index b87ea9b3fc..fbe02bdc84 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/WrapperQuery.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/WrapperQuery.java @@ -88,7 +88,7 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { } public Builder toBuilder() { - return new Builder().query(query); + return new Builder().queryName(queryName()).boost(boost()).query(query); } // --------------------------------------------------------------------------------------------- diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/XyShapeQuery.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/XyShapeQuery.java index 279b59563f..b3228db759 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/XyShapeQuery.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/XyShapeQuery.java @@ -112,7 +112,7 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { } public XyShapeQuery.Builder toBuilder() { - return new XyShapeQuery.Builder().field(field).xyShape(xyShape); + return new XyShapeQuery.Builder().queryName(queryName()).boost(boost()).field(field).xyShape(xyShape); } // --------------------------------------------------------------------------------------------- diff --git a/java-client/src/test/java/org/opensearch/client/opensearch/_types/query_dsl/BoostringQueryTest.java b/java-client/src/test/java/org/opensearch/client/opensearch/_types/query_dsl/BoostingQueryTest.java similarity index 94% rename from java-client/src/test/java/org/opensearch/client/opensearch/_types/query_dsl/BoostringQueryTest.java rename to java-client/src/test/java/org/opensearch/client/opensearch/_types/query_dsl/BoostingQueryTest.java index 3f954491b8..93535d7cb7 100644 --- a/java-client/src/test/java/org/opensearch/client/opensearch/_types/query_dsl/BoostringQueryTest.java +++ b/java-client/src/test/java/org/opensearch/client/opensearch/_types/query_dsl/BoostingQueryTest.java @@ -12,7 +12,7 @@ import org.opensearch.client.opensearch._types.FieldValue; import org.opensearch.client.opensearch.model.ModelTestCase; -public class BoostringQueryTest extends ModelTestCase { +public class BoostingQueryTest extends ModelTestCase { @Test public void toBuilder() { BoostingQuery origin = new BoostingQuery.Builder().negativeBoost(1.0f) diff --git a/java-client/src/test/java/org/opensearch/client/opensearch/_types/query_dsl/MatchQueryTest.java b/java-client/src/test/java/org/opensearch/client/opensearch/_types/query_dsl/MatchQueryTest.java index c0aa2f49f1..6e942f3806 100644 --- a/java-client/src/test/java/org/opensearch/client/opensearch/_types/query_dsl/MatchQueryTest.java +++ b/java-client/src/test/java/org/opensearch/client/opensearch/_types/query_dsl/MatchQueryTest.java @@ -15,7 +15,7 @@ public class MatchQueryTest extends ModelTestCase { @Test public void toBuilder() { - MatchQuery origin = new MatchQuery.Builder().field("field").query(FieldValue.of("1")).build(); + MatchQuery origin = new MatchQuery.Builder().field("field").query(FieldValue.of("1")).queryName("name").boost(5f).build(); MatchQuery copied = origin.toBuilder().build(); assertEquals(toJson(copied), toJson(origin)); From 33670a4b2258cf36671a6323ccec0cb0ff48a66b Mon Sep 17 00:00:00 2001 From: Chris Danisch Date: Wed, 4 Sep 2024 09:16:07 -0700 Subject: [PATCH 2/3] Updated changelog Signed-off-by: Chris Danisch --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4cdc06f158..cd64458b09 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,7 +29,7 @@ This section is for maintaining a changelog for all breaking changes for the cli ### Fixed - Fix version and build ([#254](https://github.com/opensearch-project/opensearch-java/pull/254)) -- Fix queries not preserving boost and name when converted to builders +- Fix queries not preserving boost and name when converted to builders ([#1181](https://github.com/opensearch-project/opensearch-java/pull/1181)) ### Security From 5d71e59abca87df160c521c0671857b491c21689 Mon Sep 17 00:00:00 2001 From: Chris Danisch Date: Wed, 4 Sep 2024 09:16:07 -0700 Subject: [PATCH 3/3] Added toBuilder to QueryBase instead. Signed-off-by: Chris Danisch --- .../opensearch/_types/query_dsl/BoolQuery.java | 8 +------- .../opensearch/_types/query_dsl/BoostingQuery.java | 2 +- .../_types/query_dsl/CombinedFieldsQuery.java | 4 +--- .../_types/query_dsl/CommonTermsQuery.java | 4 +--- .../_types/query_dsl/ConstantScoreQuery.java | 2 +- .../opensearch/_types/query_dsl/DisMaxQuery.java | 2 +- .../_types/query_dsl/DistanceFeatureQuery.java | 2 +- .../opensearch/_types/query_dsl/ExistsQuery.java | 2 +- .../_types/query_dsl/FunctionScoreQuery.java | 4 +--- .../opensearch/_types/query_dsl/FuzzyQuery.java | 4 +--- .../_types/query_dsl/GeoBoundingBoxQuery.java | 4 +--- .../_types/query_dsl/GeoDistanceQuery.java | 2 +- .../opensearch/_types/query_dsl/GeoShapeQuery.java | 2 +- .../opensearch/_types/query_dsl/HasChildQuery.java | 4 +--- .../opensearch/_types/query_dsl/HasParentQuery.java | 4 +--- .../opensearch/_types/query_dsl/HybridQuery.java | 2 +- .../client/opensearch/_types/query_dsl/IdsQuery.java | 2 +- .../opensearch/_types/query_dsl/IntervalsQuery.java | 2 +- .../client/opensearch/_types/query_dsl/KnnQuery.java | 2 +- .../_types/query_dsl/MatchBoolPrefixQuery.java | 4 +--- .../_types/query_dsl/MatchPhrasePrefixQuery.java | 4 +--- .../_types/query_dsl/MatchPhraseQuery.java | 8 +------- .../opensearch/_types/query_dsl/MatchQuery.java | 4 +--- .../_types/query_dsl/MoreLikeThisQuery.java | 4 +--- .../opensearch/_types/query_dsl/MultiMatchQuery.java | 4 +--- .../opensearch/_types/query_dsl/NestedQuery.java | 8 +------- .../opensearch/_types/query_dsl/NeuralQuery.java | 9 +-------- .../opensearch/_types/query_dsl/ParentIdQuery.java | 2 +- .../opensearch/_types/query_dsl/PercolateQuery.java | 4 +--- .../opensearch/_types/query_dsl/PinnedQuery.java | 2 +- .../opensearch/_types/query_dsl/PrefixQuery.java | 8 +------- .../opensearch/_types/query_dsl/QueryBase.java | 4 ++++ .../_types/query_dsl/QueryStringQuery.java | 4 +--- .../opensearch/_types/query_dsl/RangeQuery.java | 12 +----------- .../_types/query_dsl/RankFeatureQuery.java | 8 +------- .../opensearch/_types/query_dsl/RegexpQuery.java | 4 +--- .../opensearch/_types/query_dsl/ScriptQuery.java | 2 +- .../_types/query_dsl/ScriptScoreQuery.java | 2 +- .../_types/query_dsl/SimpleQueryStringQuery.java | 4 +--- .../_types/query_dsl/SpanContainingQuery.java | 2 +- .../_types/query_dsl/SpanFieldMaskingQuery.java | 2 +- .../opensearch/_types/query_dsl/SpanFirstQuery.java | 2 +- .../_types/query_dsl/SpanMultiTermQuery.java | 2 +- .../opensearch/_types/query_dsl/SpanNearQuery.java | 2 +- .../opensearch/_types/query_dsl/SpanNotQuery.java | 2 +- .../opensearch/_types/query_dsl/SpanOrQuery.java | 2 +- .../opensearch/_types/query_dsl/SpanTermQuery.java | 2 +- .../opensearch/_types/query_dsl/SpanWithinQuery.java | 2 +- .../opensearch/_types/query_dsl/TermQuery.java | 2 +- .../opensearch/_types/query_dsl/TermsQuery.java | 2 +- .../opensearch/_types/query_dsl/TermsSetQuery.java | 4 +--- .../opensearch/_types/query_dsl/TypeQuery.java | 2 +- .../opensearch/_types/query_dsl/WildcardQuery.java | 4 +--- .../opensearch/_types/query_dsl/WrapperQuery.java | 2 +- .../opensearch/_types/query_dsl/XyShapeQuery.java | 2 +- 55 files changed, 58 insertions(+), 137 deletions(-) diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/BoolQuery.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/BoolQuery.java index 19582b652a..8127122be3 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/BoolQuery.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/BoolQuery.java @@ -172,13 +172,7 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { } public Builder toBuilder() { - return new Builder().queryName(queryName()) - .boost(boost()) - .filter(filter) - .minimumShouldMatch(minimumShouldMatch) - .must(must) - .mustNot(mustNot) - .should(should); + return toBuilder(new Builder()).filter(filter).minimumShouldMatch(minimumShouldMatch).must(must).mustNot(mustNot).should(should); } // --------------------------------------------------------------------------------------------- diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/BoostingQuery.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/BoostingQuery.java index e1fbd1d333..93bf82624c 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/BoostingQuery.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/BoostingQuery.java @@ -111,7 +111,7 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { } public Builder toBuilder() { - return new Builder().queryName(queryName()).boost(boost()).negativeBoost(negativeBoost).negative(negative).positive(positive); + return toBuilder(new Builder()).negativeBoost(negativeBoost).negative(negative).positive(positive); } // --------------------------------------------------------------------------------------------- diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/CombinedFieldsQuery.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/CombinedFieldsQuery.java index b23fd579b7..88a966ff2b 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/CombinedFieldsQuery.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/CombinedFieldsQuery.java @@ -174,9 +174,7 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { } public Builder toBuilder() { - return new Builder().queryName(queryName()) - .boost(boost()) - .fields(fields) + return toBuilder(new Builder()).fields(fields) .query(query) .autoGenerateSynonymsPhraseQuery(autoGenerateSynonymsPhraseQuery) .operator(operator) diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/CommonTermsQuery.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/CommonTermsQuery.java index c9f2fa459b..cb9bd377b9 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/CommonTermsQuery.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/CommonTermsQuery.java @@ -183,9 +183,7 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { } public Builder toBuilder() { - return new Builder().queryName(queryName()) - .boost(boost()) - .field(field) + return toBuilder(new Builder()).field(field) .analyzer(analyzer) .cutoffFrequency(cutoffFrequency) .highFreqOperator(highFreqOperator) diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/ConstantScoreQuery.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/ConstantScoreQuery.java index c7c8584bb0..544e9ade3b 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/ConstantScoreQuery.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/ConstantScoreQuery.java @@ -85,7 +85,7 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { } public Builder toBuilder() { - return new Builder().queryName(queryName()).boost(boost()).filter(filter); + return toBuilder(new Builder()).filter(filter); } // --------------------------------------------------------------------------------------------- diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/DisMaxQuery.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/DisMaxQuery.java index 992a8e38ba..24cba1c8c5 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/DisMaxQuery.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/DisMaxQuery.java @@ -112,7 +112,7 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { } public Builder toBuilder() { - return new Builder().queryName(queryName()).boost(boost()).queries(queries).tieBreaker(tieBreaker); + return toBuilder(new Builder()).queries(queries).tieBreaker(tieBreaker); } // --------------------------------------------------------------------------------------------- diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/DistanceFeatureQuery.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/DistanceFeatureQuery.java index bbabab152f..3995f165d9 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/DistanceFeatureQuery.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/DistanceFeatureQuery.java @@ -112,7 +112,7 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { } public Builder toBuilder() { - return new Builder().queryName(queryName()).boost(boost()).origin(origin).pivot(pivot).field(field); + return toBuilder(new Builder()).origin(origin).pivot(pivot).field(field); } // --------------------------------------------------------------------------------------------- diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/ExistsQuery.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/ExistsQuery.java index dda35daf5e..a05229cab5 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/ExistsQuery.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/ExistsQuery.java @@ -85,7 +85,7 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { } public Builder toBuilder() { - return new Builder().queryName(queryName()).boost(boost()).field(field); + return toBuilder(new Builder()).field(field); } // --------------------------------------------------------------------------------------------- diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/FunctionScoreQuery.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/FunctionScoreQuery.java index e29f6a5914..84f23d80e5 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/FunctionScoreQuery.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/FunctionScoreQuery.java @@ -178,9 +178,7 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { } public Builder toBuilder() { - return new Builder().queryName(queryName()) - .boost(boost()) - .boostMode(boostMode) + return toBuilder(new Builder()).boostMode(boostMode) .functions(functions) .maxBoost(maxBoost) .minScore(minScore) diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/FuzzyQuery.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/FuzzyQuery.java index 2e35f8a47a..295ea1143b 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/FuzzyQuery.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/FuzzyQuery.java @@ -186,9 +186,7 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { } public Builder toBuilder() { - return new Builder().queryName(queryName()) - .boost(boost()) - .field(field) + return toBuilder(new Builder()).field(field) .value(value) .maxExpansions(maxExpansions) .prefixLength(prefixLength) diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/GeoBoundingBoxQuery.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/GeoBoundingBoxQuery.java index 166ef9b0b7..2525c26185 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/GeoBoundingBoxQuery.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/GeoBoundingBoxQuery.java @@ -149,9 +149,7 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { } public Builder toBuilder() { - return new Builder().queryName(queryName()) - .boost(boost()) - .field(field) + return toBuilder(new Builder()).field(field) .boundingBox(boundingBox) .type(type) .validationMethod(validationMethod) diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/GeoDistanceQuery.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/GeoDistanceQuery.java index ce781186aa..2fc92cf470 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/GeoDistanceQuery.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/GeoDistanceQuery.java @@ -147,7 +147,7 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { } public Builder toBuilder() { - return new Builder().queryName(queryName()).boost(boost()).field(field).location(location); + return toBuilder(new Builder()).field(field).location(location); } // --------------------------------------------------------------------------------------------- diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/GeoShapeQuery.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/GeoShapeQuery.java index 15a77d4d8b..daae1138b8 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/GeoShapeQuery.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/GeoShapeQuery.java @@ -113,7 +113,7 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { } public Builder toBuilder() { - return new Builder().queryName(queryName()).boost(boost()).field(field).shape(shape); + return toBuilder(new Builder()).field(field).shape(shape); } // --------------------------------------------------------------------------------------------- diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/HasChildQuery.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/HasChildQuery.java index c5314b0359..a89a2b19e7 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/HasChildQuery.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/HasChildQuery.java @@ -184,9 +184,7 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { } public Builder toBuilder() { - return new Builder().queryName(queryName()) - .boost(boost()) - .ignoreUnmapped(ignoreUnmapped) + return toBuilder(new Builder()).ignoreUnmapped(ignoreUnmapped) .innerHits(innerHits) .maxChildren(maxChildren) .minChildren(minChildren) diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/HasParentQuery.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/HasParentQuery.java index d3fa6d0bc4..755ad185b8 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/HasParentQuery.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/HasParentQuery.java @@ -152,9 +152,7 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { } public Builder toBuilder() { - return new Builder().queryName(queryName()) - .boost(boost()) - .ignoreUnmapped(ignoreUnmapped) + return toBuilder(new Builder()).ignoreUnmapped(ignoreUnmapped) .innerHits(innerHits) .parentType(parentType) .query(query) diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/HybridQuery.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/HybridQuery.java index 1e20cf9462..1f3048504a 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/HybridQuery.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/HybridQuery.java @@ -56,7 +56,7 @@ public Query.Kind _queryKind() { } public HybridQuery.Builder toBuilder() { - return new HybridQuery.Builder().queryName(queryName()).boost(boost()).queries(queries); + return toBuilder(new Builder()).queries(queries); } public static class Builder extends QueryBase.AbstractBuilder implements ObjectBuilder { diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/IdsQuery.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/IdsQuery.java index 0799fb5519..74e9cb02d1 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/IdsQuery.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/IdsQuery.java @@ -95,7 +95,7 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { } public Builder toBuilder() { - return new Builder().queryName(queryName()).boost(boost()).values(values); + return toBuilder(new Builder()).values(values); } // --------------------------------------------------------------------------------------------- diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/IntervalsQuery.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/IntervalsQuery.java index d13b9e6523..1386e77ef7 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/IntervalsQuery.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/IntervalsQuery.java @@ -252,7 +252,7 @@ public void serialize(JsonGenerator generator, JsonpMapper mapper) { } public Builder toBuilder() { - return new Builder().queryName(queryName()).boost(boost())._kind(_kind)._value(_value).field(field); + return toBuilder(new Builder())._kind(_kind)._value(_value).field(field); } public static class Builder extends QueryBase.AbstractBuilder implements ObjectBuilder { diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/KnnQuery.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/KnnQuery.java index 89a02bf5ee..596752f47c 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/KnnQuery.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/KnnQuery.java @@ -108,7 +108,7 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { } public Builder toBuilder() { - return new Builder().queryName(queryName()).boost(boost()).field(field).vector(vector).k(k).filter(filter); + return toBuilder(new Builder()).field(field).vector(vector).k(k).filter(filter); } /** diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/MatchBoolPrefixQuery.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/MatchBoolPrefixQuery.java index ba2571a34c..fbd877201f 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/MatchBoolPrefixQuery.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/MatchBoolPrefixQuery.java @@ -235,9 +235,7 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { } public Builder toBuilder() { - return new Builder().queryName(queryName()) - .boost(boost()) - .field(field) + return toBuilder(new Builder()).field(field) .analyzer(analyzer) .fuzziness(fuzziness) .fuzzyRewrite(fuzzyRewrite) diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/MatchPhrasePrefixQuery.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/MatchPhrasePrefixQuery.java index 2c568ba401..b275eb5a27 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/MatchPhrasePrefixQuery.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/MatchPhrasePrefixQuery.java @@ -168,9 +168,7 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { } public Builder toBuilder() { - return new Builder().queryName(queryName()) - .boost(boost()) - .field(field) + return toBuilder(new Builder()).field(field) .analyzer(analyzer) .maxExpansions(maxExpansions) .query(query) diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/MatchPhraseQuery.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/MatchPhraseQuery.java index 953a0d31a2..c6c68dcd54 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/MatchPhraseQuery.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/MatchPhraseQuery.java @@ -151,13 +151,7 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { } public Builder toBuilder() { - return new Builder().queryName(queryName()) - .boost(boost()) - .field(field) - .analyzer(analyzer) - .query(query) - .slop(slop) - .zeroTermsQuery(zeroTermsQuery); + return toBuilder(new Builder()).field(field).analyzer(analyzer).query(query).slop(slop).zeroTermsQuery(zeroTermsQuery); } // --------------------------------------------------------------------------------------------- diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/MatchQuery.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/MatchQuery.java index 346ad19d19..750c5d2948 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/MatchQuery.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/MatchQuery.java @@ -307,9 +307,7 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { } public Builder toBuilder() { - return new Builder().queryName(queryName()) - .boost(boost()) - .field(field) + return toBuilder(new Builder()).field(field) .analyzer(analyzer) .autoGenerateSynonymsPhraseQuery(autoGenerateSynonymsPhraseQuery) .cutoffFrequency(cutoffFrequency) diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/MoreLikeThisQuery.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/MoreLikeThisQuery.java index 4781ab1a74..18a28faa79 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/MoreLikeThisQuery.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/MoreLikeThisQuery.java @@ -415,9 +415,7 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { } public Builder toBuilder() { - return new Builder().queryName(queryName()) - .boost(boost()) - .analyzer(analyzer) + return toBuilder(new Builder()).analyzer(analyzer) .boostTerms(boostTerms) .failOnUnsupportedField(failOnUnsupportedField) .fields(fields) diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/MultiMatchQuery.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/MultiMatchQuery.java index df54323426..fcab41899e 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/MultiMatchQuery.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/MultiMatchQuery.java @@ -363,9 +363,7 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { } public Builder toBuilder() { - return new Builder().queryName(queryName()) - .boost(boost()) - .analyzer(analyzer) + return toBuilder(new Builder()).analyzer(analyzer) .autoGenerateSynonymsPhraseQuery(autoGenerateSynonymsPhraseQuery) .cutoffFrequency(cutoffFrequency) .fields(fields) diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/NestedQuery.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/NestedQuery.java index 5b091462cb..e3e6fc8e49 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/NestedQuery.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/NestedQuery.java @@ -151,13 +151,7 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { } public Builder toBuilder() { - return new Builder().queryName(queryName()) - .boost(boost()) - .ignoreUnmapped(ignoreUnmapped) - .innerHits(innerHits) - .path(path) - .query(query) - .scoreMode(scoreMode); + return toBuilder(new Builder()).ignoreUnmapped(ignoreUnmapped).innerHits(innerHits).path(path).query(query).scoreMode(scoreMode); } // --------------------------------------------------------------------------------------------- diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/NeuralQuery.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/NeuralQuery.java index f8ba7fe012..9984f912d0 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/NeuralQuery.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/NeuralQuery.java @@ -152,14 +152,7 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { } public Builder toBuilder() { - return new Builder().queryName(queryName()) - .boost(boost()) - .field(field) - .queryText(queryText) - .queryImage(queryImage) - .k(k) - .modelId(modelId) - .filter(filter); + return toBuilder(new Builder()).field(field).queryText(queryText).queryImage(queryImage).k(k).modelId(modelId).filter(filter); } /** diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/ParentIdQuery.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/ParentIdQuery.java index 4cb32ce28c..7664f45ed1 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/ParentIdQuery.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/ParentIdQuery.java @@ -124,7 +124,7 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { } public Builder toBuilder() { - return new Builder().queryName(queryName()).boost(boost()).id(id).ignoreUnmapped(ignoreUnmapped).type(type); + return toBuilder(new Builder()).id(id).ignoreUnmapped(ignoreUnmapped).type(type); } // --------------------------------------------------------------------------------------------- diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/PercolateQuery.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/PercolateQuery.java index b1af736db0..b224ff47b6 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/PercolateQuery.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/PercolateQuery.java @@ -228,9 +228,7 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { } public Builder toBuilder() { - return new Builder().queryName(queryName()) - .boost(boost()) - .document(document) + return toBuilder(new Builder()).document(document) .documents(documents) .field(field) .id(id) diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/PinnedQuery.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/PinnedQuery.java index e96b0393cb..04a710c1c5 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/PinnedQuery.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/PinnedQuery.java @@ -197,7 +197,7 @@ public void serialize(JsonGenerator generator, JsonpMapper mapper) { } public Builder toBuilder() { - return new Builder().queryName(queryName()).boost(boost())._kind(_kind)._value(_value).organic(organic); + return toBuilder(new Builder())._kind(_kind)._value(_value).organic(organic); } public static class Builder extends QueryBase.AbstractBuilder { diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/PrefixQuery.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/PrefixQuery.java index b921c33ed9..c7efcc35f3 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/PrefixQuery.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/PrefixQuery.java @@ -135,13 +135,7 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { } public Builder toBuilder() { - return new Builder().queryName(queryName()) - .boost(boost()) - .field(field) - .value(value) - .rewrite(rewrite) - .value(value) - .caseInsensitive(caseInsensitive); + return toBuilder(new Builder()).field(field).value(value).rewrite(rewrite).value(value).caseInsensitive(caseInsensitive); } // --------------------------------------------------------------------------------------------- diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/QueryBase.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/QueryBase.java index b08abdbd6a..90b788fca2 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/QueryBase.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/QueryBase.java @@ -98,6 +98,10 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { } + protected > BuilderT toBuilder(BuilderT builder) { + return builder.queryName(queryName).boost(boost); + } + protected abstract static class AbstractBuilder> extends ObjectBuilderBase { @Nullable private Float boost; diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/QueryStringQuery.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/QueryStringQuery.java index 275340f5ef..05e5c8165a 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/QueryStringQuery.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/QueryStringQuery.java @@ -497,9 +497,7 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { } public Builder toBuilder() { - return new Builder().queryName(queryName()) - .boost(boost()) - .allowLeadingWildcard(allowLeadingWildcard) + return toBuilder(new Builder()).allowLeadingWildcard(allowLeadingWildcard) .analyzer(analyzer) .analyzeWildcard(analyzeWildcard) .autoGenerateSynonymsPhraseQuery(autoGenerateSynonymsPhraseQuery) diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/RangeQuery.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/RangeQuery.java index 1ac2af8a6b..ec3dda228f 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/RangeQuery.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/RangeQuery.java @@ -225,17 +225,7 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { } public Builder toBuilder() { - return new Builder().queryName(queryName()) - .boost(boost()) - .field(field) - .gt(gt) - .gte(gte) - .lt(lt) - .lte(lte) - .from(from) - .to(to) - .format(format) - .timeZone(timeZone); + return toBuilder(new Builder()).field(field).gt(gt).gte(gte).lt(lt).lte(lte).from(from).to(to).format(format).timeZone(timeZone); } // --------------------------------------------------------------------------------------------- diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/RankFeatureQuery.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/RankFeatureQuery.java index 2720a6581d..8614fb3082 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/RankFeatureQuery.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/RankFeatureQuery.java @@ -155,13 +155,7 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { } public Builder toBuilder() { - return new Builder().queryName(queryName()) - .boost(boost()) - .field(field) - .saturation(saturation) - .log(log) - .linear(linear) - .sigmoid(sigmoid); + return toBuilder(new Builder()).field(field).saturation(saturation).log(log).linear(linear).sigmoid(sigmoid); } // --------------------------------------------------------------------------------------------- diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/RegexpQuery.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/RegexpQuery.java index a4f086f4de..fdcef27d76 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/RegexpQuery.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/RegexpQuery.java @@ -168,9 +168,7 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { } public Builder toBuilder() { - return new Builder().queryName(queryName()) - .boost(boost()) - .field(field) + return toBuilder(new Builder()).field(field) .value(value) .caseInsensitive(caseInsensitive) .flags(flags) diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/ScriptQuery.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/ScriptQuery.java index 2c409f7a87..ec16228cd6 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/ScriptQuery.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/ScriptQuery.java @@ -86,7 +86,7 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { } public Builder toBuilder() { - return new Builder().queryName(queryName()).boost(boost()).script(script); + return toBuilder(new Builder()).script(script); } // --------------------------------------------------------------------------------------------- diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/ScriptScoreQuery.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/ScriptScoreQuery.java index c62acadb5d..6db3199f5f 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/ScriptScoreQuery.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/ScriptScoreQuery.java @@ -117,7 +117,7 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { } public Builder toBuilder() { - return new Builder().queryName(queryName()).boost(boost()).minScore(minScore).query(query).script(script); + return toBuilder(new Builder()).minScore(minScore).query(query).script(script); } // --------------------------------------------------------------------------------------------- diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/SimpleQueryStringQuery.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/SimpleQueryStringQuery.java index aee6201230..bb7c894fc0 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/SimpleQueryStringQuery.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/SimpleQueryStringQuery.java @@ -294,9 +294,7 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { } public Builder toBuilder() { - return new Builder().queryName(queryName()) - .boost(boost()) - .analyzer(analyzer) + return toBuilder(new Builder()).analyzer(analyzer) .analyzeWildcard(analyzeWildcard) .autoGenerateSynonymsPhraseQuery(autoGenerateSynonymsPhraseQuery) .defaultOperator(defaultOperator) diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/SpanContainingQuery.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/SpanContainingQuery.java index f7b3182802..130e867453 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/SpanContainingQuery.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/SpanContainingQuery.java @@ -106,7 +106,7 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { } public Builder toBuilder() { - return new Builder().queryName(queryName()).boost(boost()).big(big).little(little); + return toBuilder(new Builder()).big(big).little(little); } // --------------------------------------------------------------------------------------------- diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/SpanFieldMaskingQuery.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/SpanFieldMaskingQuery.java index e290e5050d..61db26c521 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/SpanFieldMaskingQuery.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/SpanFieldMaskingQuery.java @@ -106,7 +106,7 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { } public Builder toBuilder() { - return new Builder().queryName(queryName()).boost(boost()).field(field).query(query); + return toBuilder(new Builder()).field(field).query(query); } // --------------------------------------------------------------------------------------------- diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/SpanFirstQuery.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/SpanFirstQuery.java index 37f41dcbc8..214712a6e7 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/SpanFirstQuery.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/SpanFirstQuery.java @@ -106,7 +106,7 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { } public Builder toBuilder() { - return new Builder().queryName(queryName()).boost(boost()).end(end).match(match); + return toBuilder(new Builder()).end(end).match(match); } // --------------------------------------------------------------------------------------------- diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/SpanMultiTermQuery.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/SpanMultiTermQuery.java index 61b0e4f065..f29bfd9889 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/SpanMultiTermQuery.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/SpanMultiTermQuery.java @@ -96,7 +96,7 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { } public Builder toBuilder() { - return new Builder().queryName(queryName()).boost(boost()).match(match); + return toBuilder(new Builder()).match(match); } // --------------------------------------------------------------------------------------------- diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/SpanNearQuery.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/SpanNearQuery.java index c5ae19e8ac..4f87b7893d 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/SpanNearQuery.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/SpanNearQuery.java @@ -137,7 +137,7 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { } public Builder toBuilder() { - return new Builder().queryName(queryName()).boost(boost()).clauses(clauses).inOrder(inOrder).slop(slop); + return toBuilder(new Builder()).clauses(clauses).inOrder(inOrder).slop(slop); } // --------------------------------------------------------------------------------------------- diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/SpanNotQuery.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/SpanNotQuery.java index e386047019..13e3f36e66 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/SpanNotQuery.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/SpanNotQuery.java @@ -159,7 +159,7 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { } public Builder toBuilder() { - return new Builder().queryName(queryName()).boost(boost()).dist(dist).exclude(exclude).include(include).post(post).pre(pre); + return toBuilder(new Builder()).dist(dist).exclude(exclude).include(include).post(post).pre(pre); } // --------------------------------------------------------------------------------------------- diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/SpanOrQuery.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/SpanOrQuery.java index 1dfa770976..ad3ae45559 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/SpanOrQuery.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/SpanOrQuery.java @@ -102,7 +102,7 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { } public Builder toBuilder() { - return new Builder().queryName(queryName()).boost(boost()).clauses(clauses); + return toBuilder(new Builder()).clauses(clauses); } // --------------------------------------------------------------------------------------------- diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/SpanTermQuery.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/SpanTermQuery.java index 9949273bee..adfcf813ea 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/SpanTermQuery.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/SpanTermQuery.java @@ -107,7 +107,7 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { } public Builder toBuilder() { - return new Builder().queryName(queryName()).boost(boost()).field(field).value(value); + return toBuilder(new Builder()).field(field).value(value); } // --------------------------------------------------------------------------------------------- diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/SpanWithinQuery.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/SpanWithinQuery.java index 7ac32054df..66a3df46ce 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/SpanWithinQuery.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/SpanWithinQuery.java @@ -106,7 +106,7 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { } public Builder toBuilder() { - return new Builder().queryName(queryName()).boost(boost()).big(big).little(little); + return toBuilder(new Builder()).big(big).little(little); } // --------------------------------------------------------------------------------------------- diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/TermQuery.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/TermQuery.java index 71429e0c6e..a14ae01a10 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/TermQuery.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/TermQuery.java @@ -119,7 +119,7 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { } public Builder toBuilder() { - return new Builder().queryName(queryName()).boost(boost()).field(field).value(value).caseInsensitive(caseInsensitive); + return toBuilder(new Builder()).field(field).value(value).caseInsensitive(caseInsensitive); } // --------------------------------------------------------------------------------------------- diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/TermsQuery.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/TermsQuery.java index 8b07686120..284e6e7c46 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/TermsQuery.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/TermsQuery.java @@ -94,7 +94,7 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { } public Builder toBuilder() { - return new Builder().queryName(queryName()).boost(boost()).field(field).terms(terms); + return toBuilder(new Builder()).field(field).terms(terms); } // --------------------------------------------------------------------------------------------- diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/TermsSetQuery.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/TermsSetQuery.java index f7de749940..1351aa9e5d 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/TermsSetQuery.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/TermsSetQuery.java @@ -144,9 +144,7 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { } public Builder toBuilder() { - return new Builder().queryName(queryName()) - .boost(boost()) - .field(field) + return toBuilder(new Builder()).field(field) .minimumShouldMatchField(minimumShouldMatchField) .minimumShouldMatchScript(minimumShouldMatchScript) .terms(terms); diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/TypeQuery.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/TypeQuery.java index 9e3ea963b4..ac334bcdc2 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/TypeQuery.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/TypeQuery.java @@ -85,7 +85,7 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { } public Builder toBuilder() { - return new Builder().queryName(queryName()).boost(boost()).value(value); + return toBuilder(new Builder()).value(value); } // --------------------------------------------------------------------------------------------- diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/WildcardQuery.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/WildcardQuery.java index 50e346bc72..d03d9cad3a 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/WildcardQuery.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/WildcardQuery.java @@ -168,9 +168,7 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { } public Builder toBuilder() { - return new Builder().queryName(queryName()) - .boost(boost()) - .field(field) + return toBuilder(new Builder()).field(field) .value(value) .caseInsensitive(caseInsensitive) .rewrite(rewrite) diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/WrapperQuery.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/WrapperQuery.java index fbe02bdc84..d4d7c2ecc2 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/WrapperQuery.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/WrapperQuery.java @@ -88,7 +88,7 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { } public Builder toBuilder() { - return new Builder().queryName(queryName()).boost(boost()).query(query); + return toBuilder(new Builder()).query(query); } // --------------------------------------------------------------------------------------------- diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/XyShapeQuery.java b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/XyShapeQuery.java index b3228db759..46d3bad07e 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/XyShapeQuery.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/XyShapeQuery.java @@ -112,7 +112,7 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { } public XyShapeQuery.Builder toBuilder() { - return new XyShapeQuery.Builder().queryName(queryName()).boost(boost()).field(field).xyShape(xyShape); + return toBuilder(new Builder()).field(field).xyShape(xyShape); } // ---------------------------------------------------------------------------------------------