Skip to content

Commit ccdb56a

Browse files
authored
feat(add-xy_shape): Ability to use xy_shape field type (#885)
* feat(add-xy_shape): Ability to use xy_shape field type Signed-off-by: MESSAOUDI Khadidja <[email protected]> * update changelog Signed-off-by: MESSAOUDI Khadidja <[email protected]> * Fix changelog and add license header Signed-off-by: MESSAOUDI Khadidja <[email protected]> * updated license header Signed-off-by: MESSAOUDI Khadidja <[email protected]> * remove shape property Signed-off-by: MESSAOUDI Khadidja <[email protected]> * fix test after removing shape Signed-off-by: MESSAOUDI Khadidja <[email protected]> * adapt ShapeQuery test to XyShapeQuery Signed-off-by: MESSAOUDI Khadidja <[email protected]> * Add ES license headers Signed-off-by: MESSAOUDI Khadidja <[email protected]> * Add ES license headers on tests Signed-off-by: MESSAOUDI Khadidja <[email protected]> --------- Signed-off-by: MESSAOUDI Khadidja <[email protected]>
1 parent a5fcb62 commit ccdb56a

File tree

15 files changed

+227
-180
lines changed

15 files changed

+227
-180
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ This section is for maintaining a changelog for all breaking changes for the cli
1212

1313
### Added
1414
- Document HTTP/2 support ([#330](https://github.com/opensearch-project/opensearch-java/pull/330))
15+
- Add xy_shape property ([#884](https://github.com/opensearch-project/opensearch-java/pull/885))
1516

1617
### Dependencies
1718

@@ -23,6 +24,7 @@ This section is for maintaining a changelog for all breaking changes for the cli
2324
- Deprecate RestClientTransport ([#536](https://github.com/opensearch-project/opensearch-java/pull/536))
2425

2526
### Removed
27+
- Delete shape property ([#884](https://github.com/opensearch-project/opensearch-java/pull/885))
2628

2729
### Fixed
2830
- Fix version and build ([#254](https://github.com/opensearch-project/opensearch-java/pull/254))

java-client/src/main/java/org/opensearch/client/opensearch/_types/mapping/FieldType.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ public enum FieldType implements JsonEnum {
109109

110110
FlatObject("flat_object"),
111111

112-
Shape("shape"),
112+
XyShape("xy_shape"),
113113

114114
Histogram("histogram"),
115115

java-client/src/main/java/org/opensearch/client/opensearch/_types/mapping/Property.java

+13-13
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ public enum Kind implements JsonEnum {
136136

137137
SearchAsYouType("search_as_you_type"),
138138

139-
Shape("shape"),
139+
XyShape("xy_shape"),
140140

141141
Short("short"),
142142

@@ -845,20 +845,20 @@ public SearchAsYouTypeProperty searchAsYouType() {
845845
}
846846

847847
/**
848-
* Is this variant instance of kind {@code shape}?
848+
* Is this variant instance of kind {@code xy_shape}?
849849
*/
850-
public boolean isShape() {
851-
return _kind == Kind.Shape;
850+
public boolean isXyShape() {
851+
return _kind == Kind.XyShape;
852852
}
853853

854854
/**
855-
* Get the {@code shape} variant value.
855+
* Get the {@code xy_shape} variant value.
856856
*
857857
* @throws IllegalStateException
858-
* if the current variant is not of the {@code shape} kind.
858+
* if the current variant is not of the {@code xy_shape} kind.
859859
*/
860-
public ShapeProperty shape() {
861-
return TaggedUnionUtils.get(this, Kind.Shape);
860+
public XyShapeProperty xyShape() {
861+
return TaggedUnionUtils.get(this, Kind.XyShape);
862862
}
863863

864864
/**
@@ -1364,14 +1364,14 @@ public ObjectBuilder<Property> searchAsYouType(
13641364
return this.searchAsYouType(fn.apply(new SearchAsYouTypeProperty.Builder()).build());
13651365
}
13661366

1367-
public ObjectBuilder<Property> shape(ShapeProperty v) {
1368-
this._kind = Kind.Shape;
1367+
public ObjectBuilder<Property> xyShape(XyShapeProperty v) {
1368+
this._kind = Kind.XyShape;
13691369
this._value = v;
13701370
return this;
13711371
}
13721372

1373-
public ObjectBuilder<Property> shape(Function<ShapeProperty.Builder, ObjectBuilder<ShapeProperty>> fn) {
1374-
return this.shape(fn.apply(new ShapeProperty.Builder()).build());
1373+
public ObjectBuilder<Property> xyShape(Function<XyShapeProperty.Builder, ObjectBuilder<XyShapeProperty>> fn) {
1374+
return this.xyShape(fn.apply(new XyShapeProperty.Builder()).build());
13751375
}
13761376

13771377
public ObjectBuilder<Property> short_(ShortNumberProperty v) {
@@ -1483,7 +1483,7 @@ protected static void setupPropertyDeserializer(ObjectDeserializer<Builder> op)
14831483
op.add(Builder::rankFeatures, RankFeaturesProperty._DESERIALIZER, "rank_features");
14841484
op.add(Builder::scaledFloat, ScaledFloatNumberProperty._DESERIALIZER, "scaled_float");
14851485
op.add(Builder::searchAsYouType, SearchAsYouTypeProperty._DESERIALIZER, "search_as_you_type");
1486-
op.add(Builder::shape, ShapeProperty._DESERIALIZER, "shape");
1486+
op.add(Builder::xyShape, XyShapeProperty._DESERIALIZER, "xy_shape");
14871487
op.add(Builder::short_, ShortNumberProperty._DESERIALIZER, "short");
14881488
op.add(Builder::text, TextProperty._DESERIALIZER, "text");
14891489
op.add(Builder::tokenCount, TokenCountProperty._DESERIALIZER, "token_count");

java-client/src/main/java/org/opensearch/client/opensearch/_types/mapping/PropertyBuilders.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -332,11 +332,11 @@ public static SearchAsYouTypeProperty.Builder searchAsYouType() {
332332
}
333333

334334
/**
335-
* Creates a builder for the {@link ShapeProperty shape} {@code Property}
335+
* Creates a builder for the {@link XyShapeProperty xy_shape} {@code Property}
336336
* variant.
337337
*/
338-
public static ShapeProperty.Builder shape() {
339-
return new ShapeProperty.Builder();
338+
public static XyShapeProperty.Builder xyShape() {
339+
return new XyShapeProperty.Builder();
340340
}
341341

342342
/**

java-client/src/main/java/org/opensearch/client/opensearch/_types/mapping/ShapeProperty.java java-client/src/main/java/org/opensearch/client/opensearch/_types/mapping/XyShapeProperty.java

+30-28
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232

3333
package org.opensearch.client.opensearch._types.mapping;
3434

35+
// typedef: _types.mapping.XyShapeProperty
36+
3537
import jakarta.json.stream.JsonGenerator;
3638
import java.util.function.Function;
3739
import javax.annotation.Nullable;
@@ -42,16 +44,14 @@
4244
import org.opensearch.client.json.ObjectDeserializer;
4345
import org.opensearch.client.util.ObjectBuilder;
4446

45-
// typedef: _types.mapping.ShapeProperty
46-
4747
/**
48-
* The <code>shape</code> data type facilitates the indexing of and searching
48+
* The <code>xy_shape</code> data type facilitates the indexing of and searching
4949
* with arbitrary <code>x, y</code> cartesian shapes such as rectangles and
5050
* polygons.
5151
*
5252
*/
5353
@JsonpDeserializable
54-
public class ShapeProperty extends DocValuesPropertyBase implements PropertyVariant {
54+
public class XyShapeProperty extends DocValuesPropertyBase implements PropertyVariant {
5555
@Nullable
5656
private final Boolean coerce;
5757

@@ -66,7 +66,7 @@ public class ShapeProperty extends DocValuesPropertyBase implements PropertyVari
6666

6767
// ---------------------------------------------------------------------------------------------
6868

69-
private ShapeProperty(Builder builder) {
69+
private XyShapeProperty(XyShapeProperty.Builder builder) {
7070
super(builder);
7171

7272
this.coerce = builder.coerce;
@@ -76,16 +76,16 @@ private ShapeProperty(Builder builder) {
7676

7777
}
7878

79-
public static ShapeProperty of(Function<Builder, ObjectBuilder<ShapeProperty>> fn) {
80-
return fn.apply(new Builder()).build();
79+
public static XyShapeProperty of(Function<XyShapeProperty.Builder, ObjectBuilder<XyShapeProperty>> fn) {
80+
return fn.apply(new XyShapeProperty.Builder()).build();
8181
}
8282

8383
/**
8484
* Property variant kind.
8585
*/
8686
@Override
8787
public Property.Kind _propertyKind() {
88-
return Property.Kind.Shape;
88+
return Property.Kind.XyShape;
8989
}
9090

9191
/**
@@ -122,7 +122,7 @@ public final GeoOrientation orientation() {
122122

123123
protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {
124124

125-
generator.write("type", "shape");
125+
generator.write("type", "xy_shape");
126126
super.serializeInternal(generator, mapper);
127127
if (this.coerce != null) {
128128
generator.writeKey("coerce");
@@ -149,10 +149,12 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {
149149
// ---------------------------------------------------------------------------------------------
150150

151151
/**
152-
* Builder for {@link ShapeProperty}.
152+
* Builder for {@link XyShapeProperty}.
153153
*/
154154

155-
public static class Builder extends DocValuesPropertyBase.AbstractBuilder<Builder> implements ObjectBuilder<ShapeProperty> {
155+
public static class Builder extends DocValuesPropertyBase.AbstractBuilder<XyShapeProperty.Builder>
156+
implements
157+
ObjectBuilder<XyShapeProperty> {
156158
@Nullable
157159
private Boolean coerce;
158160

@@ -168,69 +170,69 @@ public static class Builder extends DocValuesPropertyBase.AbstractBuilder<Builde
168170
/**
169171
* API name: {@code coerce}
170172
*/
171-
public final Builder coerce(@Nullable Boolean value) {
173+
public final XyShapeProperty.Builder coerce(@Nullable Boolean value) {
172174
this.coerce = value;
173175
return this;
174176
}
175177

176178
/**
177179
* API name: {@code ignore_malformed}
178180
*/
179-
public final Builder ignoreMalformed(@Nullable Boolean value) {
181+
public final XyShapeProperty.Builder ignoreMalformed(@Nullable Boolean value) {
180182
this.ignoreMalformed = value;
181183
return this;
182184
}
183185

184186
/**
185187
* API name: {@code ignore_z_value}
186188
*/
187-
public final Builder ignoreZValue(@Nullable Boolean value) {
189+
public final XyShapeProperty.Builder ignoreZValue(@Nullable Boolean value) {
188190
this.ignoreZValue = value;
189191
return this;
190192
}
191193

192194
/**
193195
* API name: {@code orientation}
194196
*/
195-
public final Builder orientation(@Nullable GeoOrientation value) {
197+
public final XyShapeProperty.Builder orientation(@Nullable GeoOrientation value) {
196198
this.orientation = value;
197199
return this;
198200
}
199201

200202
@Override
201-
protected Builder self() {
203+
protected XyShapeProperty.Builder self() {
202204
return this;
203205
}
204206

205207
/**
206-
* Builds a {@link ShapeProperty}.
208+
* Builds a {@link XyShapeProperty}.
207209
*
208210
* @throws NullPointerException
209211
* if some of the required fields are null.
210212
*/
211-
public ShapeProperty build() {
213+
public XyShapeProperty build() {
212214
_checkSingleUse();
213215

214-
return new ShapeProperty(this);
216+
return new XyShapeProperty(this);
215217
}
216218
}
217219

218220
// ---------------------------------------------------------------------------------------------
219221

220222
/**
221-
* Json deserializer for {@link ShapeProperty}
223+
* Json deserializer for {@link XyShapeProperty}
222224
*/
223-
public static final JsonpDeserializer<ShapeProperty> _DESERIALIZER = ObjectBuilderDeserializer.lazy(
224-
Builder::new,
225-
ShapeProperty::setupShapePropertyDeserializer
225+
public static final JsonpDeserializer<XyShapeProperty> _DESERIALIZER = ObjectBuilderDeserializer.lazy(
226+
XyShapeProperty.Builder::new,
227+
XyShapeProperty::setupXyShapePropertyDeserializer
226228
);
227229

228-
protected static void setupShapePropertyDeserializer(ObjectDeserializer<ShapeProperty.Builder> op) {
230+
protected static void setupXyShapePropertyDeserializer(ObjectDeserializer<XyShapeProperty.Builder> op) {
229231
DocValuesPropertyBase.setupDocValuesPropertyBaseDeserializer(op);
230-
op.add(Builder::coerce, JsonpDeserializer.booleanDeserializer(), "coerce");
231-
op.add(Builder::ignoreMalformed, JsonpDeserializer.booleanDeserializer(), "ignore_malformed");
232-
op.add(Builder::ignoreZValue, JsonpDeserializer.booleanDeserializer(), "ignore_z_value");
233-
op.add(Builder::orientation, GeoOrientation._DESERIALIZER, "orientation");
232+
op.add(XyShapeProperty.Builder::coerce, JsonpDeserializer.booleanDeserializer(), "coerce");
233+
op.add(XyShapeProperty.Builder::ignoreMalformed, JsonpDeserializer.booleanDeserializer(), "ignore_malformed");
234+
op.add(XyShapeProperty.Builder::ignoreZValue, JsonpDeserializer.booleanDeserializer(), "ignore_z_value");
235+
op.add(XyShapeProperty.Builder::orientation, GeoOrientation._DESERIALIZER, "orientation");
234236

235237
op.ignore("type");
236238
}

java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/Query.java

+8-19
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ public enum Kind implements JsonEnum {
142142

143143
ScriptScore("script_score"),
144144

145-
Shape("shape"),
145+
XyShape("xy_shape"),
146146

147147
SimpleQueryString("simple_query_string"),
148148

@@ -915,20 +915,20 @@ public ScriptScoreQuery scriptScore() {
915915
}
916916

917917
/**
918-
* Is this variant instance of kind {@code shape}?
918+
* Is this variant instance of kind {@code xy_shape}?
919919
*/
920-
public boolean isShape() {
921-
return _kind == Kind.Shape;
920+
public boolean isXyShape() {
921+
return _kind == Kind.XyShape;
922922
}
923923

924924
/**
925-
* Get the {@code shape} variant value.
925+
* Get the {@code xy_shape} variant value.
926926
*
927927
* @throws IllegalStateException
928-
* if the current variant is not of the {@code shape} kind.
928+
* if the current variant is not of the {@code xy_shape} kind.
929929
*/
930-
public ShapeQuery shape() {
931-
return TaggedUnionUtils.get(this, Kind.Shape);
930+
public XyShapeQuery xyShape() {
931+
return TaggedUnionUtils.get(this, Kind.XyShape);
932932
}
933933

934934
/**
@@ -1639,16 +1639,6 @@ public ObjectBuilder<Query> scriptScore(Function<ScriptScoreQuery.Builder, Objec
16391639
return this.scriptScore(fn.apply(new ScriptScoreQuery.Builder()).build());
16401640
}
16411641

1642-
public ObjectBuilder<Query> shape(ShapeQuery v) {
1643-
this._kind = Kind.Shape;
1644-
this._value = v;
1645-
return this;
1646-
}
1647-
1648-
public ObjectBuilder<Query> shape(Function<ShapeQuery.Builder, ObjectBuilder<ShapeQuery>> fn) {
1649-
return this.shape(fn.apply(new ShapeQuery.Builder()).build());
1650-
}
1651-
16521642
public ObjectBuilder<Query> simpleQueryString(SimpleQueryStringQuery v) {
16531643
this._kind = Kind.SimpleQueryString;
16541644
this._value = v;
@@ -1858,7 +1848,6 @@ protected static void setupQueryDeserializer(ObjectDeserializer<Builder> op) {
18581848
op.add(Builder::regexp, RegexpQuery._DESERIALIZER, "regexp");
18591849
op.add(Builder::script, ScriptQuery._DESERIALIZER, "script");
18601850
op.add(Builder::scriptScore, ScriptScoreQuery._DESERIALIZER, "script_score");
1861-
op.add(Builder::shape, ShapeQuery._DESERIALIZER, "shape");
18621851
op.add(Builder::simpleQueryString, SimpleQueryStringQuery._DESERIALIZER, "simple_query_string");
18631852
op.add(Builder::spanContaining, SpanContainingQuery._DESERIALIZER, "span_containing");
18641853
op.add(Builder::fieldMaskingSpan, SpanFieldMaskingQuery._DESERIALIZER, "field_masking_span");

java-client/src/main/java/org/opensearch/client/opensearch/_types/query_dsl/QueryBuilders.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -344,10 +344,10 @@ public static ScriptScoreQuery.Builder scriptScore() {
344344
}
345345

346346
/**
347-
* Creates a builder for the {@link ShapeQuery shape} {@code Query} variant.
347+
* Creates a builder for the {@link XyShapeQuery xy_shape} {@code Query} variant.
348348
*/
349-
public static ShapeQuery.Builder shape() {
350-
return new ShapeQuery.Builder();
349+
public static XyShapeQuery.Builder xyShape() {
350+
return new XyShapeQuery.Builder();
351351
}
352352

353353
/**

0 commit comments

Comments
 (0)