|
34 | 34 | import co.elastic.clients.transport.endpoints.EndpointWithResponseMapperAttr;
|
35 | 35 | import co.elastic.clients.util.ObjectBuilder;
|
36 | 36 | import java.io.IOException;
|
| 37 | +import java.lang.reflect.Type; |
37 | 38 | import java.util.function.Function;
|
38 | 39 | import javax.annotation.Nullable;
|
39 | 40 |
|
@@ -132,6 +133,43 @@ public final <TDocument> GetAsyncSearchResponse<TDocument> get(
|
132 | 133 | return get(fn.apply(new GetAsyncSearchRequest.Builder()).build(), tDocumentClass);
|
133 | 134 | }
|
134 | 135 |
|
| 136 | + /** |
| 137 | + * Retrieves the results of a previously submitted async search request given |
| 138 | + * its ID. |
| 139 | + * |
| 140 | + * @see <a href= |
| 141 | + * "https://www.elastic.co/guide/en/elasticsearch/reference/current/async-search.html">Documentation |
| 142 | + * on elastic.co</a> |
| 143 | + */ |
| 144 | + |
| 145 | + public <TDocument> GetAsyncSearchResponse<TDocument> get(GetAsyncSearchRequest request, Type tDocumentType) |
| 146 | + throws IOException, ElasticsearchException { |
| 147 | + @SuppressWarnings("unchecked") |
| 148 | + JsonEndpoint<GetAsyncSearchRequest, GetAsyncSearchResponse<TDocument>, ErrorResponse> endpoint = (JsonEndpoint<GetAsyncSearchRequest, GetAsyncSearchResponse<TDocument>, ErrorResponse>) GetAsyncSearchRequest._ENDPOINT; |
| 149 | + endpoint = new EndpointWithResponseMapperAttr<>(endpoint, |
| 150 | + "co.elastic.clients:Deserializer:async_search.get.TDocument", getDeserializer(tDocumentType)); |
| 151 | + |
| 152 | + return this.transport.performRequest(request, endpoint, this.transportOptions); |
| 153 | + } |
| 154 | + |
| 155 | + /** |
| 156 | + * Retrieves the results of a previously submitted async search request given |
| 157 | + * its ID. |
| 158 | + * |
| 159 | + * @param fn |
| 160 | + * a function that initializes a builder to create the |
| 161 | + * {@link GetAsyncSearchRequest} |
| 162 | + * @see <a href= |
| 163 | + * "https://www.elastic.co/guide/en/elasticsearch/reference/current/async-search.html">Documentation |
| 164 | + * on elastic.co</a> |
| 165 | + */ |
| 166 | + |
| 167 | + public final <TDocument> GetAsyncSearchResponse<TDocument> get( |
| 168 | + Function<GetAsyncSearchRequest.Builder, ObjectBuilder<GetAsyncSearchRequest>> fn, Type tDocumentType) |
| 169 | + throws IOException, ElasticsearchException { |
| 170 | + return get(fn.apply(new GetAsyncSearchRequest.Builder()).build(), tDocumentType); |
| 171 | + } |
| 172 | + |
135 | 173 | // ----- Endpoint: async_search.status
|
136 | 174 |
|
137 | 175 | /**
|
@@ -171,6 +209,43 @@ public final <TDocument> AsyncSearchStatusResponse<TDocument> status(
|
171 | 209 | return status(fn.apply(new AsyncSearchStatusRequest.Builder()).build(), tDocumentClass);
|
172 | 210 | }
|
173 | 211 |
|
| 212 | + /** |
| 213 | + * Retrieves the status of a previously submitted async search request given its |
| 214 | + * ID. |
| 215 | + * |
| 216 | + * @see <a href= |
| 217 | + * "https://www.elastic.co/guide/en/elasticsearch/reference/current/async-search.html">Documentation |
| 218 | + * on elastic.co</a> |
| 219 | + */ |
| 220 | + |
| 221 | + public <TDocument> AsyncSearchStatusResponse<TDocument> status(AsyncSearchStatusRequest request, Type tDocumentType) |
| 222 | + throws IOException, ElasticsearchException { |
| 223 | + @SuppressWarnings("unchecked") |
| 224 | + JsonEndpoint<AsyncSearchStatusRequest, AsyncSearchStatusResponse<TDocument>, ErrorResponse> endpoint = (JsonEndpoint<AsyncSearchStatusRequest, AsyncSearchStatusResponse<TDocument>, ErrorResponse>) AsyncSearchStatusRequest._ENDPOINT; |
| 225 | + endpoint = new EndpointWithResponseMapperAttr<>(endpoint, |
| 226 | + "co.elastic.clients:Deserializer:async_search.status.TDocument", getDeserializer(tDocumentType)); |
| 227 | + |
| 228 | + return this.transport.performRequest(request, endpoint, this.transportOptions); |
| 229 | + } |
| 230 | + |
| 231 | + /** |
| 232 | + * Retrieves the status of a previously submitted async search request given its |
| 233 | + * ID. |
| 234 | + * |
| 235 | + * @param fn |
| 236 | + * a function that initializes a builder to create the |
| 237 | + * {@link AsyncSearchStatusRequest} |
| 238 | + * @see <a href= |
| 239 | + * "https://www.elastic.co/guide/en/elasticsearch/reference/current/async-search.html">Documentation |
| 240 | + * on elastic.co</a> |
| 241 | + */ |
| 242 | + |
| 243 | + public final <TDocument> AsyncSearchStatusResponse<TDocument> status( |
| 244 | + Function<AsyncSearchStatusRequest.Builder, ObjectBuilder<AsyncSearchStatusRequest>> fn, Type tDocumentType) |
| 245 | + throws IOException, ElasticsearchException { |
| 246 | + return status(fn.apply(new AsyncSearchStatusRequest.Builder()).build(), tDocumentType); |
| 247 | + } |
| 248 | + |
174 | 249 | // ----- Endpoint: async_search.submit
|
175 | 250 |
|
176 | 251 | /**
|
@@ -208,4 +283,39 @@ public final <TDocument> SubmitResponse<TDocument> submit(
|
208 | 283 | return submit(fn.apply(new SubmitRequest.Builder()).build(), tDocumentClass);
|
209 | 284 | }
|
210 | 285 |
|
| 286 | + /** |
| 287 | + * Executes a search request asynchronously. |
| 288 | + * |
| 289 | + * @see <a href= |
| 290 | + * "https://www.elastic.co/guide/en/elasticsearch/reference/current/async-search.html">Documentation |
| 291 | + * on elastic.co</a> |
| 292 | + */ |
| 293 | + |
| 294 | + public <TDocument> SubmitResponse<TDocument> submit(SubmitRequest request, Type tDocumentType) |
| 295 | + throws IOException, ElasticsearchException { |
| 296 | + @SuppressWarnings("unchecked") |
| 297 | + JsonEndpoint<SubmitRequest, SubmitResponse<TDocument>, ErrorResponse> endpoint = (JsonEndpoint<SubmitRequest, SubmitResponse<TDocument>, ErrorResponse>) SubmitRequest._ENDPOINT; |
| 298 | + endpoint = new EndpointWithResponseMapperAttr<>(endpoint, |
| 299 | + "co.elastic.clients:Deserializer:async_search.submit.TDocument", getDeserializer(tDocumentType)); |
| 300 | + |
| 301 | + return this.transport.performRequest(request, endpoint, this.transportOptions); |
| 302 | + } |
| 303 | + |
| 304 | + /** |
| 305 | + * Executes a search request asynchronously. |
| 306 | + * |
| 307 | + * @param fn |
| 308 | + * a function that initializes a builder to create the |
| 309 | + * {@link SubmitRequest} |
| 310 | + * @see <a href= |
| 311 | + * "https://www.elastic.co/guide/en/elasticsearch/reference/current/async-search.html">Documentation |
| 312 | + * on elastic.co</a> |
| 313 | + */ |
| 314 | + |
| 315 | + public final <TDocument> SubmitResponse<TDocument> submit( |
| 316 | + Function<SubmitRequest.Builder, ObjectBuilder<SubmitRequest>> fn, Type tDocumentType) |
| 317 | + throws IOException, ElasticsearchException { |
| 318 | + return submit(fn.apply(new SubmitRequest.Builder()).build(), tDocumentType); |
| 319 | + } |
| 320 | + |
211 | 321 | }
|
0 commit comments