Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changed OpenApi spec for reflecting recent hybrid search #1490

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ This section is for maintaining a changelog for all breaking changes for the cli
## [Unreleased 2.x]
### Added
- Added `normalizer` to wildcard field ([#1489](https://github.com/opensearch-project/opensearch-java/pull/1489))

- Added `paginationDepth` to `HybridQuery` ([#1490](https://github.com/opensearch-project/opensearch-java/pull/1490))
### Dependencies

### Changed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,17 @@
@Generated("org.opensearch.client.codegen.CodeGenerator")
public class HybridQuery extends QueryBase implements QueryVariant, ToCopyableBuilder<HybridQuery.Builder, HybridQuery> {

@Nullable
private final Number paginationDepth;

@Nonnull
private final List<Query> queries;

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

private HybridQuery(Builder builder) {
super(builder);
this.paginationDepth = builder.paginationDepth;
this.queries = ApiTypeHelper.unmodifiable(builder.queries);
}

Expand All @@ -81,6 +85,14 @@ public Query.Kind _queryKind() {
return Query.Kind.Hybrid;
}

/**
* API name: {@code pagination_depth}
*/
@Nullable
public final Number paginationDepth() {
return this.paginationDepth;
}

/**
* API name: {@code queries}
*/
Expand All @@ -91,6 +103,11 @@ public final List<Query> queries() {

protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {
super.serializeInternal(generator, mapper);
if (this.paginationDepth != null) {
generator.writeKey("pagination_depth");
generator.write(this.paginationDepth.doubleValue());
}

if (ApiTypeHelper.isDefined(this.queries)) {
generator.writeKey("queries");
generator.writeStartArray();
Expand Down Expand Up @@ -118,18 +135,22 @@ public static Builder builder() {
* Builder for {@link HybridQuery}.
*/
public static class Builder extends QueryBase.AbstractBuilder<Builder> implements CopyableBuilder<Builder, HybridQuery> {
@Nullable
private Number paginationDepth;
@Nullable
private List<Query> queries;

public Builder() {}

private Builder(HybridQuery o) {
super(o);
this.paginationDepth = o.paginationDepth;
this.queries = _listCopy(o.queries);
}

private Builder(Builder o) {
super(o);
this.paginationDepth = o.paginationDepth;
this.queries = _listCopy(o.queries);
}

Expand All @@ -145,6 +166,15 @@ protected Builder self() {
return this;
}

/**
* API name: {@code pagination_depth}
*/
@Nonnull
public final Builder paginationDepth(@Nullable Number value) {
this.paginationDepth = value;
return this;
}

/**
* API name: {@code queries}
*
Expand Down Expand Up @@ -209,12 +239,14 @@ public HybridQuery build() {

protected static void setupHybridQueryDeserializer(ObjectDeserializer<HybridQuery.Builder> op) {
setupQueryBaseDeserializer(op);
op.add(Builder::paginationDepth, JsonpDeserializer.numberDeserializer(), "pagination_depth");
op.add(Builder::queries, JsonpDeserializer.arrayDeserializer(Query._DESERIALIZER), "queries");
}

@Override
public int hashCode() {
int result = super.hashCode();
result = 31 * result + Objects.hashCode(this.paginationDepth);
result = 31 * result + Objects.hashCode(this.queries);
return result;
}
Expand All @@ -227,6 +259,6 @@ public boolean equals(Object o) {
if (this == o) return true;
if (o == null || this.getClass() != o.getClass()) return false;
HybridQuery other = (HybridQuery) o;
return Objects.equals(this.queries, other.queries);
return Objects.equals(this.paginationDepth, other.paginationDepth) && Objects.equals(this.queries, other.queries);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public void toBuilder() {
.toQuery(),
new KnnQuery.Builder().field("passage_embedding").vector(0.01f, 0.02f).k(2).build().toQuery()
)
).build();
).paginationDepth(100).build();
HybridQuery copied = origin.toBuilder().build();

assertEquals(toJson(copied), toJson(origin));
Expand Down
2 changes: 2 additions & 0 deletions java-codegen/opensearch-openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44296,6 +44296,8 @@ components:
type: array
items:
$ref: '#/components/schemas/_common.query_dsl___QueryContainer'
pagination_depth:
type: number
_common.query_dsl___IdsQuery:
allOf:
- $ref: '#/components/schemas/_common.query_dsl___QueryBase'
Expand Down
Loading