From dfe42490f010a45d9c94f3e3a7053900d8837776 Mon Sep 17 00:00:00 2001 From: Thomas Farr Date: Thu, 9 Jan 2025 16:54:13 +1300 Subject: [PATCH] Remove terms_enum Signed-off-by: Thomas Farr --- CHANGELOG.md | 1 + .../opensearch/OpenSearchAsyncClient.java | 38 -- .../client/opensearch/OpenSearchClient.java | 38 -- .../opensearch/core/TermsEnumRequest.java | 457 ------------------ .../opensearch/core/TermsEnumResponse.java | 210 -------- 5 files changed, 1 insertion(+), 743 deletions(-) delete mode 100644 java-client/src/main/java/org/opensearch/client/opensearch/core/TermsEnumRequest.java delete mode 100644 java-client/src/main/java/org/opensearch/client/opensearch/core/TermsEnumResponse.java diff --git a/CHANGELOG.md b/CHANGELOG.md index 81f046dbe6..14a0222023 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -35,6 +35,7 @@ This section is for maintaining a changelog for all breaking changes for the cli - Removed the `indices.diskUsage` operation as it's not supported by OpenSearch ([#1361](https://github.com/opensearch-project/opensearch-java/pull/1361)) - Removed the `ingest.geoIpStats` operation as it's not supported by OpenSearch ([#1375](https://github.com/opensearch-project/opensearch-java/pull/1375)) - Removed the `indices.getUpgrade` and `indices.upgrade` operations as they're not supported by OpenSearch ([#]()) +- Removed the `termsEnum` operation as it's not supported by OpenSearch ([#]()) ### Fixed - Fix version and build ([#254](https://github.com/opensearch-project/opensearch-java/pull/254)) diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/OpenSearchAsyncClient.java b/java-client/src/main/java/org/opensearch/client/opensearch/OpenSearchAsyncClient.java index 94bb713326..fa38003be7 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/OpenSearchAsyncClient.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/OpenSearchAsyncClient.java @@ -64,8 +64,6 @@ import org.opensearch.client.opensearch.core.SearchResponse; import org.opensearch.client.opensearch.core.SearchTemplateRequest; import org.opensearch.client.opensearch.core.SearchTemplateResponse; -import org.opensearch.client.opensearch.core.TermsEnumRequest; -import org.opensearch.client.opensearch.core.TermsEnumResponse; import org.opensearch.client.opensearch.core.TermvectorsRequest; import org.opensearch.client.opensearch.core.TermvectorsResponse; import org.opensearch.client.opensearch.core.UpdateRequest; @@ -614,42 +612,6 @@ public final CompletableFuture> se return searchTemplate(fn.apply(new SearchTemplateRequest.Builder()).build(), tDocumentClass); } - // ----- Endpoint: terms_enum - - /** - * The terms enum API can be used to discover terms in the index that begin with - * the provided string. It is designed for low-latency look-ups used in - * auto-complete scenarios. - * - * - */ - - public CompletableFuture termsEnum(TermsEnumRequest request) throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint endpoint = (JsonEndpoint< - TermsEnumRequest, - TermsEnumResponse, - ErrorResponse>) TermsEnumRequest._ENDPOINT; - - return this.transport.performRequestAsync(request, endpoint, this.transportOptions); - } - - /** - * The terms enum API can be used to discover terms in the index that begin with - * the provided string. It is designed for low-latency look-ups used in - * auto-complete scenarios. - * - * @param fn - * a function that initializes a builder to create the - * {@link TermsEnumRequest} - * - */ - - public final CompletableFuture termsEnum(Function> fn) - throws IOException, OpenSearchException { - return termsEnum(fn.apply(new TermsEnumRequest.Builder()).build()); - } - // ----- Endpoint: termvectors /** diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/OpenSearchClient.java b/java-client/src/main/java/org/opensearch/client/opensearch/OpenSearchClient.java index 00a641a76e..b943225a44 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/OpenSearchClient.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/OpenSearchClient.java @@ -63,8 +63,6 @@ import org.opensearch.client.opensearch.core.SearchResponse; import org.opensearch.client.opensearch.core.SearchTemplateRequest; import org.opensearch.client.opensearch.core.SearchTemplateResponse; -import org.opensearch.client.opensearch.core.TermsEnumRequest; -import org.opensearch.client.opensearch.core.TermsEnumResponse; import org.opensearch.client.opensearch.core.TermvectorsRequest; import org.opensearch.client.opensearch.core.TermvectorsResponse; import org.opensearch.client.opensearch.core.UpdateRequest; @@ -611,42 +609,6 @@ public final SearchTemplateResponse searchTemplate( return searchTemplate(fn.apply(new SearchTemplateRequest.Builder()).build(), tDocumentClass); } - // ----- Endpoint: terms_enum - - /** - * The terms enum API can be used to discover terms in the index that begin with - * the provided string. It is designed for low-latency look-ups used in - * auto-complete scenarios. - * - * - */ - - public TermsEnumResponse termsEnum(TermsEnumRequest request) throws IOException, OpenSearchException { - @SuppressWarnings("unchecked") - JsonEndpoint endpoint = (JsonEndpoint< - TermsEnumRequest, - TermsEnumResponse, - ErrorResponse>) TermsEnumRequest._ENDPOINT; - - return this.transport.performRequest(request, endpoint, this.transportOptions); - } - - /** - * The terms enum API can be used to discover terms in the index that begin with - * the provided string. It is designed for low-latency look-ups used in - * auto-complete scenarios. - * - * @param fn - * a function that initializes a builder to create the - * {@link TermsEnumRequest} - * - */ - - public final TermsEnumResponse termsEnum(Function> fn) throws IOException, - OpenSearchException { - return termsEnum(fn.apply(new TermsEnumRequest.Builder()).build()); - } - // ----- Endpoint: termvectors /** diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/core/TermsEnumRequest.java b/java-client/src/main/java/org/opensearch/client/opensearch/core/TermsEnumRequest.java deleted file mode 100644 index a87ffcee4d..0000000000 --- a/java-client/src/main/java/org/opensearch/client/opensearch/core/TermsEnumRequest.java +++ /dev/null @@ -1,457 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.client.opensearch.core; - -import jakarta.json.stream.JsonGenerator; -import java.util.Collections; -import java.util.function.Function; -import javax.annotation.Nullable; -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.opensearch._types.ErrorResponse; -import org.opensearch.client.opensearch._types.RequestBase; -import org.opensearch.client.opensearch._types.Time; -import org.opensearch.client.opensearch._types.query_dsl.Query; -import org.opensearch.client.transport.Endpoint; -import org.opensearch.client.transport.endpoints.SimpleEndpoint; -import org.opensearch.client.util.ApiTypeHelper; -import org.opensearch.client.util.ObjectBuilder; -import org.opensearch.client.util.ObjectBuilderBase; - -// typedef: _global.terms_enum.Request - -/** - * The terms enum API can be used to discover terms in the index that begin with - * the provided string. It is designed for low-latency look-ups used in - * auto-complete scenarios. - * - */ -@JsonpDeserializable -public class TermsEnumRequest extends RequestBase implements PlainJsonSerializable { - @Nullable - private final Boolean caseInsensitive; - - private final String field; - - private final String index; - - @Nullable - private final Query indexFilter; - - @Nullable - private final String searchAfter; - - @Nullable - private final Integer size; - - @Nullable - private final String string; - - @Nullable - private final Time timeout; - - // --------------------------------------------------------------------------------------------- - - private TermsEnumRequest(Builder builder) { - - this.caseInsensitive = builder.caseInsensitive; - this.field = ApiTypeHelper.requireNonNull(builder.field, this, "field"); - this.index = ApiTypeHelper.requireNonNull(builder.index, this, "index"); - this.indexFilter = builder.indexFilter; - this.searchAfter = builder.searchAfter; - this.size = builder.size; - this.string = builder.string; - this.timeout = builder.timeout; - - } - - public static TermsEnumRequest of(Function> fn) { - return fn.apply(new Builder()).build(); - } - - /** - * When true the provided search string is matched against index terms without - * case sensitivity. - *

- * API name: {@code case_insensitive} - */ - @Nullable - public final Boolean caseInsensitive() { - return this.caseInsensitive; - } - - /** - * Required - The string to match at the start of indexed terms. If not - * provided, all terms in the field are considered. - *

- * API name: {@code field} - */ - public final String field() { - return this.field; - } - - /** - * Required - Comma-separated list of data streams, indices, and index aliases - * to search. Wildcard (*) expressions are supported. - *

- * API name: {@code index} - */ - public final String index() { - return this.index; - } - - /** - * Allows to filter an index shard if the provided query rewrites to match_none. - *

- * API name: {@code index_filter} - */ - @Nullable - public final Query indexFilter() { - return this.indexFilter; - } - - /** - * API name: {@code search_after} - */ - @Nullable - public final String searchAfter() { - return this.searchAfter; - } - - /** - * How many matching terms to return. - *

- * API name: {@code size} - */ - @Nullable - public final Integer size() { - return this.size; - } - - /** - * The string after which terms in the index should be returned. Allows for a - * form of pagination if the last result from one request is passed as the - * search_after parameter for a subsequent request. - *

- * API name: {@code string} - */ - @Nullable - public final String string() { - return this.string; - } - - /** - * The maximum length of time to spend collecting results. Defaults to - * "1s" (one second). If the timeout is exceeded the complete flag set - * to false in the response and the results may be partial or empty. - *

- * API name: {@code timeout} - */ - @Nullable - public final Time timeout() { - return this.timeout; - } - - /** - * Serialize this object to JSON. - */ - public void serialize(JsonGenerator generator, JsonpMapper mapper) { - generator.writeStartObject(); - serializeInternal(generator, mapper); - generator.writeEnd(); - } - - protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - - if (this.caseInsensitive != null) { - generator.writeKey("case_insensitive"); - generator.write(this.caseInsensitive); - - } - generator.writeKey("field"); - generator.write(this.field); - - if (this.indexFilter != null) { - generator.writeKey("index_filter"); - this.indexFilter.serialize(generator, mapper); - - } - if (this.searchAfter != null) { - generator.writeKey("search_after"); - generator.write(this.searchAfter); - - } - if (this.size != null) { - generator.writeKey("size"); - generator.write(this.size); - - } - if (this.string != null) { - generator.writeKey("string"); - generator.write(this.string); - - } - if (this.timeout != null) { - generator.writeKey("timeout"); - this.timeout.serialize(generator, mapper); - - } - - } - - public Builder toBuilder() { - return new Builder().caseInsensitive(caseInsensitive) - .field(field) - .index(index) - .indexFilter(indexFilter) - .searchAfter(searchAfter) - .size(size) - .string(string) - .timeout(timeout); - } - - // --------------------------------------------------------------------------------------------- - - /** - * Builder for {@link TermsEnumRequest}. - */ - - public static class Builder extends ObjectBuilderBase implements ObjectBuilder { - @Nullable - private Boolean caseInsensitive; - - private String field; - - private String index; - - @Nullable - private Query indexFilter; - - @Nullable - private String searchAfter; - - @Nullable - private Integer size; - - @Nullable - private String string; - - @Nullable - private Time timeout; - - /** - * When true the provided search string is matched against index terms without - * case sensitivity. - *

- * API name: {@code case_insensitive} - */ - public final Builder caseInsensitive(@Nullable Boolean value) { - this.caseInsensitive = value; - return this; - } - - /** - * Required - The string to match at the start of indexed terms. If not - * provided, all terms in the field are considered. - *

- * API name: {@code field} - */ - public final Builder field(String value) { - this.field = value; - return this; - } - - /** - * Required - Comma-separated list of data streams, indices, and index aliases - * to search. Wildcard (*) expressions are supported. - *

- * API name: {@code index} - */ - public final Builder index(String value) { - this.index = value; - return this; - } - - /** - * Allows to filter an index shard if the provided query rewrites to match_none. - *

- * API name: {@code index_filter} - */ - public final Builder indexFilter(@Nullable Query value) { - this.indexFilter = value; - return this; - } - - /** - * Allows to filter an index shard if the provided query rewrites to match_none. - *

- * API name: {@code index_filter} - */ - public final Builder indexFilter(Function> fn) { - return this.indexFilter(fn.apply(new Query.Builder()).build()); - } - - /** - * API name: {@code search_after} - */ - public final Builder searchAfter(@Nullable String value) { - this.searchAfter = value; - return this; - } - - /** - * How many matching terms to return. - *

- * API name: {@code size} - */ - public final Builder size(@Nullable Integer value) { - this.size = value; - return this; - } - - /** - * The string after which terms in the index should be returned. Allows for a - * form of pagination if the last result from one request is passed as the - * search_after parameter for a subsequent request. - *

- * API name: {@code string} - */ - public final Builder string(@Nullable String value) { - this.string = value; - return this; - } - - /** - * The maximum length of time to spend collecting results. Defaults to - * "1s" (one second). If the timeout is exceeded the complete flag set - * to false in the response and the results may be partial or empty. - *

- * API name: {@code timeout} - */ - public final Builder timeout(@Nullable Time value) { - this.timeout = value; - return this; - } - - /** - * The maximum length of time to spend collecting results. Defaults to - * "1s" (one second). If the timeout is exceeded the complete flag set - * to false in the response and the results may be partial or empty. - *

- * API name: {@code timeout} - */ - public final Builder timeout(Function> fn) { - return this.timeout(fn.apply(new Time.Builder()).build()); - } - - /** - * Builds a {@link TermsEnumRequest}. - * - * @throws NullPointerException - * if some of the required fields are null. - */ - public TermsEnumRequest build() { - _checkSingleUse(); - - return new TermsEnumRequest(this); - } - } - - // --------------------------------------------------------------------------------------------- - - /** - * Json deserializer for {@link TermsEnumRequest} - */ - public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy( - Builder::new, - TermsEnumRequest::setupTermsEnumRequestDeserializer - ); - - protected static void setupTermsEnumRequestDeserializer(ObjectDeserializer op) { - - op.add(Builder::caseInsensitive, JsonpDeserializer.booleanDeserializer(), "case_insensitive"); - op.add(Builder::field, JsonpDeserializer.stringDeserializer(), "field"); - op.add(Builder::indexFilter, Query._DESERIALIZER, "index_filter"); - op.add(Builder::searchAfter, JsonpDeserializer.stringDeserializer(), "search_after"); - op.add(Builder::size, JsonpDeserializer.integerDeserializer(), "size"); - op.add(Builder::string, JsonpDeserializer.stringDeserializer(), "string"); - op.add(Builder::timeout, Time._DESERIALIZER, "timeout"); - - } - - // --------------------------------------------------------------------------------------------- - - /** - * Endpoint "{@code terms_enum}". - */ - public static final Endpoint _ENDPOINT = new SimpleEndpoint<>( - - // Request method - request -> { - return "POST"; - - }, - - // Request path - request -> { - final int _index = 1 << 0; - - int propsSet = 0; - - propsSet |= _index; - - if (propsSet == (_index)) { - StringBuilder buf = new StringBuilder(); - buf.append("/"); - SimpleEndpoint.pathEncode(request.index, buf); - buf.append("/_terms_enum"); - return buf.toString(); - } - throw SimpleEndpoint.noPathTemplateFound("path"); - - }, - - // Request parameters - request -> { - return Collections.emptyMap(); - - }, - SimpleEndpoint.emptyMap(), - true, - TermsEnumResponse._DESERIALIZER - ); -} diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/core/TermsEnumResponse.java b/java-client/src/main/java/org/opensearch/client/opensearch/core/TermsEnumResponse.java deleted file mode 100644 index 2909698699..0000000000 --- a/java-client/src/main/java/org/opensearch/client/opensearch/core/TermsEnumResponse.java +++ /dev/null @@ -1,210 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -/* - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.client.opensearch.core; - -import jakarta.json.stream.JsonGenerator; -import java.util.List; -import java.util.function.Function; -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.opensearch._types.ShardStatistics; -import org.opensearch.client.util.ApiTypeHelper; -import org.opensearch.client.util.ObjectBuilder; -import org.opensearch.client.util.ObjectBuilderBase; - -// typedef: _global.terms_enum.Response - -@JsonpDeserializable -public class TermsEnumResponse implements PlainJsonSerializable { - private final ShardStatistics shards; - - private final List terms; - - private final boolean complete; - - // --------------------------------------------------------------------------------------------- - - private TermsEnumResponse(Builder builder) { - - this.shards = ApiTypeHelper.requireNonNull(builder.shards, this, "shards"); - this.terms = ApiTypeHelper.unmodifiableRequired(builder.terms, this, "terms"); - this.complete = ApiTypeHelper.requireNonNull(builder.complete, this, "complete"); - - } - - public static TermsEnumResponse of(Function> fn) { - return fn.apply(new Builder()).build(); - } - - /** - * Required - API name: {@code _shards} - */ - public final ShardStatistics shards() { - return this.shards; - } - - /** - * Required - API name: {@code terms} - */ - public final List terms() { - return this.terms; - } - - /** - * Required - API name: {@code complete} - */ - public final boolean complete() { - return this.complete; - } - - /** - * Serialize this object to JSON. - */ - public void serialize(JsonGenerator generator, JsonpMapper mapper) { - generator.writeStartObject(); - serializeInternal(generator, mapper); - generator.writeEnd(); - } - - protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { - - generator.writeKey("_shards"); - this.shards.serialize(generator, mapper); - - if (ApiTypeHelper.isDefined(this.terms)) { - generator.writeKey("terms"); - generator.writeStartArray(); - for (String item0 : this.terms) { - generator.write(item0); - - } - generator.writeEnd(); - - } - generator.writeKey("complete"); - generator.write(this.complete); - - } - - // --------------------------------------------------------------------------------------------- - - /** - * Builder for {@link TermsEnumResponse}. - */ - - public static class Builder extends ObjectBuilderBase implements ObjectBuilder { - private ShardStatistics shards; - - private List terms; - - private Boolean complete; - - /** - * Required - API name: {@code _shards} - */ - public final Builder shards(ShardStatistics value) { - this.shards = value; - return this; - } - - /** - * Required - API name: {@code _shards} - */ - public final Builder shards(Function> fn) { - return this.shards(fn.apply(new ShardStatistics.Builder()).build()); - } - - /** - * Required - API name: {@code terms} - *

- * Adds all elements of list to terms. - */ - public final Builder terms(List list) { - this.terms = _listAddAll(this.terms, list); - return this; - } - - /** - * Required - API name: {@code terms} - *

- * Adds one or more values to terms. - */ - public final Builder terms(String value, String... values) { - this.terms = _listAdd(this.terms, value, values); - return this; - } - - /** - * Required - API name: {@code complete} - */ - public final Builder complete(boolean value) { - this.complete = value; - return this; - } - - /** - * Builds a {@link TermsEnumResponse}. - * - * @throws NullPointerException - * if some of the required fields are null. - */ - public TermsEnumResponse build() { - _checkSingleUse(); - - return new TermsEnumResponse(this); - } - } - - // --------------------------------------------------------------------------------------------- - - /** - * Json deserializer for {@link TermsEnumResponse} - */ - public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy( - Builder::new, - TermsEnumResponse::setupTermsEnumResponseDeserializer - ); - - protected static void setupTermsEnumResponseDeserializer(ObjectDeserializer op) { - - op.add(Builder::shards, ShardStatistics._DESERIALIZER, "_shards"); - op.add(Builder::terms, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "terms"); - op.add(Builder::complete, JsonpDeserializer.booleanDeserializer(), "complete"); - - } - -}