Skip to content

Commit

Permalink
Generate KnnVectorProperty (#1255)
Browse files Browse the repository at this point in the history
* Generate KnnVectorProperty

Signed-off-by: Thomas Farr <[email protected]>

* spotlessApply

Signed-off-by: Thomas Farr <[email protected]>

* Add PR number

Signed-off-by: Thomas Farr <[email protected]>

---------

Signed-off-by: Thomas Farr <[email protected]>
  • Loading branch information
Xtansia authored Nov 1, 2024
1 parent b962e89 commit 71d63d0
Show file tree
Hide file tree
Showing 20 changed files with 734 additions and 371 deletions.
19 changes: 14 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
- Bumps `org.eclipse.parsson:parsson` from 1.1.6 to 1.1.7
- Bumps `org.hamcrest:hamcrest` from 2.2 to 3.0
- Bumps `com.github.jk1.dependency-license-report` from 2.8 to 2.9
- Bumps `org.ajoberstar.grgit:grgit-gradle` from 5.2.2 to 5.3.0
- Bumps `org.apache.httpcomponents.core5:httpcore5-h2` from 5.3 to 5.3.1

This section is for maintaining a changelog for all breaking changes for the client that cannot be released in the 2.x line. All other non-breaking changes should be added to [Unreleased 2.x] section.
Expand Down Expand Up @@ -41,8 +40,7 @@ This section is for maintaining a changelog for all breaking changes for the cli
## [Unreleased 2.x]

### Added
- Added `minScore` and `maxDistance` to `KnnQuery` ([#1166](https://github.com/opensearch-project/opensearch-java/pull/1166))
- Added `minScore` and `maxDistance` to `NeuralQuery` ([#1235](https://github.com/opensearch-project/opensearch-java/pull/1235))
- Added support for `KnnVectorProperty`'s `compression_level`, `data_type`, `mode` & `space_type` properties ([#1255](https://github.com/opensearch-project/opensearch-java/pull/1255))

### Dependencies

Expand All @@ -53,10 +51,20 @@ This section is for maintaining a changelog for all breaking changes for the cli
### Removed

### Fixed
- Fixed deserializing `GeoBoundsAggregate` when `bounds` is not returned by OpenSearch ([#1238](https://github.com/opensearch-project/opensearch-java/pull/1238))

### Security

## [2.16.0] - 10/22/2024
### Added
- Added `minScore` and `maxDistance` to `KnnQuery` ([#1166](https://github.com/opensearch-project/opensearch-java/pull/1166))
- Added `minScore` and `maxDistance` to `NeuralQuery` ([#1235](https://github.com/opensearch-project/opensearch-java/pull/1235))

### Dependencies
- Bumps `org.ajoberstar.grgit:grgit-gradle` from 5.2.2 to 5.3.0

### Fixed
- Fixed deserializing `GeoBoundsAggregate` when `bounds` is not returned by OpenSearch ([#1238](https://github.com/opensearch-project/opensearch-java/pull/1238))

## [2.15.0] - 10/17/2024
### Added
- Added `hashCode` and `equals` implementations to generated code ([#312](https://github.com/opensearch-project/opensearch-java/pull/312))
Expand Down Expand Up @@ -548,7 +556,8 @@ This section is for maintaining a changelog for all breaking changes for the cli
### Security

[Unreleased 3.0]: https://github.com/opensearch-project/opensearch-java/compare/2.x...HEAD
[Unreleased 2.x]: https://github.com/opensearch-project/opensearch-java/compare/v2.15.0...2.x
[Unreleased 2.x]: https://github.com/opensearch-project/opensearch-java/compare/v2.16.0...2.x
[2.16.0]: https://github.com/opensearch-project/opensearch-java/compare/v2.15.0...v2.16.0
[2.15.0]: https://github.com/opensearch-project/opensearch-java/compare/v2.14.0...v2.15.0
[2.14.0]: https://github.com/opensearch-project/opensearch-java/compare/v2.13.0...v2.14.0
[2.13.0]: https://github.com/opensearch-project/opensearch-java/compare/v2.12.0...v2.13.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,17 @@
* GitHub history for details.
*/

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

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

import jakarta.json.stream.JsonGenerator;
import java.util.List;
import java.util.Objects;
import javax.annotation.Generated;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import org.opensearch.client.json.JsonpDeserializer;
import org.opensearch.client.json.JsonpMapper;
Expand All @@ -42,7 +49,10 @@

// typedef: _types.mapping.CorePropertyBase

@Generated("org.opensearch.client.codegen.CodeGenerator")
public abstract class CorePropertyBase extends PropertyBase {

@Nonnull
private final List<String> copyTo;

@Nullable
Expand All @@ -55,16 +65,15 @@ public abstract class CorePropertyBase extends PropertyBase {

protected CorePropertyBase(AbstractBuilder<?> builder) {
super(builder);

this.copyTo = ApiTypeHelper.unmodifiable(builder.copyTo);
this.similarity = builder.similarity;
this.store = builder.store;

}

/**
* API name: {@code copy_to}
*/
@Nonnull
public final List<String> copyTo() {
return this.copyTo;
}
Expand All @@ -86,46 +95,44 @@ public final Boolean store() {
}

protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {

super.serializeInternal(generator, mapper);
if (ApiTypeHelper.isDefined(this.copyTo)) {
generator.writeKey("copy_to");
generator.writeStartArray();
for (String item0 : this.copyTo) {
generator.write(item0);

}
generator.writeEnd();

}

if (this.similarity != null) {
generator.writeKey("similarity");
generator.write(this.similarity);

}

if (this.store != null) {
generator.writeKey("store");
generator.write(this.store);

}

}

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

protected abstract static class AbstractBuilder<BuilderT extends AbstractBuilder<BuilderT>> extends PropertyBase.AbstractBuilder<
BuilderT> {
@Nullable
private List<String> copyTo;

@Nullable
private String similarity;

@Nullable
private Boolean store;

/**
* API name: {@code copy_to}
*
* <p>
* Adds all elements of <code>list</code> to <code>copyTo</code>.
* </p>
*/
public final BuilderT copyTo(List<String> list) {
this.copyTo = _listAddAll(this.copyTo, list);
Expand All @@ -134,8 +141,10 @@ public final BuilderT copyTo(List<String> list) {

/**
* API name: {@code copy_to}
*
* <p>
* Adds one or more values to <code>copyTo</code>.
* </p>
*/
public final BuilderT copyTo(String value, String... values) {
this.copyTo = _listAdd(this.copyTo, value, values);
Expand All @@ -161,12 +170,33 @@ public final BuilderT store(@Nullable Boolean value) {
}

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

protected static <BuilderT extends AbstractBuilder<BuilderT>> void setupCorePropertyBaseDeserializer(ObjectDeserializer<BuilderT> op) {
PropertyBase.setupPropertyBaseDeserializer(op);
setupPropertyBaseDeserializer(op);
op.add(AbstractBuilder::copyTo, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "copy_to");
op.add(AbstractBuilder::similarity, JsonpDeserializer.stringDeserializer(), "similarity");
op.add(AbstractBuilder::store, JsonpDeserializer.booleanDeserializer(), "store");
}

@Override
public int hashCode() {
int result = super.hashCode();
result = 31 * result + Objects.hashCode(this.copyTo);
result = 31 * result + Objects.hashCode(this.similarity);
result = 31 * result + Objects.hashCode(this.store);
return result;
}

@Override
public boolean equals(Object o) {
if (!super.equals(o)) {
return false;
}
if (this == o) return true;
if (o == null || this.getClass() != o.getClass()) return false;
CorePropertyBase other = (CorePropertyBase) o;
return Objects.equals(this.copyTo, other.copyTo)
&& Objects.equals(this.similarity, other.similarity)
&& Objects.equals(this.store, other.store);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,27 +30,33 @@
* GitHub history for details.
*/

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

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

import jakarta.json.stream.JsonGenerator;
import java.util.Objects;
import javax.annotation.Generated;
import javax.annotation.Nullable;
import org.opensearch.client.json.JsonpDeserializer;
import org.opensearch.client.json.JsonpMapper;
import org.opensearch.client.json.ObjectDeserializer;

// typedef: _types.mapping.DocValuesPropertyBase

@Generated("org.opensearch.client.codegen.CodeGenerator")
public abstract class DocValuesPropertyBase extends CorePropertyBase {

@Nullable
private final Boolean docValues;

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

protected DocValuesPropertyBase(AbstractBuilder<?> builder) {
super(builder);

this.docValues = builder.docValues;

}

/**
Expand All @@ -62,16 +68,15 @@ public final Boolean docValues() {
}

protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {

super.serializeInternal(generator, mapper);
if (this.docValues != null) {
generator.writeKey("doc_values");
generator.write(this.docValues);

}

}

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

protected abstract static class AbstractBuilder<BuilderT extends AbstractBuilder<BuilderT>> extends CorePropertyBase.AbstractBuilder<
BuilderT> {
@Nullable
Expand All @@ -88,12 +93,29 @@ public final BuilderT docValues(@Nullable Boolean value) {
}

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

protected static <BuilderT extends AbstractBuilder<BuilderT>> void setupDocValuesPropertyBaseDeserializer(
ObjectDeserializer<BuilderT> op
) {
setupCorePropertyBaseDeserializer(op);
op.add(AbstractBuilder::docValues, JsonpDeserializer.booleanDeserializer(), "doc_values");
}

@Override
public int hashCode() {
int result = super.hashCode();
result = 31 * result + Objects.hashCode(this.docValues);
return result;
}

@Override
public boolean equals(Object o) {
if (!super.equals(o)) {
return false;
}
if (this == o) return true;
if (o == null || this.getClass() != o.getClass()) return false;
DocValuesPropertyBase other = (DocValuesPropertyBase) o;
return Objects.equals(this.docValues, other.docValues);
}
}
Loading

0 comments on commit 71d63d0

Please sign in to comment.