Skip to content

Commit

Permalink
Generate query DSL types (opensearch-project#1337)
Browse files Browse the repository at this point in the history
Signed-off-by: Thomas Farr <[email protected]>
  • Loading branch information
Xtansia authored Dec 5, 2024
1 parent f783196 commit 75ff633
Show file tree
Hide file tree
Showing 244 changed files with 15,567 additions and 7,907 deletions.
33 changes: 32 additions & 1 deletion UPGRADING.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,4 +112,35 @@ After:
- The `creationDate` property is now of type `Long` instead of `String`.
- The `translogDurability` property now accepts a `TranslogDurability` enum instead of a `String`.
- The `numberOfReplicas` property is now of type `Integer` instead of `String`.
- The `numberOfShards` property is now of type `Integer` instead of `String`.
- The `numberOfShards` property is now of type `Integer` instead of `String`.

### BoostingQuery
- The `negativeBoost` property has been corrected to be of type `float` instead of `double`.

### DisMaxQuery
- The `tieBreaker` property has been corrected to be of type `Float` instead of `Double`.

### FunctionScoreQuery
- The `maxBoost` property has been corrected to be of type `Float` instead of `Double`.
- The `minScore` property has been corrected to be of type `Float` instead of `Double`.

### KnnQuery
- The `filter` property is now of type `List<Query>` instead of `Query`.
- The `vector` property is now of type `List<Float>` instead of `float[]`.

### LikeDocument
- The `type` property has been removed as it is not supported by OpenSearch as of version 2.0.0.

### MatchQuery
- The `cutoffFrequency` property has been corrected to be of type `Float` instead of `Double`.

### MoreLikeThisQuery
- The `boostTerms` property has been corrected to be of type `Float` instead of `Double`.

### MultiMatchQuery
- The `cutoffFrequency` property has been corrected to be of type `Float` instead of `Double`.
- The `tieBreaker` property has been corrected to be of type `Float` instead of `Double`.

### QueryStringQuery
- The `phraseSlop` property has been corrected to be of type `Integer` instead of `Double`.
- The `tieBreaker` property has been corrected to be of type `Float` instead of `Double`.
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ public final BuilderT acknowledged(boolean value) {
this.acknowledged = value;
return self();
}

}

// ---------------------------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,6 @@ public final BuilderT transportAddress(@Nullable String value) {
this.transportAddress = value;
return self();
}

}

// ---------------------------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import java.util.Objects;
import java.util.function.Function;
import javax.annotation.Generated;
import javax.annotation.Nonnull;
import org.opensearch.client.json.JsonpDeserializable;
import org.opensearch.client.json.JsonpDeserializer;
import org.opensearch.client.json.JsonpMapper;
Expand Down Expand Up @@ -136,10 +137,27 @@ public void serialize(JsonGenerator generator, JsonpMapper mapper) {
}
}

@Nonnull
public Builder toBuilder() {
return new Builder(this);
}

@Nonnull
public static Builder builder() {
return new Builder();
}

public static class Builder extends ObjectBuilderBase implements ObjectBuilder<BulkByScrollTaskStatusOrException> {
private Kind _kind;
private Object _value;

public Builder() {}

private Builder(BulkByScrollTaskStatusOrException o) {
this._kind = o._kind;
this._value = o._value;
}

public ObjectBuilder<BulkByScrollTaskStatusOrException> exception(ErrorCause v) {
this._kind = Kind.Exception;
this._value = v;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,54 +30,55 @@
* GitHub history for details.
*/

//----------------------------------------------------
// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST.
//----------------------------------------------------

package org.opensearch.client.opensearch._types;

import jakarta.json.stream.JsonGenerator;
import java.util.function.Function;
import javax.annotation.Generated;
import javax.annotation.Nonnull;
import org.opensearch.client.json.JsonpDeserializable;
import org.opensearch.client.json.JsonpDeserializer;
import org.opensearch.client.json.JsonpMapper;
import org.opensearch.client.json.ObjectBuilderDeserializer;
import org.opensearch.client.json.ObjectDeserializer;
import org.opensearch.client.json.PlainJsonSerializable;
import org.opensearch.client.util.ApiTypeHelper;
import org.opensearch.client.util.CopyableBuilder;
import org.opensearch.client.util.ObjectBuilder;
import org.opensearch.client.util.ObjectBuilderBase;
import org.opensearch.client.util.ToCopyableBuilder;

// typedef: _types.CoordsGeoBounds

@JsonpDeserializable
public class CoordsGeoBounds implements PlainJsonSerializable {
private final double top;
@Generated("org.opensearch.client.codegen.CodeGenerator")
public class CoordsGeoBounds implements PlainJsonSerializable, ToCopyableBuilder<CoordsGeoBounds.Builder, CoordsGeoBounds> {

private final double bottom;

private final double left;

private final double right;

private final double top;

// ---------------------------------------------------------------------------------------------

private CoordsGeoBounds(Builder builder) {

this.top = ApiTypeHelper.requireNonNull(builder.top, this, "top");
this.bottom = ApiTypeHelper.requireNonNull(builder.bottom, this, "bottom");
this.left = ApiTypeHelper.requireNonNull(builder.left, this, "left");
this.right = ApiTypeHelper.requireNonNull(builder.right, this, "right");

this.top = ApiTypeHelper.requireNonNull(builder.top, this, "top");
}

public static CoordsGeoBounds of(Function<Builder, ObjectBuilder<CoordsGeoBounds>> fn) {
public static CoordsGeoBounds of(Function<CoordsGeoBounds.Builder, ObjectBuilder<CoordsGeoBounds>> fn) {
return fn.apply(new Builder()).build();
}

/**
* Required - API name: {@code top}
*/
public final double top() {
return this.top;
}

/**
* Required - API name: {@code bottom}
*/
Expand All @@ -99,20 +100,24 @@ public final double right() {
return this.right;
}

/**
* Required - API name: {@code top}
*/
public final double top() {
return this.top;
}

/**
* Serialize this object to JSON.
*/
@Override
public void serialize(JsonGenerator generator, JsonpMapper mapper) {
generator.writeStartObject();
serializeInternal(generator, mapper);
generator.writeEnd();
}

protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {

generator.writeKey("top");
generator.write(this.top);

generator.writeKey("bottom");
generator.write(this.bottom);

Expand All @@ -122,34 +127,58 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {
generator.writeKey("right");
generator.write(this.right);

generator.writeKey("top");
generator.write(this.top);
}

// ---------------------------------------------------------------------------------------------

@Override
@Nonnull
public Builder toBuilder() {
return new Builder(this);
}

@Nonnull
public static Builder builder() {
return new Builder();
}

/**
* Builder for {@link CoordsGeoBounds}.
*/

public static class Builder extends ObjectBuilderBase implements ObjectBuilder<CoordsGeoBounds> {
public static class Builder extends ObjectBuilderBase implements CopyableBuilder<Builder, CoordsGeoBounds> {
private Double bottom;
private Double left;
private Double right;
private Double top;

private Double bottom;
public Builder() {}

private Double left;
private Builder(CoordsGeoBounds o) {
this.bottom = o.bottom;
this.left = o.left;
this.right = o.right;
this.top = o.top;
}

private Double right;
private Builder(Builder o) {
this.bottom = o.bottom;
this.left = o.left;
this.right = o.right;
this.top = o.top;
}

/**
* Required - API name: {@code top}
*/
public final Builder top(double value) {
this.top = value;
return this;
@Override
@Nonnull
public Builder copy() {
return new Builder(this);
}

/**
* Required - API name: {@code bottom}
*/
@Nonnull
public final Builder bottom(double value) {
this.bottom = value;
return this;
Expand All @@ -158,6 +187,7 @@ public final Builder bottom(double value) {
/**
* Required - API name: {@code left}
*/
@Nonnull
public final Builder left(double value) {
this.left = value;
return this;
Expand All @@ -166,17 +196,28 @@ public final Builder left(double value) {
/**
* Required - API name: {@code right}
*/
@Nonnull
public final Builder right(double value) {
this.right = value;
return this;
}

/**
* Required - API name: {@code top}
*/
@Nonnull
public final Builder top(double value) {
this.top = value;
return this;
}

/**
* Builds a {@link CoordsGeoBounds}.
*
* @throws NullPointerException
* if some of the required fields are null.
* @throws NullPointerException if some of the required fields are null.
*/
@Override
@Nonnull
public CoordsGeoBounds build() {
_checkSingleUse();

Expand All @@ -195,12 +236,27 @@ public CoordsGeoBounds build() {
);

protected static void setupCoordsGeoBoundsDeserializer(ObjectDeserializer<CoordsGeoBounds.Builder> op) {

op.add(Builder::top, JsonpDeserializer.doubleDeserializer(), "top");
op.add(Builder::bottom, JsonpDeserializer.doubleDeserializer(), "bottom");
op.add(Builder::left, JsonpDeserializer.doubleDeserializer(), "left");
op.add(Builder::right, JsonpDeserializer.doubleDeserializer(), "right");
op.add(Builder::top, JsonpDeserializer.doubleDeserializer(), "top");
}

@Override
public int hashCode() {
int result = 17;
result = 31 * result + Double.hashCode(this.bottom);
result = 31 * result + Double.hashCode(this.left);
result = 31 * result + Double.hashCode(this.right);
result = 31 * result + Double.hashCode(this.top);
return result;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || this.getClass() != o.getClass()) return false;
CoordsGeoBounds other = (CoordsGeoBounds) o;
return this.bottom == other.bottom && this.left == other.left && this.right == other.right && this.top == other.top;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,32 +30,38 @@
* GitHub history for details.
*/

//----------------------------------------------------
// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST.
//----------------------------------------------------

package org.opensearch.client.opensearch._types;

import javax.annotation.Generated;
import org.opensearch.client.json.JsonEnum;
import org.opensearch.client.json.JsonpDeserializable;

// typedef: _types.DistanceUnit

@JsonpDeserializable
@Generated("org.opensearch.client.codegen.CodeGenerator")
public enum DistanceUnit implements JsonEnum {
Inches("in"),
Centimeters("cm"),

Feet("ft"),

Yards("yd"),

Miles("mi"),

NauticMiles("nmi"),
Inches("in"),

Kilometers("km"),

Meters("m"),

Centimeters("cm"),
Miles("mi"),

Millimeters("mm"),

;
NauticalMiles("nmi"),

Yards("yd");

private final String jsonValue;

Expand Down
Loading

0 comments on commit 75ff633

Please sign in to comment.