Skip to content

Commit dd1a936

Browse files
Add support for GeoDistanceSort's nested and validation_method fields (#1470)
Signed-off-by: Thomas Farr <[email protected]> (cherry picked from commit dc67343) Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
1 parent 74761fe commit dd1a936

File tree

2 files changed

+66
-2
lines changed

2 files changed

+66
-2
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
88
- Added support for the Search Pipeline APIs ([#1442](https://github.com/opensearch-project/opensearch-java/pull/1442))
99
- Added support for `simple_pattern` and `simple_pattern_split` tokenizers ([#1448](https://github.com/opensearch-project/opensearch-java/pull/1448), [#1451](https://github.com/opensearch-project/opensearch-java/pull/1451))
1010
- Added support for the Search response `phase_took` field ([#1449](https://github.com/opensearch-project/opensearch-java/pull/1449))
11+
- Added support for `GeoDistanceSort`'s `nested` and `validation_method` fields ([#1470](https://github.com/opensearch-project/opensearch-java/pull/1470))
1112

1213
### Dependencies
1314
- Bump `org.junit:junit-bom` from 5.11.4 to 5.12.0 ([#1456](https://github.com/opensearch-project/opensearch-java/pull/1456))

java-client/src/main/java/org/opensearch/client/opensearch/_types/GeoDistanceSort.java

+65-2
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,15 @@
3535
import jakarta.json.stream.JsonGenerator;
3636
import java.util.List;
3737
import java.util.function.Function;
38+
import javax.annotation.Nonnull;
3839
import javax.annotation.Nullable;
3940
import org.opensearch.client.json.JsonpDeserializable;
4041
import org.opensearch.client.json.JsonpDeserializer;
4142
import org.opensearch.client.json.JsonpMapper;
4243
import org.opensearch.client.json.JsonpSerializable;
4344
import org.opensearch.client.json.ObjectBuilderDeserializer;
4445
import org.opensearch.client.json.ObjectDeserializer;
46+
import org.opensearch.client.opensearch._types.query_dsl.GeoValidationMethod;
4547
import org.opensearch.client.util.ApiTypeHelper;
4648
import org.opensearch.client.util.ObjectBuilder;
4749
import org.opensearch.client.util.ObjectBuilderBase;
@@ -69,6 +71,12 @@ public class GeoDistanceSort implements SortOptionsVariant, JsonpSerializable {
6971
@Nullable
7072
private final DistanceUnit unit;
7173

74+
@Nullable
75+
private final GeoValidationMethod validationMethod;
76+
77+
@Nullable
78+
private final NestedSortValue nested;
79+
7280
// ---------------------------------------------------------------------------------------------
7381

7482
private GeoDistanceSort(Builder builder) {
@@ -81,7 +89,8 @@ private GeoDistanceSort(Builder builder) {
8189
this.ignoreUnmapped = builder.ignoreUnmapped;
8290
this.order = builder.order;
8391
this.unit = builder.unit;
84-
92+
this.validationMethod = builder.validationMethod;
93+
this.nested = builder.nested;
8594
}
8695

8796
public static GeoDistanceSort of(Function<Builder, ObjectBuilder<GeoDistanceSort>> fn) {
@@ -150,6 +159,22 @@ public final DistanceUnit unit() {
150159
return this.unit;
151160
}
152161

162+
/**
163+
* API name: {@code validation_method}
164+
*/
165+
@Nullable
166+
public final GeoValidationMethod validationMethod() {
167+
return this.validationMethod;
168+
}
169+
170+
/**
171+
* API name: {@code nested}
172+
*/
173+
@Nullable
174+
public final NestedSortValue nested() {
175+
return this.nested;
176+
}
177+
153178
/**
154179
* Serialize this object to JSON.
155180
*/
@@ -189,7 +214,14 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {
189214
generator.writeKey("unit");
190215
this.unit.serialize(generator, mapper);
191216
}
192-
217+
if (this.validationMethod != null) {
218+
generator.writeKey("validation_method");
219+
this.validationMethod.serialize(generator, mapper);
220+
}
221+
if (this.nested != null) {
222+
generator.writeKey("nested");
223+
this.nested.serialize(generator, mapper);
224+
}
193225
}
194226

195227
// ---------------------------------------------------------------------------------------------
@@ -249,6 +281,12 @@ public final Builder location(Function<GeoLocation.Builder, ObjectBuilder<GeoLoc
249281
@Nullable
250282
private DistanceUnit unit;
251283

284+
@Nullable
285+
private GeoValidationMethod validationMethod;
286+
287+
@Nullable
288+
private NestedSortValue nested;
289+
252290
/**
253291
* API name: {@code mode}
254292
*/
@@ -289,6 +327,29 @@ public final Builder unit(@Nullable DistanceUnit value) {
289327
return this;
290328
}
291329

330+
/**
331+
* API name: {@code validation_method}
332+
*/
333+
public final Builder validationMethod(@Nullable GeoValidationMethod value) {
334+
this.validationMethod = value;
335+
return this;
336+
}
337+
338+
/**
339+
* API name: {@code nested}
340+
*/
341+
public final Builder nested(@Nullable NestedSortValue value) {
342+
this.nested = value;
343+
return this;
344+
}
345+
346+
/**
347+
* API name: {@code nested}
348+
*/
349+
public final Builder nested(@Nonnull Function<NestedSortValue.Builder, ObjectBuilder<NestedSortValue>> fn) {
350+
return nested(fn.apply(new NestedSortValue.Builder()).build());
351+
}
352+
292353
/**
293354
* Builds a {@link GeoDistanceSort}.
294355
*
@@ -319,6 +380,8 @@ protected static void setupGeoDistanceSortDeserializer(ObjectDeserializer<GeoDis
319380
op.add(Builder::ignoreUnmapped, JsonpDeserializer.booleanDeserializer(), "ignore_unmapped");
320381
op.add(Builder::order, SortOrder._DESERIALIZER, "order");
321382
op.add(Builder::unit, DistanceUnit._DESERIALIZER, "unit");
383+
op.add(Builder::validationMethod, GeoValidationMethod._DESERIALIZER, "validation_method");
384+
op.add(Builder::nested, NestedSortValue._DESERIALIZER, "nested");
322385

323386
op.setUnknownFieldHandler((builder, name, parser, mapper) -> {
324387
builder.field(name);

0 commit comments

Comments
 (0)