Skip to content

Commit 717a437

Browse files
authored
Add search_relevance APIs to the Java client (opensearch-project#1748)
* Add search_relevance apis to the Java client Signed-off-by: Eric Pugh <epugh@opensourceconnections.com> * Add changelog Signed-off-by: Eric Pugh <epugh@opensourceconnections.com> --------- Signed-off-by: Eric Pugh <epugh@opensourceconnections.com>
1 parent 0fe986f commit 717a437

36 files changed

Lines changed: 9678 additions & 1 deletion

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
1010
- Bump `org.apache.httpcomponents.core5:httpcore5` from 5.3.4 to 5.3.6 ([#1726](https://github.com/opensearch-project/opensearch-java/pull/1726), [#1733](https://github.com/opensearch-project/opensearch-java/pull/1733))
1111
- Bump `org.owasp.dependencycheck` from 12.1.3 to 12.1.6 ([#1735](https://github.com/opensearch-project/opensearch-java/pull/1735), [#1742](https://github.com/opensearch-project/opensearch-java/pull/1742))
1212
- Bump `org.apache.httpcomponents.client5:httpclient5` from 5.5 to 5.5.1 ([#1740](https://github.com/opensearch-project/opensearch-java/pull/1740))
13+
- Added support for the `search_relevance` namespace ([#1748](https://github.com/opensearch-project/opensearch-java/pull/1748))
1314
- Fix formatting of the main method to run for various samples ([#1749](https://github.com/opensearch-project/opensearch-java/pull/1749))
1415

1516
## [Unreleased 3.x]

java-client/src/generated/java/org/opensearch/client/opensearch/OpenSearchAsyncClientBase.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@
122122
import org.opensearch.client.opensearch.ml.OpenSearchMlAsyncClient;
123123
import org.opensearch.client.opensearch.nodes.OpenSearchNodesAsyncClient;
124124
import org.opensearch.client.opensearch.search_pipeline.OpenSearchSearchPipelineAsyncClient;
125+
import org.opensearch.client.opensearch.search_relevance.OpenSearchSearchRelevanceAsyncClient;
125126
import org.opensearch.client.opensearch.security.OpenSearchSecurityAsyncClient;
126127
import org.opensearch.client.opensearch.snapshot.OpenSearchSnapshotAsyncClient;
127128
import org.opensearch.client.opensearch.tasks.OpenSearchTasksAsyncClient;
@@ -195,6 +196,10 @@ public OpenSearchSearchPipelineAsyncClient searchPipeline() {
195196
return new OpenSearchSearchPipelineAsyncClient(this.transport, this.transportOptions);
196197
}
197198

199+
public OpenSearchSearchRelevanceAsyncClient searchRelevance() {
200+
return new OpenSearchSearchRelevanceAsyncClient(this.transport, this.transportOptions);
201+
}
202+
198203
public OpenSearchSecurityAsyncClient security() {
199204
return new OpenSearchSecurityAsyncClient(this.transport, this.transportOptions);
200205
}

java-client/src/generated/java/org/opensearch/client/opensearch/OpenSearchClientBase.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@
121121
import org.opensearch.client.opensearch.ml.OpenSearchMlClient;
122122
import org.opensearch.client.opensearch.nodes.OpenSearchNodesClient;
123123
import org.opensearch.client.opensearch.search_pipeline.OpenSearchSearchPipelineClient;
124+
import org.opensearch.client.opensearch.search_relevance.OpenSearchSearchRelevanceClient;
124125
import org.opensearch.client.opensearch.security.OpenSearchSecurityClient;
125126
import org.opensearch.client.opensearch.snapshot.OpenSearchSnapshotClient;
126127
import org.opensearch.client.opensearch.tasks.OpenSearchTasksClient;
@@ -194,6 +195,10 @@ public OpenSearchSearchPipelineClient searchPipeline() {
194195
return new OpenSearchSearchPipelineClient(this.transport, this.transportOptions);
195196
}
196197

198+
public OpenSearchSearchRelevanceClient searchRelevance() {
199+
return new OpenSearchSearchRelevanceClient(this.transport, this.transportOptions);
200+
}
201+
197202
public OpenSearchSecurityClient security() {
198203
return new OpenSearchSecurityClient(this.transport, this.transportOptions);
199204
}
Lines changed: 197 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,197 @@
1+
/*
2+
* SPDX-License-Identifier: Apache-2.0
3+
*
4+
* The OpenSearch Contributors require contributions made to
5+
* this file be licensed under the Apache-2.0 license or a
6+
* compatible open source license.
7+
*/
8+
9+
/*
10+
* Licensed to Elasticsearch B.V. under one or more contributor
11+
* license agreements. See the NOTICE file distributed with
12+
* this work for additional information regarding copyright
13+
* ownership. Elasticsearch B.V. licenses this file to you under
14+
* the Apache License, Version 2.0 (the "License"); you may
15+
* not use this file except in compliance with the License.
16+
* You may obtain a copy of the License at
17+
*
18+
* http://www.apache.org/licenses/LICENSE-2.0
19+
*
20+
* Unless required by applicable law or agreed to in writing,
21+
* software distributed under the License is distributed on an
22+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
23+
* KIND, either express or implied. See the License for the
24+
* specific language governing permissions and limitations
25+
* under the License.
26+
*/
27+
28+
/*
29+
* Modifications Copyright OpenSearch Contributors. See
30+
* GitHub history for details.
31+
*/
32+
33+
//----------------------------------------------------
34+
// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST.
35+
//----------------------------------------------------
36+
37+
package org.opensearch.client.opensearch.search_relevance;
38+
39+
import java.util.HashMap;
40+
import java.util.Map;
41+
import java.util.function.Function;
42+
import javax.annotation.Generated;
43+
import javax.annotation.Nonnull;
44+
import org.opensearch.client.opensearch._types.ErrorResponse;
45+
import org.opensearch.client.opensearch._types.RequestBase;
46+
import org.opensearch.client.transport.Endpoint;
47+
import org.opensearch.client.transport.endpoints.SimpleEndpoint;
48+
import org.opensearch.client.util.ApiTypeHelper;
49+
import org.opensearch.client.util.CopyableBuilder;
50+
import org.opensearch.client.util.ObjectBuilder;
51+
import org.opensearch.client.util.ToCopyableBuilder;
52+
53+
// typedef: search_relevance.delete_experiments.Request
54+
55+
/**
56+
* Deletes a specified experiment.
57+
*/
58+
@Generated("org.opensearch.client.codegen.CodeGenerator")
59+
public final class DeleteExperimentsRequest extends RequestBase
60+
implements
61+
ToCopyableBuilder<DeleteExperimentsRequest.Builder, DeleteExperimentsRequest> {
62+
63+
@Nonnull
64+
private final String experimentId;
65+
66+
// ---------------------------------------------------------------------------------------------
67+
68+
private DeleteExperimentsRequest(Builder builder) {
69+
super(builder);
70+
this.experimentId = ApiTypeHelper.requireNonNull(builder.experimentId, this, "experimentId");
71+
}
72+
73+
public static DeleteExperimentsRequest of(Function<DeleteExperimentsRequest.Builder, ObjectBuilder<DeleteExperimentsRequest>> fn) {
74+
return fn.apply(new Builder()).build();
75+
}
76+
77+
/**
78+
* Required - The experiment id
79+
* <p>
80+
* API name: {@code experiment_id}
81+
* </p>
82+
*/
83+
@Nonnull
84+
public final String experimentId() {
85+
return this.experimentId;
86+
}
87+
88+
// ---------------------------------------------------------------------------------------------
89+
90+
@Override
91+
@Nonnull
92+
public Builder toBuilder() {
93+
return new Builder(this);
94+
}
95+
96+
@Nonnull
97+
public static Builder builder() {
98+
return new Builder();
99+
}
100+
101+
/**
102+
* Builder for {@link DeleteExperimentsRequest}.
103+
*/
104+
public static class Builder extends RequestBase.AbstractBuilder<Builder> implements CopyableBuilder<Builder, DeleteExperimentsRequest> {
105+
private String experimentId;
106+
107+
public Builder() {}
108+
109+
private Builder(DeleteExperimentsRequest o) {
110+
super(o);
111+
this.experimentId = o.experimentId;
112+
}
113+
114+
private Builder(Builder o) {
115+
super(o);
116+
this.experimentId = o.experimentId;
117+
}
118+
119+
@Override
120+
@Nonnull
121+
public Builder copy() {
122+
return new Builder(this);
123+
}
124+
125+
@Override
126+
@Nonnull
127+
protected Builder self() {
128+
return this;
129+
}
130+
131+
/**
132+
* Required - The experiment id
133+
* <p>
134+
* API name: {@code experiment_id}
135+
* </p>
136+
*/
137+
@Nonnull
138+
public final Builder experimentId(String value) {
139+
this.experimentId = value;
140+
return this;
141+
}
142+
143+
/**
144+
* Builds a {@link DeleteExperimentsRequest}.
145+
*
146+
* @throws NullPointerException if some of the required fields are null.
147+
*/
148+
@Override
149+
@Nonnull
150+
public DeleteExperimentsRequest build() {
151+
_checkSingleUse();
152+
153+
return new DeleteExperimentsRequest(this);
154+
}
155+
}
156+
157+
// ---------------------------------------------------------------------------------------------
158+
159+
/**
160+
* Endpoint "{@code search_relevance.delete_experiments}".
161+
*/
162+
public static final Endpoint<DeleteExperimentsRequest, DeleteExperimentsResponse, ErrorResponse> _ENDPOINT = new SimpleEndpoint<>(
163+
// Request method
164+
request -> "DELETE",
165+
// Request path
166+
request -> {
167+
StringBuilder buf = new StringBuilder();
168+
buf.append("/_plugins/_search_relevance/experiments/");
169+
SimpleEndpoint.pathEncode(request.experimentId, buf);
170+
return buf.toString();
171+
},
172+
// Request parameters
173+
request -> {
174+
Map<String, String> params = new HashMap<>();
175+
request.applyQueryParameters(params);
176+
return params;
177+
},
178+
SimpleEndpoint.emptyMap(),
179+
false,
180+
DeleteExperimentsResponse._DESERIALIZER
181+
);
182+
183+
@Override
184+
public int hashCode() {
185+
int result = 17;
186+
result = 31 * result + this.experimentId.hashCode();
187+
return result;
188+
}
189+
190+
@Override
191+
public boolean equals(Object o) {
192+
if (this == o) return true;
193+
if (o == null || this.getClass() != o.getClass()) return false;
194+
DeleteExperimentsRequest other = (DeleteExperimentsRequest) o;
195+
return this.experimentId.equals(other.experimentId);
196+
}
197+
}
Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
/*
2+
* SPDX-License-Identifier: Apache-2.0
3+
*
4+
* The OpenSearch Contributors require contributions made to
5+
* this file be licensed under the Apache-2.0 license or a
6+
* compatible open source license.
7+
*/
8+
9+
/*
10+
* Licensed to Elasticsearch B.V. under one or more contributor
11+
* license agreements. See the NOTICE file distributed with
12+
* this work for additional information regarding copyright
13+
* ownership. Elasticsearch B.V. licenses this file to you under
14+
* the Apache License, Version 2.0 (the "License"); you may
15+
* not use this file except in compliance with the License.
16+
* You may obtain a copy of the License at
17+
*
18+
* http://www.apache.org/licenses/LICENSE-2.0
19+
*
20+
* Unless required by applicable law or agreed to in writing,
21+
* software distributed under the License is distributed on an
22+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
23+
* KIND, either express or implied. See the License for the
24+
* specific language governing permissions and limitations
25+
* under the License.
26+
*/
27+
28+
/*
29+
* Modifications Copyright OpenSearch Contributors. See
30+
* GitHub history for details.
31+
*/
32+
33+
//----------------------------------------------------
34+
// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST.
35+
//----------------------------------------------------
36+
37+
package org.opensearch.client.opensearch.search_relevance;
38+
39+
import jakarta.json.stream.JsonGenerator;
40+
import java.util.function.Function;
41+
import javax.annotation.Generated;
42+
import javax.annotation.Nonnull;
43+
import org.opensearch.client.json.JsonpDeserializer;
44+
import org.opensearch.client.json.JsonpMapper;
45+
import org.opensearch.client.json.PlainJsonSerializable;
46+
import org.opensearch.client.util.CopyableBuilder;
47+
import org.opensearch.client.util.ObjectBuilder;
48+
import org.opensearch.client.util.ObjectBuilderBase;
49+
import org.opensearch.client.util.ToCopyableBuilder;
50+
51+
// typedef: search_relevance.delete_experiments.Response
52+
53+
@Generated("org.opensearch.client.codegen.CodeGenerator")
54+
public class DeleteExperimentsResponse
55+
implements
56+
PlainJsonSerializable,
57+
ToCopyableBuilder<DeleteExperimentsResponse.Builder, DeleteExperimentsResponse> {
58+
59+
// ---------------------------------------------------------------------------------------------
60+
61+
private DeleteExperimentsResponse(Builder builder) {}
62+
63+
public static DeleteExperimentsResponse of(Function<DeleteExperimentsResponse.Builder, ObjectBuilder<DeleteExperimentsResponse>> fn) {
64+
return fn.apply(new Builder()).build();
65+
}
66+
67+
/**
68+
* Serialize this object to JSON.
69+
*/
70+
@Override
71+
public void serialize(JsonGenerator generator, JsonpMapper mapper) {
72+
generator.writeStartObject();
73+
generator.writeEnd();
74+
}
75+
76+
// ---------------------------------------------------------------------------------------------
77+
78+
@Override
79+
@Nonnull
80+
public Builder toBuilder() {
81+
return new Builder(this);
82+
}
83+
84+
@Nonnull
85+
public static Builder builder() {
86+
return new Builder();
87+
}
88+
89+
/**
90+
* Builder for {@link DeleteExperimentsResponse}.
91+
*/
92+
public static class Builder extends ObjectBuilderBase implements CopyableBuilder<Builder, DeleteExperimentsResponse> {
93+
94+
public Builder() {}
95+
96+
private Builder(DeleteExperimentsResponse o) {}
97+
98+
private Builder(Builder o) {}
99+
100+
@Override
101+
@Nonnull
102+
public Builder copy() {
103+
return new Builder(this);
104+
}
105+
106+
/**
107+
* Builds a {@link DeleteExperimentsResponse}.
108+
*
109+
* @throws NullPointerException if some of the required fields are null.
110+
*/
111+
@Override
112+
@Nonnull
113+
public DeleteExperimentsResponse build() {
114+
_checkSingleUse();
115+
116+
return new DeleteExperimentsResponse(this);
117+
}
118+
}
119+
120+
// ---------------------------------------------------------------------------------------------
121+
122+
/**
123+
* Singleton instance for {@link DeleteExperimentsResponse}.
124+
*/
125+
public static final DeleteExperimentsResponse _INSTANCE = builder().build();
126+
127+
public static final JsonpDeserializer<DeleteExperimentsResponse> _DESERIALIZER = JsonpDeserializer.emptyObject(
128+
DeleteExperimentsResponse._INSTANCE
129+
);
130+
131+
@Override
132+
public int hashCode() {
133+
int result = 17;
134+
return result;
135+
}
136+
137+
@Override
138+
public boolean equals(Object o) {
139+
if (this == o) return true;
140+
if (o == null || this.getClass() != o.getClass()) return false;
141+
return true;
142+
}
143+
}

0 commit comments

Comments
 (0)