You can buy this project and download/modify it how often you want.
/* * 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. */ //---------------------------------------------------- // THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST. //---------------------------------------------------- package co.elastic.clients.elasticsearch.async_search; import co.elastic.clients.elasticsearch._types.ErrorResponse; import co.elastic.clients.elasticsearch._types.ExpandWildcard; import co.elastic.clients.elasticsearch._types.RequestBase; import co.elastic.clients.elasticsearch._types.ScriptField; import co.elastic.clients.elasticsearch._types.SearchType; import co.elastic.clients.elasticsearch._types.SlicedScroll; import co.elastic.clients.elasticsearch._types.SortOptions; import co.elastic.clients.elasticsearch._types.Time; import co.elastic.clients.elasticsearch._types.aggregations.Aggregation; import co.elastic.clients.elasticsearch._types.mapping.RuntimeField; import co.elastic.clients.elasticsearch._types.query_dsl.FieldAndFormat; import co.elastic.clients.elasticsearch._types.query_dsl.Operator; import co.elastic.clients.elasticsearch._types.query_dsl.Query; import co.elastic.clients.elasticsearch.core.search.FieldCollapse; import co.elastic.clients.elasticsearch.core.search.Highlight; import co.elastic.clients.elasticsearch.core.search.PointInTimeReference; import co.elastic.clients.elasticsearch.core.search.Rescore; import co.elastic.clients.elasticsearch.core.search.SourceConfig; import co.elastic.clients.elasticsearch.core.search.Suggester; import co.elastic.clients.elasticsearch.core.search.TrackHits; import co.elastic.clients.json.JsonpDeserializable; import co.elastic.clients.json.JsonpDeserializer; import co.elastic.clients.json.JsonpMapper; import co.elastic.clients.json.JsonpSerializable; import co.elastic.clients.json.ObjectBuilderDeserializer; import co.elastic.clients.json.ObjectDeserializer; import co.elastic.clients.transport.Endpoint; import co.elastic.clients.transport.endpoints.SimpleEndpoint; import co.elastic.clients.util.ApiTypeHelper; import co.elastic.clients.util.ObjectBuilder; import co.elastic.clients.util.WithJsonObjectBuilderBase; import jakarta.json.stream.JsonGenerator; import java.lang.Boolean; import java.lang.Double; import java.lang.Integer; import java.lang.Long; import java.lang.String; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Objects; import java.util.function.Function; import java.util.stream.Collectors; import javax.annotation.Nullable; // typedef: async_search.submit.Request /** * Executes a search request asynchronously. * * @see API * specification */ @JsonpDeserializable public class SubmitRequest extends RequestBase implements JsonpSerializable { @Nullable private final SourceConfig source; private final Map aggregations; @Nullable private final Boolean allowNoIndices; @Nullable private final Boolean allowPartialSearchResults; @Nullable private final Boolean analyzeWildcard; @Nullable private final String analyzer; @Nullable private final Long batchedReduceSize; @Nullable private final Boolean ccsMinimizeRoundtrips; @Nullable private final FieldCollapse collapse; @Nullable private final Operator defaultOperator; @Nullable private final String df; private final List docvalueFields; private final List expandWildcards; @Nullable private final Boolean explain; private final List fields; @Nullable private final Integer from; @Nullable private final Highlight highlight; @Nullable private final Boolean ignoreThrottled; @Nullable private final Boolean ignoreUnavailable; private final List index; private final List> indicesBoost; @Nullable private final Time keepAlive; @Nullable private final Boolean keepOnCompletion; @Nullable private final Boolean lenient; @Nullable private final Long maxConcurrentShardRequests; @Nullable private final String minCompatibleShardNode; @Nullable private final Double minScore; @Nullable private final PointInTimeReference pit; @Nullable private final Query postFilter; @Nullable private final Long preFilterShardSize; @Nullable private final String preference; @Nullable private final Boolean profile; @Nullable private final String q; @Nullable private final Query query; @Nullable private final Boolean requestCache; private final List rescore; @Nullable private final String routing; private final Map> runtimeMappings; private final Map scriptFields; @Nullable private final Time scroll; private final List searchAfter; @Nullable private final SearchType searchType; @Nullable private final Boolean seqNoPrimaryTerm; @Nullable private final Integer size; @Nullable private final SlicedScroll slice; private final List sort; private final List stats; private final List storedFields; @Nullable private final Suggester suggest; @Nullable private final Long terminateAfter; @Nullable private final String timeout; @Nullable private final Boolean trackScores; @Nullable private final TrackHits trackTotalHits; @Nullable private final Boolean version; @Nullable private final Time waitForCompletionTimeout; // --------------------------------------------------------------------------------------------- private SubmitRequest(Builder builder) { this.source = builder.source; this.aggregations = ApiTypeHelper.unmodifiable(builder.aggregations); this.allowNoIndices = builder.allowNoIndices; this.allowPartialSearchResults = builder.allowPartialSearchResults; this.analyzeWildcard = builder.analyzeWildcard; this.analyzer = builder.analyzer; this.batchedReduceSize = builder.batchedReduceSize; this.ccsMinimizeRoundtrips = builder.ccsMinimizeRoundtrips; this.collapse = builder.collapse; this.defaultOperator = builder.defaultOperator; this.df = builder.df; this.docvalueFields = ApiTypeHelper.unmodifiable(builder.docvalueFields); this.expandWildcards = ApiTypeHelper.unmodifiable(builder.expandWildcards); this.explain = builder.explain; this.fields = ApiTypeHelper.unmodifiable(builder.fields); this.from = builder.from; this.highlight = builder.highlight; this.ignoreThrottled = builder.ignoreThrottled; this.ignoreUnavailable = builder.ignoreUnavailable; this.index = ApiTypeHelper.unmodifiable(builder.index); this.indicesBoost = ApiTypeHelper.unmodifiable(builder.indicesBoost); this.keepAlive = builder.keepAlive; this.keepOnCompletion = builder.keepOnCompletion; this.lenient = builder.lenient; this.maxConcurrentShardRequests = builder.maxConcurrentShardRequests; this.minCompatibleShardNode = builder.minCompatibleShardNode; this.minScore = builder.minScore; this.pit = builder.pit; this.postFilter = builder.postFilter; this.preFilterShardSize = builder.preFilterShardSize; this.preference = builder.preference; this.profile = builder.profile; this.q = builder.q; this.query = builder.query; this.requestCache = builder.requestCache; this.rescore = ApiTypeHelper.unmodifiable(builder.rescore); this.routing = builder.routing; this.runtimeMappings = ApiTypeHelper.unmodifiable(builder.runtimeMappings); this.scriptFields = ApiTypeHelper.unmodifiable(builder.scriptFields); this.scroll = builder.scroll; this.searchAfter = ApiTypeHelper.unmodifiable(builder.searchAfter); this.searchType = builder.searchType; this.seqNoPrimaryTerm = builder.seqNoPrimaryTerm; this.size = builder.size; this.slice = builder.slice; this.sort = ApiTypeHelper.unmodifiable(builder.sort); this.stats = ApiTypeHelper.unmodifiable(builder.stats); this.storedFields = ApiTypeHelper.unmodifiable(builder.storedFields); this.suggest = builder.suggest; this.terminateAfter = builder.terminateAfter; this.timeout = builder.timeout; this.trackScores = builder.trackScores; this.trackTotalHits = builder.trackTotalHits; this.version = builder.version; this.waitForCompletionTimeout = builder.waitForCompletionTimeout; } public static SubmitRequest of(Function> fn) { return fn.apply(new Builder()).build(); } /** * Indicates which source fields are returned for matching documents. These * fields are returned in the hits._source property of the search response. * * API name: {@code _source} */ @Nullable public final SourceConfig source() { return this.source; } /** * API name: {@code aggregations} */ public final Map aggregations() { return this.aggregations; } /** * Whether to ignore if a wildcard indices expression resolves into no concrete * indices. (This includes _all string or when no indices have been * specified) * * API name: {@code allow_no_indices} */ @Nullable public final Boolean allowNoIndices() { return this.allowNoIndices; } /** * Indicate if an error should be returned if there is a partial search failure * or timeout * * API name: {@code allow_partial_search_results} */ @Nullable public final Boolean allowPartialSearchResults() { return this.allowPartialSearchResults; } /** * Specify whether wildcard and prefix queries should be analyzed (default: * false) * * API name: {@code analyze_wildcard} */ @Nullable public final Boolean analyzeWildcard() { return this.analyzeWildcard; } /** * The analyzer to use for the query string * * API name: {@code analyzer} */ @Nullable public final String analyzer() { return this.analyzer; } /** * The number of shard results that should be reduced at once on the * coordinating node. This value should be used as the granularity at which * progress results will be made available. * * API name: {@code batched_reduce_size} */ @Nullable public final Long batchedReduceSize() { return this.batchedReduceSize; } /** * API name: {@code ccs_minimize_roundtrips} */ @Nullable public final Boolean ccsMinimizeRoundtrips() { return this.ccsMinimizeRoundtrips; } /** * API name: {@code collapse} */ @Nullable public final FieldCollapse collapse() { return this.collapse; } /** * The default operator for query string query (AND or OR) * * API name: {@code default_operator} */ @Nullable public final Operator defaultOperator() { return this.defaultOperator; } /** * The field to use as default where no field prefix is given in the query * string * * API name: {@code df} */ @Nullable public final String df() { return this.df; } /** * Array of wildcard (*) patterns. The request returns doc values for field * names matching these patterns in the hits.fields property of the response. * * API name: {@code docvalue_fields} */ public final List docvalueFields() { return this.docvalueFields; } /** * Whether to expand wildcard expression to concrete indices that are open, * closed or both. * * API name: {@code expand_wildcards} */ public final List expandWildcards() { return this.expandWildcards; } /** * If true, returns detailed information about score computation as part of a * hit. * * API name: {@code explain} */ @Nullable public final Boolean explain() { return this.explain; } /** * Array of wildcard (*) patterns. The request returns values for field names * matching these patterns in the hits.fields property of the response. * * API name: {@code fields} */ public final List fields() { return this.fields; } /** * Starting document offset. By default, you cannot page through more than * 10,000 hits using the from and size parameters. To page through more hits, * use the search_after parameter. * * API name: {@code from} */ @Nullable public final Integer from() { return this.from; } /** * API name: {@code highlight} */ @Nullable public final Highlight highlight() { return this.highlight; } /** * Whether specified concrete, expanded or aliased indices should be ignored * when throttled * * API name: {@code ignore_throttled} */ @Nullable public final Boolean ignoreThrottled() { return this.ignoreThrottled; } /** * Whether specified concrete indices should be ignored when unavailable * (missing or closed) * * API name: {@code ignore_unavailable} */ @Nullable public final Boolean ignoreUnavailable() { return this.ignoreUnavailable; } /** * A comma-separated list of index names to search; use _all or * empty string to perform the operation on all indices * * API name: {@code index} */ public final List index() { return this.index; } /** * Boosts the _score of documents from specified indices. * * API name: {@code indices_boost} */ public final List> indicesBoost() { return this.indicesBoost; } /** * Update the time interval in which the results (partial or final) for this * search will be available * * API name: {@code keep_alive} */ @Nullable public final Time keepAlive() { return this.keepAlive; } /** * Control whether the response should be stored in the cluster if it completed * within the provided [wait_for_completion] time (default: false) * * API name: {@code keep_on_completion} */ @Nullable public final Boolean keepOnCompletion() { return this.keepOnCompletion; } /** * Specify whether format-based query failures (such as providing text to a * numeric field) should be ignored * * API name: {@code lenient} */ @Nullable public final Boolean lenient() { return this.lenient; } /** * The number of concurrent shard requests per node this search executes * concurrently. This value should be used to limit the impact of the search on * the cluster in order to limit the number of concurrent shard requests * * API name: {@code max_concurrent_shard_requests} */ @Nullable public final Long maxConcurrentShardRequests() { return this.maxConcurrentShardRequests; } /** * API name: {@code min_compatible_shard_node} */ @Nullable public final String minCompatibleShardNode() { return this.minCompatibleShardNode; } /** * Minimum _score for matching documents. Documents with a lower _score are not * included in the search results. * * API name: {@code min_score} */ @Nullable public final Double minScore() { return this.minScore; } /** * Limits the search to a point in time (PIT). If you provide a PIT, you cannot * specify an <index> in the request path. * * API name: {@code pit} */ @Nullable public final PointInTimeReference pit() { return this.pit; } /** * API name: {@code post_filter} */ @Nullable public final Query postFilter() { return this.postFilter; } /** * API name: {@code pre_filter_shard_size} */ @Nullable public final Long preFilterShardSize() { return this.preFilterShardSize; } /** * Specify the node or shard the operation should be performed on (default: * random) * * API name: {@code preference} */ @Nullable public final String preference() { return this.preference; } /** * API name: {@code profile} */ @Nullable public final Boolean profile() { return this.profile; } /** * Query in the Lucene query string syntax * * API name: {@code q} */ @Nullable public final String q() { return this.q; } /** * Defines the search definition using the Query DSL. * * API name: {@code query} */ @Nullable public final Query query() { return this.query; } /** * Specify if request cache should be used for this request or not, defaults to * true * * API name: {@code request_cache} */ @Nullable public final Boolean requestCache() { return this.requestCache; } /** * API name: {@code rescore} */ public final List rescore() { return this.rescore; } /** * A comma-separated list of specific routing values * * API name: {@code routing} */ @Nullable public final String routing() { return this.routing; } /** * Defines one or more runtime fields in the search request. These fields take * precedence over mapped fields with the same name. * * API name: {@code runtime_mappings} */ public final Map> runtimeMappings() { return this.runtimeMappings; } /** * Retrieve a script evaluation (based on different fields) for each hit. * * API name: {@code script_fields} */ public final Map scriptFields() { return this.scriptFields; } /** * API name: {@code scroll} */ @Nullable public final Time scroll() { return this.scroll; } /** * API name: {@code search_after} */ public final List searchAfter() { return this.searchAfter; } /** * Search operation type * * API name: {@code search_type} */ @Nullable public final SearchType searchType() { return this.searchType; } /** * If true, returns sequence number and primary term of the last modification of * each hit. See Optimistic concurrency control. * * API name: {@code seq_no_primary_term} */ @Nullable public final Boolean seqNoPrimaryTerm() { return this.seqNoPrimaryTerm; } /** * The number of hits to return. By default, you cannot page through more than * 10,000 hits using the from and size parameters. To page through more hits, * use the search_after parameter. * * API name: {@code size} */ @Nullable public final Integer size() { return this.size; } /** * API name: {@code slice} */ @Nullable public final SlicedScroll slice() { return this.slice; } /** * API name: {@code sort} */ public final List sort() { return this.sort; } /** * Stats groups to associate with the search. Each group maintains a statistics * aggregation for its associated searches. You can retrieve these stats using * the indices stats API. * * API name: {@code stats} */ public final List stats() { return this.stats; } /** * List of stored fields to return as part of a hit. If no fields are specified, * no stored fields are included in the response. If this field is specified, * the _source parameter defaults to false. You can pass _source: true to return * both source fields and stored fields in the search response. * * API name: {@code stored_fields} */ public final List storedFields() { return this.storedFields; } /** * API name: {@code suggest} */ @Nullable public final Suggester suggest() { return this.suggest; } /** * Maximum number of documents to collect for each shard. If a query reaches * this limit, Elasticsearch terminates the query early. Elasticsearch collects * documents before sorting. Defaults to 0, which does not terminate query * execution early. * * API name: {@code terminate_after} */ @Nullable public final Long terminateAfter() { return this.terminateAfter; } /** * Specifies the period of time to wait for a response from each shard. If no * response is received before the timeout expires, the request fails and * returns an error. Defaults to no timeout. * * API name: {@code timeout} */ @Nullable public final String timeout() { return this.timeout; } /** * If true, calculate and return document scores, even if the scores are not * used for sorting. * * API name: {@code track_scores} */ @Nullable public final Boolean trackScores() { return this.trackScores; } /** * Number of hits matching the query to count accurately. If true, the exact * number of hits is returned at the cost of some performance. If false, the * response does not include the total number of hits matching the query. * Defaults to 10,000 hits. * * API name: {@code track_total_hits} */ @Nullable public final TrackHits trackTotalHits() { return this.trackTotalHits; } /** * If true, returns document version as part of a hit. * * API name: {@code version} */ @Nullable public final Boolean version() { return this.version; } /** * Specify the time that the request should block waiting for the final response * * API name: {@code wait_for_completion_timeout} */ @Nullable public final Time waitForCompletionTimeout() { return this.waitForCompletionTimeout; } /** * 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.source != null) { generator.writeKey("_source"); this.source.serialize(generator, mapper); } if (ApiTypeHelper.isDefined(this.aggregations)) { generator.writeKey("aggregations"); generator.writeStartObject(); for (Map.Entry item0 : this.aggregations.entrySet()) { generator.writeKey(item0.getKey()); item0.getValue().serialize(generator, mapper); } generator.writeEnd(); } if (this.collapse != null) { generator.writeKey("collapse"); this.collapse.serialize(generator, mapper); } if (ApiTypeHelper.isDefined(this.docvalueFields)) { generator.writeKey("docvalue_fields"); generator.writeStartArray(); for (FieldAndFormat item0 : this.docvalueFields) { item0.serialize(generator, mapper); } generator.writeEnd(); } if (this.explain != null) { generator.writeKey("explain"); generator.write(this.explain); } if (ApiTypeHelper.isDefined(this.fields)) { generator.writeKey("fields"); generator.writeStartArray(); for (FieldAndFormat item0 : this.fields) { item0.serialize(generator, mapper); } generator.writeEnd(); } if (this.from != null) { generator.writeKey("from"); generator.write(this.from); } if (this.highlight != null) { generator.writeKey("highlight"); this.highlight.serialize(generator, mapper); } if (ApiTypeHelper.isDefined(this.indicesBoost)) { generator.writeKey("indices_boost"); generator.writeStartArray(); for (Map item0 : this.indicesBoost) { generator.writeStartObject(); if (item0 != null) { for (Map.Entry item1 : item0.entrySet()) { generator.writeKey(item1.getKey()); generator.write(item1.getValue()); } } generator.writeEnd(); } generator.writeEnd(); } if (this.minScore != null) { generator.writeKey("min_score"); generator.write(this.minScore); } if (this.pit != null) { generator.writeKey("pit"); this.pit.serialize(generator, mapper); } if (this.postFilter != null) { generator.writeKey("post_filter"); this.postFilter.serialize(generator, mapper); } if (this.profile != null) { generator.writeKey("profile"); generator.write(this.profile); } if (this.query != null) { generator.writeKey("query"); this.query.serialize(generator, mapper); } if (ApiTypeHelper.isDefined(this.rescore)) { generator.writeKey("rescore"); generator.writeStartArray(); for (Rescore item0 : this.rescore) { item0.serialize(generator, mapper); } generator.writeEnd(); } if (ApiTypeHelper.isDefined(this.runtimeMappings)) { generator.writeKey("runtime_mappings"); generator.writeStartObject(); for (Map.Entry> item0 : this.runtimeMappings.entrySet()) { generator.writeKey(item0.getKey()); generator.writeStartArray(); if (item0.getValue() != null) { for (RuntimeField item1 : item0.getValue()) { item1.serialize(generator, mapper); } } generator.writeEnd(); } generator.writeEnd(); } if (ApiTypeHelper.isDefined(this.scriptFields)) { generator.writeKey("script_fields"); generator.writeStartObject(); for (Map.Entry item0 : this.scriptFields.entrySet()) { generator.writeKey(item0.getKey()); item0.getValue().serialize(generator, mapper); } generator.writeEnd(); } if (ApiTypeHelper.isDefined(this.searchAfter)) { generator.writeKey("search_after"); generator.writeStartArray(); for (String item0 : this.searchAfter) { generator.write(item0); } generator.writeEnd(); } if (this.seqNoPrimaryTerm != null) { generator.writeKey("seq_no_primary_term"); generator.write(this.seqNoPrimaryTerm); } if (this.size != null) { generator.writeKey("size"); generator.write(this.size); } if (this.slice != null) { generator.writeKey("slice"); this.slice.serialize(generator, mapper); } if (ApiTypeHelper.isDefined(this.sort)) { generator.writeKey("sort"); generator.writeStartArray(); for (SortOptions item0 : this.sort) { item0.serialize(generator, mapper); } generator.writeEnd(); } if (ApiTypeHelper.isDefined(this.stats)) { generator.writeKey("stats"); generator.writeStartArray(); for (String item0 : this.stats) { generator.write(item0); } generator.writeEnd(); } if (ApiTypeHelper.isDefined(this.storedFields)) { generator.writeKey("stored_fields"); generator.writeStartArray(); for (String item0 : this.storedFields) { generator.write(item0); } generator.writeEnd(); } if (this.suggest != null) { generator.writeKey("suggest"); this.suggest.serialize(generator, mapper); } if (this.terminateAfter != null) { generator.writeKey("terminate_after"); generator.write(this.terminateAfter); } if (this.timeout != null) { generator.writeKey("timeout"); generator.write(this.timeout); } if (this.trackScores != null) { generator.writeKey("track_scores"); generator.write(this.trackScores); } if (this.trackTotalHits != null) { generator.writeKey("track_total_hits"); this.trackTotalHits.serialize(generator, mapper); } if (this.version != null) { generator.writeKey("version"); generator.write(this.version); } } // --------------------------------------------------------------------------------------------- /** * Builder for {@link SubmitRequest}. */ public static class Builder extends WithJsonObjectBuilderBase implements ObjectBuilder { @Nullable private SourceConfig source; @Nullable private Map aggregations; @Nullable private Boolean allowNoIndices; @Nullable private Boolean allowPartialSearchResults; @Nullable private Boolean analyzeWildcard; @Nullable private String analyzer; @Nullable private Long batchedReduceSize; @Nullable private Boolean ccsMinimizeRoundtrips; @Nullable private FieldCollapse collapse; @Nullable private Operator defaultOperator; @Nullable private String df; @Nullable private List docvalueFields; @Nullable private List expandWildcards; @Nullable private Boolean explain; @Nullable private List fields; @Nullable private Integer from; @Nullable private Highlight highlight; @Nullable private Boolean ignoreThrottled; @Nullable private Boolean ignoreUnavailable; @Nullable private List index; @Nullable private List> indicesBoost; @Nullable private Time keepAlive; @Nullable private Boolean keepOnCompletion; @Nullable private Boolean lenient; @Nullable private Long maxConcurrentShardRequests; @Nullable private String minCompatibleShardNode; @Nullable private Double minScore; @Nullable private PointInTimeReference pit; @Nullable private Query postFilter; @Nullable private Long preFilterShardSize; @Nullable private String preference; @Nullable private Boolean profile; @Nullable private String q; @Nullable private Query query; @Nullable private Boolean requestCache; @Nullable private List rescore; @Nullable private String routing; @Nullable private Map> runtimeMappings; @Nullable private Map scriptFields; @Nullable private Time scroll; @Nullable private List searchAfter; @Nullable private SearchType searchType; @Nullable private Boolean seqNoPrimaryTerm; @Nullable private Integer size; @Nullable private SlicedScroll slice; @Nullable private List sort; @Nullable private List stats; @Nullable private List storedFields; @Nullable private Suggester suggest; @Nullable private Long terminateAfter; @Nullable private String timeout; @Nullable private Boolean trackScores; @Nullable private TrackHits trackTotalHits; @Nullable private Boolean version; @Nullable private Time waitForCompletionTimeout; /** * Indicates which source fields are returned for matching documents. These * fields are returned in the hits._source property of the search response. * * API name: {@code _source} */ public final Builder source(@Nullable SourceConfig value) { this.source = value; return this; } /** * Indicates which source fields are returned for matching documents. These * fields are returned in the hits._source property of the search response. * * API name: {@code _source} */ public final Builder source(Function> fn) { return this.source(fn.apply(new SourceConfig.Builder()).build()); } /** * API name: {@code aggregations} * * Adds all entries of map to aggregations. */ public final Builder aggregations(Map map) { this.aggregations = _mapPutAll(this.aggregations, map); return this; } /** * API name: {@code aggregations} * * Adds an entry to aggregations. */ public final Builder aggregations(String key, Aggregation value) { this.aggregations = _mapPut(this.aggregations, key, value); return this; } /** * API name: {@code aggregations} * * Adds an entry to aggregations using a builder lambda. */ public final Builder aggregations(String key, Function> fn) { return aggregations(key, fn.apply(new Aggregation.Builder()).build()); } /** * Whether to ignore if a wildcard indices expression resolves into no concrete * indices. (This includes _all string or when no indices have been * specified) * * API name: {@code allow_no_indices} */ public final Builder allowNoIndices(@Nullable Boolean value) { this.allowNoIndices = value; return this; } /** * Indicate if an error should be returned if there is a partial search failure * or timeout * * API name: {@code allow_partial_search_results} */ public final Builder allowPartialSearchResults(@Nullable Boolean value) { this.allowPartialSearchResults = value; return this; } /** * Specify whether wildcard and prefix queries should be analyzed (default: * false) * * API name: {@code analyze_wildcard} */ public final Builder analyzeWildcard(@Nullable Boolean value) { this.analyzeWildcard = value; return this; } /** * The analyzer to use for the query string * * API name: {@code analyzer} */ public final Builder analyzer(@Nullable String value) { this.analyzer = value; return this; } /** * The number of shard results that should be reduced at once on the * coordinating node. This value should be used as the granularity at which * progress results will be made available. * * API name: {@code batched_reduce_size} */ public final Builder batchedReduceSize(@Nullable Long value) { this.batchedReduceSize = value; return this; } /** * API name: {@code ccs_minimize_roundtrips} */ public final Builder ccsMinimizeRoundtrips(@Nullable Boolean value) { this.ccsMinimizeRoundtrips = value; return this; } /** * API name: {@code collapse} */ public final Builder collapse(@Nullable FieldCollapse value) { this.collapse = value; return this; } /** * API name: {@code collapse} */ public final Builder collapse(Function> fn) { return this.collapse(fn.apply(new FieldCollapse.Builder()).build()); } /** * The default operator for query string query (AND or OR) * * API name: {@code default_operator} */ public final Builder defaultOperator(@Nullable Operator value) { this.defaultOperator = value; return this; } /** * The field to use as default where no field prefix is given in the query * string * * API name: {@code df} */ public final Builder df(@Nullable String value) { this.df = value; return this; } /** * Array of wildcard (*) patterns. The request returns doc values for field * names matching these patterns in the hits.fields property of the response. * * API name: {@code docvalue_fields} * * Adds all elements of list to docvalueFields. */ public final Builder docvalueFields(List list) { this.docvalueFields = _listAddAll(this.docvalueFields, list); return this; } /** * Array of wildcard (*) patterns. The request returns doc values for field * names matching these patterns in the hits.fields property of the response. * * API name: {@code docvalue_fields} * * Adds one or more values to docvalueFields. */ public final Builder docvalueFields(FieldAndFormat value, FieldAndFormat... values) { this.docvalueFields = _listAdd(this.docvalueFields, value, values); return this; } /** * Array of wildcard (*) patterns. The request returns doc values for field * names matching these patterns in the hits.fields property of the response. * * API name: {@code docvalue_fields} * * Adds a value to docvalueFields using a builder lambda. */ public final Builder docvalueFields(Function> fn) { return docvalueFields(fn.apply(new FieldAndFormat.Builder()).build()); } /** * Whether to expand wildcard expression to concrete indices that are open, * closed or both. * * API name: {@code expand_wildcards} * * Adds all elements of list to expandWildcards. */ public final Builder expandWildcards(List list) { this.expandWildcards = _listAddAll(this.expandWildcards, list); return this; } /** * Whether to expand wildcard expression to concrete indices that are open, * closed or both. * * API name: {@code expand_wildcards} * * Adds one or more values to expandWildcards. */ public final Builder expandWildcards(ExpandWildcard value, ExpandWildcard... values) { this.expandWildcards = _listAdd(this.expandWildcards, value, values); return this; } /** * If true, returns detailed information about score computation as part of a * hit. * * API name: {@code explain} */ public final Builder explain(@Nullable Boolean value) { this.explain = value; return this; } /** * Array of wildcard (*) patterns. The request returns values for field names * matching these patterns in the hits.fields property of the response. * * API name: {@code fields} * * Adds all elements of list to fields. */ public final Builder fields(List list) { this.fields = _listAddAll(this.fields, list); return this; } /** * Array of wildcard (*) patterns. The request returns values for field names * matching these patterns in the hits.fields property of the response. * * API name: {@code fields} * * Adds one or more values to fields. */ public final Builder fields(FieldAndFormat value, FieldAndFormat... values) { this.fields = _listAdd(this.fields, value, values); return this; } /** * Array of wildcard (*) patterns. The request returns values for field names * matching these patterns in the hits.fields property of the response. * * API name: {@code fields} * * Adds a value to fields using a builder lambda. */ public final Builder fields(Function> fn) { return fields(fn.apply(new FieldAndFormat.Builder()).build()); } /** * Starting document offset. By default, you cannot page through more than * 10,000 hits using the from and size parameters. To page through more hits, * use the search_after parameter. * * API name: {@code from} */ public final Builder from(@Nullable Integer value) { this.from = value; return this; } /** * API name: {@code highlight} */ public final Builder highlight(@Nullable Highlight value) { this.highlight = value; return this; } /** * API name: {@code highlight} */ public final Builder highlight(Function> fn) { return this.highlight(fn.apply(new Highlight.Builder()).build()); } /** * Whether specified concrete, expanded or aliased indices should be ignored * when throttled * * API name: {@code ignore_throttled} */ public final Builder ignoreThrottled(@Nullable Boolean value) { this.ignoreThrottled = value; return this; } /** * Whether specified concrete indices should be ignored when unavailable * (missing or closed) * * API name: {@code ignore_unavailable} */ public final Builder ignoreUnavailable(@Nullable Boolean value) { this.ignoreUnavailable = value; return this; } /** * A comma-separated list of index names to search; use _all or * empty string to perform the operation on all indices * * API name: {@code index} * * Adds all elements of list to index. */ public final Builder index(List list) { this.index = _listAddAll(this.index, list); return this; } /** * A comma-separated list of index names to search; use _all or * empty string to perform the operation on all indices * * API name: {@code index} * * Adds one or more values to index. */ public final Builder index(String value, String... values) { this.index = _listAdd(this.index, value, values); return this; } /** * Boosts the _score of documents from specified indices. * * API name: {@code indices_boost} * * Adds all elements of list to indicesBoost. */ public final Builder indicesBoost(List> list) { this.indicesBoost = _listAddAll(this.indicesBoost, list); return this; } /** * Boosts the _score of documents from specified indices. * * API name: {@code indices_boost} * * Adds one or more values to indicesBoost. */ public final Builder indicesBoost(Map value, Map... values) { this.indicesBoost = _listAdd(this.indicesBoost, value, values); return this; } /** * Update the time interval in which the results (partial or final) for this * search will be available * * API name: {@code keep_alive} */ public final Builder keepAlive(@Nullable Time value) { this.keepAlive = value; return this; } /** * Update the time interval in which the results (partial or final) for this * search will be available * * API name: {@code keep_alive} */ public final Builder keepAlive(Function> fn) { return this.keepAlive(fn.apply(new Time.Builder()).build()); } /** * Control whether the response should be stored in the cluster if it completed * within the provided [wait_for_completion] time (default: false) * * API name: {@code keep_on_completion} */ public final Builder keepOnCompletion(@Nullable Boolean value) { this.keepOnCompletion = value; return this; } /** * Specify whether format-based query failures (such as providing text to a * numeric field) should be ignored * * API name: {@code lenient} */ public final Builder lenient(@Nullable Boolean value) { this.lenient = value; return this; } /** * The number of concurrent shard requests per node this search executes * concurrently. This value should be used to limit the impact of the search on * the cluster in order to limit the number of concurrent shard requests * * API name: {@code max_concurrent_shard_requests} */ public final Builder maxConcurrentShardRequests(@Nullable Long value) { this.maxConcurrentShardRequests = value; return this; } /** * API name: {@code min_compatible_shard_node} */ public final Builder minCompatibleShardNode(@Nullable String value) { this.minCompatibleShardNode = value; return this; } /** * Minimum _score for matching documents. Documents with a lower _score are not * included in the search results. * * API name: {@code min_score} */ public final Builder minScore(@Nullable Double value) { this.minScore = value; return this; } /** * Limits the search to a point in time (PIT). If you provide a PIT, you cannot * specify an <index> in the request path. * * API name: {@code pit} */ public final Builder pit(@Nullable PointInTimeReference value) { this.pit = value; return this; } /** * Limits the search to a point in time (PIT). If you provide a PIT, you cannot * specify an <index> in the request path. * * API name: {@code pit} */ public final Builder pit(Function> fn) { return this.pit(fn.apply(new PointInTimeReference.Builder()).build()); } /** * API name: {@code post_filter} */ public final Builder postFilter(@Nullable Query value) { this.postFilter = value; return this; } /** * API name: {@code post_filter} */ public final Builder postFilter(Function> fn) { return this.postFilter(fn.apply(new Query.Builder()).build()); } /** * API name: {@code pre_filter_shard_size} */ public final Builder preFilterShardSize(@Nullable Long value) { this.preFilterShardSize = value; return this; } /** * Specify the node or shard the operation should be performed on (default: * random) * * API name: {@code preference} */ public final Builder preference(@Nullable String value) { this.preference = value; return this; } /** * API name: {@code profile} */ public final Builder profile(@Nullable Boolean value) { this.profile = value; return this; } /** * Query in the Lucene query string syntax * * API name: {@code q} */ public final Builder q(@Nullable String value) { this.q = value; return this; } /** * Defines the search definition using the Query DSL. * * API name: {@code query} */ public final Builder query(@Nullable Query value) { this.query = value; return this; } /** * Defines the search definition using the Query DSL. * * API name: {@code query} */ public final Builder query(Function> fn) { return this.query(fn.apply(new Query.Builder()).build()); } /** * Specify if request cache should be used for this request or not, defaults to * true * * API name: {@code request_cache} */ public final Builder requestCache(@Nullable Boolean value) { this.requestCache = value; return this; } /** * API name: {@code rescore} * * Adds all elements of list to rescore. */ public final Builder rescore(List list) { this.rescore = _listAddAll(this.rescore, list); return this; } /** * API name: {@code rescore} * * Adds one or more values to rescore. */ public final Builder rescore(Rescore value, Rescore... values) { this.rescore = _listAdd(this.rescore, value, values); return this; } /** * API name: {@code rescore} * * Adds a value to rescore using a builder lambda. */ public final Builder rescore(Function> fn) { return rescore(fn.apply(new Rescore.Builder()).build()); } /** * A comma-separated list of specific routing values * * API name: {@code routing} */ public final Builder routing(@Nullable String value) { this.routing = value; return this; } /** * Defines one or more runtime fields in the search request. These fields take * precedence over mapped fields with the same name. * * API name: {@code runtime_mappings} * * Adds all entries of map to runtimeMappings. */ public final Builder runtimeMappings(Map> map) { this.runtimeMappings = _mapPutAll(this.runtimeMappings, map); return this; } /** * Defines one or more runtime fields in the search request. These fields take * precedence over mapped fields with the same name. * * API name: {@code runtime_mappings} * * Adds an entry to runtimeMappings. */ public final Builder runtimeMappings(String key, List value) { this.runtimeMappings = _mapPut(this.runtimeMappings, key, value); return this; } /** * Retrieve a script evaluation (based on different fields) for each hit. * * API name: {@code script_fields} * * Adds all entries of map to scriptFields. */ public final Builder scriptFields(Map map) { this.scriptFields = _mapPutAll(this.scriptFields, map); return this; } /** * Retrieve a script evaluation (based on different fields) for each hit. * * API name: {@code script_fields} * * Adds an entry to scriptFields. */ public final Builder scriptFields(String key, ScriptField value) { this.scriptFields = _mapPut(this.scriptFields, key, value); return this; } /** * Retrieve a script evaluation (based on different fields) for each hit. * * API name: {@code script_fields} * * Adds an entry to scriptFields using a builder lambda. */ public final Builder scriptFields(String key, Function> fn) { return scriptFields(key, fn.apply(new ScriptField.Builder()).build()); } /** * API name: {@code scroll} */ public final Builder scroll(@Nullable Time value) { this.scroll = value; return this; } /** * API name: {@code scroll} */ public final Builder scroll(Function> fn) { return this.scroll(fn.apply(new Time.Builder()).build()); } /** * API name: {@code search_after} * * Adds all elements of list to searchAfter. */ public final Builder searchAfter(List list) { this.searchAfter = _listAddAll(this.searchAfter, list); return this; } /** * API name: {@code search_after} * * Adds one or more values to searchAfter. */ public final Builder searchAfter(String value, String... values) { this.searchAfter = _listAdd(this.searchAfter, value, values); return this; } /** * Search operation type * * API name: {@code search_type} */ public final Builder searchType(@Nullable SearchType value) { this.searchType = value; return this; } /** * If true, returns sequence number and primary term of the last modification of * each hit. See Optimistic concurrency control. * * API name: {@code seq_no_primary_term} */ public final Builder seqNoPrimaryTerm(@Nullable Boolean value) { this.seqNoPrimaryTerm = value; return this; } /** * The number of hits to return. By default, you cannot page through more than * 10,000 hits using the from and size parameters. To page through more hits, * use the search_after parameter. * * API name: {@code size} */ public final Builder size(@Nullable Integer value) { this.size = value; return this; } /** * API name: {@code slice} */ public final Builder slice(@Nullable SlicedScroll value) { this.slice = value; return this; } /** * API name: {@code slice} */ public final Builder slice(Function> fn) { return this.slice(fn.apply(new SlicedScroll.Builder()).build()); } /** * API name: {@code sort} * * Adds all elements of list to sort. */ public final Builder sort(List list) { this.sort = _listAddAll(this.sort, list); return this; } /** * API name: {@code sort} * * Adds one or more values to sort. */ public final Builder sort(SortOptions value, SortOptions... values) { this.sort = _listAdd(this.sort, value, values); return this; } /** * API name: {@code sort} * * Adds a value to sort using a builder lambda. */ public final Builder sort(Function> fn) { return sort(fn.apply(new SortOptions.Builder()).build()); } /** * Stats groups to associate with the search. Each group maintains a statistics * aggregation for its associated searches. You can retrieve these stats using * the indices stats API. * * API name: {@code stats} * * Adds all elements of list to stats. */ public final Builder stats(List list) { this.stats = _listAddAll(this.stats, list); return this; } /** * Stats groups to associate with the search. Each group maintains a statistics * aggregation for its associated searches. You can retrieve these stats using * the indices stats API. * * API name: {@code stats} * * Adds one or more values to stats. */ public final Builder stats(String value, String... values) { this.stats = _listAdd(this.stats, value, values); return this; } /** * List of stored fields to return as part of a hit. If no fields are specified, * no stored fields are included in the response. If this field is specified, * the _source parameter defaults to false. You can pass _source: true to return * both source fields and stored fields in the search response. * * API name: {@code stored_fields} * * Adds all elements of list to storedFields. */ public final Builder storedFields(List list) { this.storedFields = _listAddAll(this.storedFields, list); return this; } /** * List of stored fields to return as part of a hit. If no fields are specified, * no stored fields are included in the response. If this field is specified, * the _source parameter defaults to false. You can pass _source: true to return * both source fields and stored fields in the search response. * * API name: {@code stored_fields} * * Adds one or more values to storedFields. */ public final Builder storedFields(String value, String... values) { this.storedFields = _listAdd(this.storedFields, value, values); return this; } /** * API name: {@code suggest} */ public final Builder suggest(@Nullable Suggester value) { this.suggest = value; return this; } /** * API name: {@code suggest} */ public final Builder suggest(Function> fn) { return this.suggest(fn.apply(new Suggester.Builder()).build()); } /** * Maximum number of documents to collect for each shard. If a query reaches * this limit, Elasticsearch terminates the query early. Elasticsearch collects * documents before sorting. Defaults to 0, which does not terminate query * execution early. * * API name: {@code terminate_after} */ public final Builder terminateAfter(@Nullable Long value) { this.terminateAfter = value; return this; } /** * Specifies the period of time to wait for a response from each shard. If no * response is received before the timeout expires, the request fails and * returns an error. Defaults to no timeout. * * API name: {@code timeout} */ public final Builder timeout(@Nullable String value) { this.timeout = value; return this; } /** * If true, calculate and return document scores, even if the scores are not * used for sorting. * * API name: {@code track_scores} */ public final Builder trackScores(@Nullable Boolean value) { this.trackScores = value; return this; } /** * Number of hits matching the query to count accurately. If true, the exact * number of hits is returned at the cost of some performance. If false, the * response does not include the total number of hits matching the query. * Defaults to 10,000 hits. * * API name: {@code track_total_hits} */ public final Builder trackTotalHits(@Nullable TrackHits value) { this.trackTotalHits = value; return this; } /** * Number of hits matching the query to count accurately. If true, the exact * number of hits is returned at the cost of some performance. If false, the * response does not include the total number of hits matching the query. * Defaults to 10,000 hits. * * API name: {@code track_total_hits} */ public final Builder trackTotalHits(Function> fn) { return this.trackTotalHits(fn.apply(new TrackHits.Builder()).build()); } /** * If true, returns document version as part of a hit. * * API name: {@code version} */ public final Builder version(@Nullable Boolean value) { this.version = value; return this; } /** * Specify the time that the request should block waiting for the final response * * API name: {@code wait_for_completion_timeout} */ public final Builder waitForCompletionTimeout(@Nullable Time value) { this.waitForCompletionTimeout = value; return this; } /** * Specify the time that the request should block waiting for the final response * * API name: {@code wait_for_completion_timeout} */ public final Builder waitForCompletionTimeout(Function> fn) { return this.waitForCompletionTimeout(fn.apply(new Time.Builder()).build()); } @Override protected Builder self() { return this; } /** * Builds a {@link SubmitRequest}. * * @throws NullPointerException * if some of the required fields are null. */ public SubmitRequest build() { _checkSingleUse(); return new SubmitRequest(this); } } // --------------------------------------------------------------------------------------------- /** * Json deserializer for {@link SubmitRequest} */ public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy(Builder::new, SubmitRequest::setupSubmitRequestDeserializer); protected static void setupSubmitRequestDeserializer(ObjectDeserializer op) { op.add(Builder::source, SourceConfig._DESERIALIZER, "_source"); op.add(Builder::aggregations, JsonpDeserializer.stringMapDeserializer(Aggregation._DESERIALIZER), "aggregations", "aggs"); op.add(Builder::collapse, FieldCollapse._DESERIALIZER, "collapse"); op.add(Builder::docvalueFields, JsonpDeserializer.arrayDeserializer(FieldAndFormat._DESERIALIZER), "docvalue_fields"); op.add(Builder::explain, JsonpDeserializer.booleanDeserializer(), "explain"); op.add(Builder::fields, JsonpDeserializer.arrayDeserializer(FieldAndFormat._DESERIALIZER), "fields"); op.add(Builder::from, JsonpDeserializer.integerDeserializer(), "from"); op.add(Builder::highlight, Highlight._DESERIALIZER, "highlight"); op.add(Builder::indicesBoost, JsonpDeserializer.arrayDeserializer( JsonpDeserializer.stringMapDeserializer(JsonpDeserializer.doubleDeserializer())), "indices_boost"); op.add(Builder::minScore, JsonpDeserializer.doubleDeserializer(), "min_score"); op.add(Builder::pit, PointInTimeReference._DESERIALIZER, "pit"); op.add(Builder::postFilter, Query._DESERIALIZER, "post_filter"); op.add(Builder::profile, JsonpDeserializer.booleanDeserializer(), "profile"); op.add(Builder::query, Query._DESERIALIZER, "query"); op.add(Builder::rescore, JsonpDeserializer.arrayDeserializer(Rescore._DESERIALIZER), "rescore"); op.add(Builder::runtimeMappings, JsonpDeserializer.stringMapDeserializer( JsonpDeserializer.arrayDeserializer(RuntimeField._DESERIALIZER)), "runtime_mappings"); op.add(Builder::scriptFields, JsonpDeserializer.stringMapDeserializer(ScriptField._DESERIALIZER), "script_fields"); op.add(Builder::searchAfter, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "search_after"); op.add(Builder::seqNoPrimaryTerm, JsonpDeserializer.booleanDeserializer(), "seq_no_primary_term"); op.add(Builder::size, JsonpDeserializer.integerDeserializer(), "size"); op.add(Builder::slice, SlicedScroll._DESERIALIZER, "slice"); op.add(Builder::sort, JsonpDeserializer.arrayDeserializer(SortOptions._DESERIALIZER), "sort"); op.add(Builder::stats, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "stats"); op.add(Builder::storedFields, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "stored_fields"); op.add(Builder::suggest, Suggester._DESERIALIZER, "suggest"); op.add(Builder::terminateAfter, JsonpDeserializer.longDeserializer(), "terminate_after"); op.add(Builder::timeout, JsonpDeserializer.stringDeserializer(), "timeout"); op.add(Builder::trackScores, JsonpDeserializer.booleanDeserializer(), "track_scores"); op.add(Builder::trackTotalHits, TrackHits._DESERIALIZER, "track_total_hits"); op.add(Builder::version, JsonpDeserializer.booleanDeserializer(), "version"); } // --------------------------------------------------------------------------------------------- /** * Endpoint "{@code async_search.submit}". */ public static final SimpleEndpoint _ENDPOINT = new SimpleEndpoint<>("es/async_search.submit", // Request method request -> { return "POST"; }, // Request path request -> { final int _index = 1 << 0; int propsSet = 0; if (ApiTypeHelper.isDefined(request.index())) propsSet |= _index; if (propsSet == 0) { StringBuilder buf = new StringBuilder(); buf.append("/_async_search"); return buf.toString(); } if (propsSet == (_index)) { StringBuilder buf = new StringBuilder(); buf.append("/"); SimpleEndpoint.pathEncode(request.index.stream().map(v -> v).collect(Collectors.joining(",")), buf); buf.append("/_async_search"); return buf.toString(); } throw SimpleEndpoint.noPathTemplateFound("path"); }, // Request parameters request -> { Map params = new HashMap<>(); params.put("typed_keys", "true"); if (request.df != null) { params.put("df", request.df); } if (request.preFilterShardSize != null) { params.put("pre_filter_shard_size", String.valueOf(request.preFilterShardSize)); } if (request.minCompatibleShardNode != null) { params.put("min_compatible_shard_node", request.minCompatibleShardNode); } if (request.lenient != null) { params.put("lenient", String.valueOf(request.lenient)); } if (request.routing != null) { params.put("routing", request.routing); } if (request.ignoreUnavailable != null) { params.put("ignore_unavailable", String.valueOf(request.ignoreUnavailable)); } if (request.allowNoIndices != null) { params.put("allow_no_indices", String.valueOf(request.allowNoIndices)); } if (request.analyzer != null) { params.put("analyzer", request.analyzer); } if (request.ignoreThrottled != null) { params.put("ignore_throttled", String.valueOf(request.ignoreThrottled)); } if (request.keepOnCompletion != null) { params.put("keep_on_completion", String.valueOf(request.keepOnCompletion)); } if (request.maxConcurrentShardRequests != null) { params.put("max_concurrent_shard_requests", String.valueOf(request.maxConcurrentShardRequests)); } if (request.allowPartialSearchResults != null) { params.put("allow_partial_search_results", String.valueOf(request.allowPartialSearchResults)); } if (ApiTypeHelper.isDefined(request.expandWildcards)) { params.put("expand_wildcards", request.expandWildcards.stream().map(v -> v.jsonValue()).collect(Collectors.joining(","))); } if (request.preference != null) { params.put("preference", request.preference); } if (request.analyzeWildcard != null) { params.put("analyze_wildcard", String.valueOf(request.analyzeWildcard)); } if (request.scroll != null) { params.put("scroll", request.scroll._toJsonString()); } if (request.waitForCompletionTimeout != null) { params.put("wait_for_completion_timeout", request.waitForCompletionTimeout._toJsonString()); } if (request.searchType != null) { params.put("search_type", request.searchType.jsonValue()); } if (request.ccsMinimizeRoundtrips != null) { params.put("ccs_minimize_roundtrips", String.valueOf(request.ccsMinimizeRoundtrips)); } if (request.q != null) { params.put("q", request.q); } if (request.defaultOperator != null) { params.put("default_operator", request.defaultOperator.jsonValue()); } if (request.keepAlive != null) { params.put("keep_alive", request.keepAlive._toJsonString()); } if (request.requestCache != null) { params.put("request_cache", String.valueOf(request.requestCache)); } if (request.batchedReduceSize != null) { params.put("batched_reduce_size", String.valueOf(request.batchedReduceSize)); } return params; }, SimpleEndpoint.emptyMap(), true, SubmitResponse._DESERIALIZER); /** * Create an "{@code async_search.submit}" endpoint. */ public static Endpoint, ErrorResponse> createSubmitEndpoint( JsonpDeserializer tDocumentDeserializer) { return _ENDPOINT .withResponseDeserializer(SubmitResponse.createSubmitResponseDeserializer(tDocumentDeserializer)); } }
* API name: {@code _source} */ @Nullable public final SourceConfig source() { return this.source; } /** * API name: {@code aggregations} */ public final Map aggregations() { return this.aggregations; } /** * Whether to ignore if a wildcard indices expression resolves into no concrete * indices. (This includes _all string or when no indices have been * specified) * * API name: {@code allow_no_indices} */ @Nullable public final Boolean allowNoIndices() { return this.allowNoIndices; } /** * Indicate if an error should be returned if there is a partial search failure * or timeout * * API name: {@code allow_partial_search_results} */ @Nullable public final Boolean allowPartialSearchResults() { return this.allowPartialSearchResults; } /** * Specify whether wildcard and prefix queries should be analyzed (default: * false) * * API name: {@code analyze_wildcard} */ @Nullable public final Boolean analyzeWildcard() { return this.analyzeWildcard; } /** * The analyzer to use for the query string * * API name: {@code analyzer} */ @Nullable public final String analyzer() { return this.analyzer; } /** * The number of shard results that should be reduced at once on the * coordinating node. This value should be used as the granularity at which * progress results will be made available. * * API name: {@code batched_reduce_size} */ @Nullable public final Long batchedReduceSize() { return this.batchedReduceSize; } /** * API name: {@code ccs_minimize_roundtrips} */ @Nullable public final Boolean ccsMinimizeRoundtrips() { return this.ccsMinimizeRoundtrips; } /** * API name: {@code collapse} */ @Nullable public final FieldCollapse collapse() { return this.collapse; } /** * The default operator for query string query (AND or OR) * * API name: {@code default_operator} */ @Nullable public final Operator defaultOperator() { return this.defaultOperator; } /** * The field to use as default where no field prefix is given in the query * string * * API name: {@code df} */ @Nullable public final String df() { return this.df; } /** * Array of wildcard (*) patterns. The request returns doc values for field * names matching these patterns in the hits.fields property of the response. * * API name: {@code docvalue_fields} */ public final List docvalueFields() { return this.docvalueFields; } /** * Whether to expand wildcard expression to concrete indices that are open, * closed or both. * * API name: {@code expand_wildcards} */ public final List expandWildcards() { return this.expandWildcards; } /** * If true, returns detailed information about score computation as part of a * hit. * * API name: {@code explain} */ @Nullable public final Boolean explain() { return this.explain; } /** * Array of wildcard (*) patterns. The request returns values for field names * matching these patterns in the hits.fields property of the response. * * API name: {@code fields} */ public final List fields() { return this.fields; } /** * Starting document offset. By default, you cannot page through more than * 10,000 hits using the from and size parameters. To page through more hits, * use the search_after parameter. * * API name: {@code from} */ @Nullable public final Integer from() { return this.from; } /** * API name: {@code highlight} */ @Nullable public final Highlight highlight() { return this.highlight; } /** * Whether specified concrete, expanded or aliased indices should be ignored * when throttled * * API name: {@code ignore_throttled} */ @Nullable public final Boolean ignoreThrottled() { return this.ignoreThrottled; } /** * Whether specified concrete indices should be ignored when unavailable * (missing or closed) * * API name: {@code ignore_unavailable} */ @Nullable public final Boolean ignoreUnavailable() { return this.ignoreUnavailable; } /** * A comma-separated list of index names to search; use _all or * empty string to perform the operation on all indices * * API name: {@code index} */ public final List index() { return this.index; } /** * Boosts the _score of documents from specified indices. * * API name: {@code indices_boost} */ public final List> indicesBoost() { return this.indicesBoost; } /** * Update the time interval in which the results (partial or final) for this * search will be available * * API name: {@code keep_alive} */ @Nullable public final Time keepAlive() { return this.keepAlive; } /** * Control whether the response should be stored in the cluster if it completed * within the provided [wait_for_completion] time (default: false) * * API name: {@code keep_on_completion} */ @Nullable public final Boolean keepOnCompletion() { return this.keepOnCompletion; } /** * Specify whether format-based query failures (such as providing text to a * numeric field) should be ignored * * API name: {@code lenient} */ @Nullable public final Boolean lenient() { return this.lenient; } /** * The number of concurrent shard requests per node this search executes * concurrently. This value should be used to limit the impact of the search on * the cluster in order to limit the number of concurrent shard requests * * API name: {@code max_concurrent_shard_requests} */ @Nullable public final Long maxConcurrentShardRequests() { return this.maxConcurrentShardRequests; } /** * API name: {@code min_compatible_shard_node} */ @Nullable public final String minCompatibleShardNode() { return this.minCompatibleShardNode; } /** * Minimum _score for matching documents. Documents with a lower _score are not * included in the search results. * * API name: {@code min_score} */ @Nullable public final Double minScore() { return this.minScore; } /** * Limits the search to a point in time (PIT). If you provide a PIT, you cannot * specify an <index> in the request path. * * API name: {@code pit} */ @Nullable public final PointInTimeReference pit() { return this.pit; } /** * API name: {@code post_filter} */ @Nullable public final Query postFilter() { return this.postFilter; } /** * API name: {@code pre_filter_shard_size} */ @Nullable public final Long preFilterShardSize() { return this.preFilterShardSize; } /** * Specify the node or shard the operation should be performed on (default: * random) * * API name: {@code preference} */ @Nullable public final String preference() { return this.preference; } /** * API name: {@code profile} */ @Nullable public final Boolean profile() { return this.profile; } /** * Query in the Lucene query string syntax * * API name: {@code q} */ @Nullable public final String q() { return this.q; } /** * Defines the search definition using the Query DSL. * * API name: {@code query} */ @Nullable public final Query query() { return this.query; } /** * Specify if request cache should be used for this request or not, defaults to * true * * API name: {@code request_cache} */ @Nullable public final Boolean requestCache() { return this.requestCache; } /** * API name: {@code rescore} */ public final List rescore() { return this.rescore; } /** * A comma-separated list of specific routing values * * API name: {@code routing} */ @Nullable public final String routing() { return this.routing; } /** * Defines one or more runtime fields in the search request. These fields take * precedence over mapped fields with the same name. * * API name: {@code runtime_mappings} */ public final Map> runtimeMappings() { return this.runtimeMappings; } /** * Retrieve a script evaluation (based on different fields) for each hit. * * API name: {@code script_fields} */ public final Map scriptFields() { return this.scriptFields; } /** * API name: {@code scroll} */ @Nullable public final Time scroll() { return this.scroll; } /** * API name: {@code search_after} */ public final List searchAfter() { return this.searchAfter; } /** * Search operation type * * API name: {@code search_type} */ @Nullable public final SearchType searchType() { return this.searchType; } /** * If true, returns sequence number and primary term of the last modification of * each hit. See Optimistic concurrency control. * * API name: {@code seq_no_primary_term} */ @Nullable public final Boolean seqNoPrimaryTerm() { return this.seqNoPrimaryTerm; } /** * The number of hits to return. By default, you cannot page through more than * 10,000 hits using the from and size parameters. To page through more hits, * use the search_after parameter. * * API name: {@code size} */ @Nullable public final Integer size() { return this.size; } /** * API name: {@code slice} */ @Nullable public final SlicedScroll slice() { return this.slice; } /** * API name: {@code sort} */ public final List sort() { return this.sort; } /** * Stats groups to associate with the search. Each group maintains a statistics * aggregation for its associated searches. You can retrieve these stats using * the indices stats API. * * API name: {@code stats} */ public final List stats() { return this.stats; } /** * List of stored fields to return as part of a hit. If no fields are specified, * no stored fields are included in the response. If this field is specified, * the _source parameter defaults to false. You can pass _source: true to return * both source fields and stored fields in the search response. * * API name: {@code stored_fields} */ public final List storedFields() { return this.storedFields; } /** * API name: {@code suggest} */ @Nullable public final Suggester suggest() { return this.suggest; } /** * Maximum number of documents to collect for each shard. If a query reaches * this limit, Elasticsearch terminates the query early. Elasticsearch collects * documents before sorting. Defaults to 0, which does not terminate query * execution early. * * API name: {@code terminate_after} */ @Nullable public final Long terminateAfter() { return this.terminateAfter; } /** * Specifies the period of time to wait for a response from each shard. If no * response is received before the timeout expires, the request fails and * returns an error. Defaults to no timeout. * * API name: {@code timeout} */ @Nullable public final String timeout() { return this.timeout; } /** * If true, calculate and return document scores, even if the scores are not * used for sorting. * * API name: {@code track_scores} */ @Nullable public final Boolean trackScores() { return this.trackScores; } /** * Number of hits matching the query to count accurately. If true, the exact * number of hits is returned at the cost of some performance. If false, the * response does not include the total number of hits matching the query. * Defaults to 10,000 hits. * * API name: {@code track_total_hits} */ @Nullable public final TrackHits trackTotalHits() { return this.trackTotalHits; } /** * If true, returns document version as part of a hit. * * API name: {@code version} */ @Nullable public final Boolean version() { return this.version; } /** * Specify the time that the request should block waiting for the final response * * API name: {@code wait_for_completion_timeout} */ @Nullable public final Time waitForCompletionTimeout() { return this.waitForCompletionTimeout; } /** * 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.source != null) { generator.writeKey("_source"); this.source.serialize(generator, mapper); } if (ApiTypeHelper.isDefined(this.aggregations)) { generator.writeKey("aggregations"); generator.writeStartObject(); for (Map.Entry item0 : this.aggregations.entrySet()) { generator.writeKey(item0.getKey()); item0.getValue().serialize(generator, mapper); } generator.writeEnd(); } if (this.collapse != null) { generator.writeKey("collapse"); this.collapse.serialize(generator, mapper); } if (ApiTypeHelper.isDefined(this.docvalueFields)) { generator.writeKey("docvalue_fields"); generator.writeStartArray(); for (FieldAndFormat item0 : this.docvalueFields) { item0.serialize(generator, mapper); } generator.writeEnd(); } if (this.explain != null) { generator.writeKey("explain"); generator.write(this.explain); } if (ApiTypeHelper.isDefined(this.fields)) { generator.writeKey("fields"); generator.writeStartArray(); for (FieldAndFormat item0 : this.fields) { item0.serialize(generator, mapper); } generator.writeEnd(); } if (this.from != null) { generator.writeKey("from"); generator.write(this.from); } if (this.highlight != null) { generator.writeKey("highlight"); this.highlight.serialize(generator, mapper); } if (ApiTypeHelper.isDefined(this.indicesBoost)) { generator.writeKey("indices_boost"); generator.writeStartArray(); for (Map item0 : this.indicesBoost) { generator.writeStartObject(); if (item0 != null) { for (Map.Entry item1 : item0.entrySet()) { generator.writeKey(item1.getKey()); generator.write(item1.getValue()); } } generator.writeEnd(); } generator.writeEnd(); } if (this.minScore != null) { generator.writeKey("min_score"); generator.write(this.minScore); } if (this.pit != null) { generator.writeKey("pit"); this.pit.serialize(generator, mapper); } if (this.postFilter != null) { generator.writeKey("post_filter"); this.postFilter.serialize(generator, mapper); } if (this.profile != null) { generator.writeKey("profile"); generator.write(this.profile); } if (this.query != null) { generator.writeKey("query"); this.query.serialize(generator, mapper); } if (ApiTypeHelper.isDefined(this.rescore)) { generator.writeKey("rescore"); generator.writeStartArray(); for (Rescore item0 : this.rescore) { item0.serialize(generator, mapper); } generator.writeEnd(); } if (ApiTypeHelper.isDefined(this.runtimeMappings)) { generator.writeKey("runtime_mappings"); generator.writeStartObject(); for (Map.Entry> item0 : this.runtimeMappings.entrySet()) { generator.writeKey(item0.getKey()); generator.writeStartArray(); if (item0.getValue() != null) { for (RuntimeField item1 : item0.getValue()) { item1.serialize(generator, mapper); } } generator.writeEnd(); } generator.writeEnd(); } if (ApiTypeHelper.isDefined(this.scriptFields)) { generator.writeKey("script_fields"); generator.writeStartObject(); for (Map.Entry item0 : this.scriptFields.entrySet()) { generator.writeKey(item0.getKey()); item0.getValue().serialize(generator, mapper); } generator.writeEnd(); } if (ApiTypeHelper.isDefined(this.searchAfter)) { generator.writeKey("search_after"); generator.writeStartArray(); for (String item0 : this.searchAfter) { generator.write(item0); } generator.writeEnd(); } if (this.seqNoPrimaryTerm != null) { generator.writeKey("seq_no_primary_term"); generator.write(this.seqNoPrimaryTerm); } if (this.size != null) { generator.writeKey("size"); generator.write(this.size); } if (this.slice != null) { generator.writeKey("slice"); this.slice.serialize(generator, mapper); } if (ApiTypeHelper.isDefined(this.sort)) { generator.writeKey("sort"); generator.writeStartArray(); for (SortOptions item0 : this.sort) { item0.serialize(generator, mapper); } generator.writeEnd(); } if (ApiTypeHelper.isDefined(this.stats)) { generator.writeKey("stats"); generator.writeStartArray(); for (String item0 : this.stats) { generator.write(item0); } generator.writeEnd(); } if (ApiTypeHelper.isDefined(this.storedFields)) { generator.writeKey("stored_fields"); generator.writeStartArray(); for (String item0 : this.storedFields) { generator.write(item0); } generator.writeEnd(); } if (this.suggest != null) { generator.writeKey("suggest"); this.suggest.serialize(generator, mapper); } if (this.terminateAfter != null) { generator.writeKey("terminate_after"); generator.write(this.terminateAfter); } if (this.timeout != null) { generator.writeKey("timeout"); generator.write(this.timeout); } if (this.trackScores != null) { generator.writeKey("track_scores"); generator.write(this.trackScores); } if (this.trackTotalHits != null) { generator.writeKey("track_total_hits"); this.trackTotalHits.serialize(generator, mapper); } if (this.version != null) { generator.writeKey("version"); generator.write(this.version); } } // --------------------------------------------------------------------------------------------- /** * Builder for {@link SubmitRequest}. */ public static class Builder extends WithJsonObjectBuilderBase implements ObjectBuilder { @Nullable private SourceConfig source; @Nullable private Map aggregations; @Nullable private Boolean allowNoIndices; @Nullable private Boolean allowPartialSearchResults; @Nullable private Boolean analyzeWildcard; @Nullable private String analyzer; @Nullable private Long batchedReduceSize; @Nullable private Boolean ccsMinimizeRoundtrips; @Nullable private FieldCollapse collapse; @Nullable private Operator defaultOperator; @Nullable private String df; @Nullable private List docvalueFields; @Nullable private List expandWildcards; @Nullable private Boolean explain; @Nullable private List fields; @Nullable private Integer from; @Nullable private Highlight highlight; @Nullable private Boolean ignoreThrottled; @Nullable private Boolean ignoreUnavailable; @Nullable private List index; @Nullable private List> indicesBoost; @Nullable private Time keepAlive; @Nullable private Boolean keepOnCompletion; @Nullable private Boolean lenient; @Nullable private Long maxConcurrentShardRequests; @Nullable private String minCompatibleShardNode; @Nullable private Double minScore; @Nullable private PointInTimeReference pit; @Nullable private Query postFilter; @Nullable private Long preFilterShardSize; @Nullable private String preference; @Nullable private Boolean profile; @Nullable private String q; @Nullable private Query query; @Nullable private Boolean requestCache; @Nullable private List rescore; @Nullable private String routing; @Nullable private Map> runtimeMappings; @Nullable private Map scriptFields; @Nullable private Time scroll; @Nullable private List searchAfter; @Nullable private SearchType searchType; @Nullable private Boolean seqNoPrimaryTerm; @Nullable private Integer size; @Nullable private SlicedScroll slice; @Nullable private List sort; @Nullable private List stats; @Nullable private List storedFields; @Nullable private Suggester suggest; @Nullable private Long terminateAfter; @Nullable private String timeout; @Nullable private Boolean trackScores; @Nullable private TrackHits trackTotalHits; @Nullable private Boolean version; @Nullable private Time waitForCompletionTimeout; /** * Indicates which source fields are returned for matching documents. These * fields are returned in the hits._source property of the search response. * * API name: {@code _source} */ public final Builder source(@Nullable SourceConfig value) { this.source = value; return this; } /** * Indicates which source fields are returned for matching documents. These * fields are returned in the hits._source property of the search response. * * API name: {@code _source} */ public final Builder source(Function> fn) { return this.source(fn.apply(new SourceConfig.Builder()).build()); } /** * API name: {@code aggregations} * * Adds all entries of map to aggregations. */ public final Builder aggregations(Map map) { this.aggregations = _mapPutAll(this.aggregations, map); return this; } /** * API name: {@code aggregations} * * Adds an entry to aggregations. */ public final Builder aggregations(String key, Aggregation value) { this.aggregations = _mapPut(this.aggregations, key, value); return this; } /** * API name: {@code aggregations} * * Adds an entry to aggregations using a builder lambda. */ public final Builder aggregations(String key, Function> fn) { return aggregations(key, fn.apply(new Aggregation.Builder()).build()); } /** * Whether to ignore if a wildcard indices expression resolves into no concrete * indices. (This includes _all string or when no indices have been * specified) * * API name: {@code allow_no_indices} */ public final Builder allowNoIndices(@Nullable Boolean value) { this.allowNoIndices = value; return this; } /** * Indicate if an error should be returned if there is a partial search failure * or timeout * * API name: {@code allow_partial_search_results} */ public final Builder allowPartialSearchResults(@Nullable Boolean value) { this.allowPartialSearchResults = value; return this; } /** * Specify whether wildcard and prefix queries should be analyzed (default: * false) * * API name: {@code analyze_wildcard} */ public final Builder analyzeWildcard(@Nullable Boolean value) { this.analyzeWildcard = value; return this; } /** * The analyzer to use for the query string * * API name: {@code analyzer} */ public final Builder analyzer(@Nullable String value) { this.analyzer = value; return this; } /** * The number of shard results that should be reduced at once on the * coordinating node. This value should be used as the granularity at which * progress results will be made available. * * API name: {@code batched_reduce_size} */ public final Builder batchedReduceSize(@Nullable Long value) { this.batchedReduceSize = value; return this; } /** * API name: {@code ccs_minimize_roundtrips} */ public final Builder ccsMinimizeRoundtrips(@Nullable Boolean value) { this.ccsMinimizeRoundtrips = value; return this; } /** * API name: {@code collapse} */ public final Builder collapse(@Nullable FieldCollapse value) { this.collapse = value; return this; } /** * API name: {@code collapse} */ public final Builder collapse(Function> fn) { return this.collapse(fn.apply(new FieldCollapse.Builder()).build()); } /** * The default operator for query string query (AND or OR) * * API name: {@code default_operator} */ public final Builder defaultOperator(@Nullable Operator value) { this.defaultOperator = value; return this; } /** * The field to use as default where no field prefix is given in the query * string * * API name: {@code df} */ public final Builder df(@Nullable String value) { this.df = value; return this; } /** * Array of wildcard (*) patterns. The request returns doc values for field * names matching these patterns in the hits.fields property of the response. * * API name: {@code docvalue_fields} * * Adds all elements of list to docvalueFields. */ public final Builder docvalueFields(List list) { this.docvalueFields = _listAddAll(this.docvalueFields, list); return this; } /** * Array of wildcard (*) patterns. The request returns doc values for field * names matching these patterns in the hits.fields property of the response. * * API name: {@code docvalue_fields} * * Adds one or more values to docvalueFields. */ public final Builder docvalueFields(FieldAndFormat value, FieldAndFormat... values) { this.docvalueFields = _listAdd(this.docvalueFields, value, values); return this; } /** * Array of wildcard (*) patterns. The request returns doc values for field * names matching these patterns in the hits.fields property of the response. * * API name: {@code docvalue_fields} * * Adds a value to docvalueFields using a builder lambda. */ public final Builder docvalueFields(Function> fn) { return docvalueFields(fn.apply(new FieldAndFormat.Builder()).build()); } /** * Whether to expand wildcard expression to concrete indices that are open, * closed or both. * * API name: {@code expand_wildcards} * * Adds all elements of list to expandWildcards. */ public final Builder expandWildcards(List list) { this.expandWildcards = _listAddAll(this.expandWildcards, list); return this; } /** * Whether to expand wildcard expression to concrete indices that are open, * closed or both. * * API name: {@code expand_wildcards} * * Adds one or more values to expandWildcards. */ public final Builder expandWildcards(ExpandWildcard value, ExpandWildcard... values) { this.expandWildcards = _listAdd(this.expandWildcards, value, values); return this; } /** * If true, returns detailed information about score computation as part of a * hit. * * API name: {@code explain} */ public final Builder explain(@Nullable Boolean value) { this.explain = value; return this; } /** * Array of wildcard (*) patterns. The request returns values for field names * matching these patterns in the hits.fields property of the response. * * API name: {@code fields} * * Adds all elements of list to fields. */ public final Builder fields(List list) { this.fields = _listAddAll(this.fields, list); return this; } /** * Array of wildcard (*) patterns. The request returns values for field names * matching these patterns in the hits.fields property of the response. * * API name: {@code fields} * * Adds one or more values to fields. */ public final Builder fields(FieldAndFormat value, FieldAndFormat... values) { this.fields = _listAdd(this.fields, value, values); return this; } /** * Array of wildcard (*) patterns. The request returns values for field names * matching these patterns in the hits.fields property of the response. * * API name: {@code fields} * * Adds a value to fields using a builder lambda. */ public final Builder fields(Function> fn) { return fields(fn.apply(new FieldAndFormat.Builder()).build()); } /** * Starting document offset. By default, you cannot page through more than * 10,000 hits using the from and size parameters. To page through more hits, * use the search_after parameter. * * API name: {@code from} */ public final Builder from(@Nullable Integer value) { this.from = value; return this; } /** * API name: {@code highlight} */ public final Builder highlight(@Nullable Highlight value) { this.highlight = value; return this; } /** * API name: {@code highlight} */ public final Builder highlight(Function> fn) { return this.highlight(fn.apply(new Highlight.Builder()).build()); } /** * Whether specified concrete, expanded or aliased indices should be ignored * when throttled * * API name: {@code ignore_throttled} */ public final Builder ignoreThrottled(@Nullable Boolean value) { this.ignoreThrottled = value; return this; } /** * Whether specified concrete indices should be ignored when unavailable * (missing or closed) * * API name: {@code ignore_unavailable} */ public final Builder ignoreUnavailable(@Nullable Boolean value) { this.ignoreUnavailable = value; return this; } /** * A comma-separated list of index names to search; use _all or * empty string to perform the operation on all indices * * API name: {@code index} * * Adds all elements of list to index. */ public final Builder index(List list) { this.index = _listAddAll(this.index, list); return this; } /** * A comma-separated list of index names to search; use _all or * empty string to perform the operation on all indices * * API name: {@code index} * * Adds one or more values to index. */ public final Builder index(String value, String... values) { this.index = _listAdd(this.index, value, values); return this; } /** * Boosts the _score of documents from specified indices. * * API name: {@code indices_boost} * * Adds all elements of list to indicesBoost. */ public final Builder indicesBoost(List> list) { this.indicesBoost = _listAddAll(this.indicesBoost, list); return this; } /** * Boosts the _score of documents from specified indices. * * API name: {@code indices_boost} * * Adds one or more values to indicesBoost. */ public final Builder indicesBoost(Map value, Map... values) { this.indicesBoost = _listAdd(this.indicesBoost, value, values); return this; } /** * Update the time interval in which the results (partial or final) for this * search will be available * * API name: {@code keep_alive} */ public final Builder keepAlive(@Nullable Time value) { this.keepAlive = value; return this; } /** * Update the time interval in which the results (partial or final) for this * search will be available * * API name: {@code keep_alive} */ public final Builder keepAlive(Function> fn) { return this.keepAlive(fn.apply(new Time.Builder()).build()); } /** * Control whether the response should be stored in the cluster if it completed * within the provided [wait_for_completion] time (default: false) * * API name: {@code keep_on_completion} */ public final Builder keepOnCompletion(@Nullable Boolean value) { this.keepOnCompletion = value; return this; } /** * Specify whether format-based query failures (such as providing text to a * numeric field) should be ignored * * API name: {@code lenient} */ public final Builder lenient(@Nullable Boolean value) { this.lenient = value; return this; } /** * The number of concurrent shard requests per node this search executes * concurrently. This value should be used to limit the impact of the search on * the cluster in order to limit the number of concurrent shard requests * * API name: {@code max_concurrent_shard_requests} */ public final Builder maxConcurrentShardRequests(@Nullable Long value) { this.maxConcurrentShardRequests = value; return this; } /** * API name: {@code min_compatible_shard_node} */ public final Builder minCompatibleShardNode(@Nullable String value) { this.minCompatibleShardNode = value; return this; } /** * Minimum _score for matching documents. Documents with a lower _score are not * included in the search results. * * API name: {@code min_score} */ public final Builder minScore(@Nullable Double value) { this.minScore = value; return this; } /** * Limits the search to a point in time (PIT). If you provide a PIT, you cannot * specify an <index> in the request path. * * API name: {@code pit} */ public final Builder pit(@Nullable PointInTimeReference value) { this.pit = value; return this; } /** * Limits the search to a point in time (PIT). If you provide a PIT, you cannot * specify an <index> in the request path. * * API name: {@code pit} */ public final Builder pit(Function> fn) { return this.pit(fn.apply(new PointInTimeReference.Builder()).build()); } /** * API name: {@code post_filter} */ public final Builder postFilter(@Nullable Query value) { this.postFilter = value; return this; } /** * API name: {@code post_filter} */ public final Builder postFilter(Function> fn) { return this.postFilter(fn.apply(new Query.Builder()).build()); } /** * API name: {@code pre_filter_shard_size} */ public final Builder preFilterShardSize(@Nullable Long value) { this.preFilterShardSize = value; return this; } /** * Specify the node or shard the operation should be performed on (default: * random) * * API name: {@code preference} */ public final Builder preference(@Nullable String value) { this.preference = value; return this; } /** * API name: {@code profile} */ public final Builder profile(@Nullable Boolean value) { this.profile = value; return this; } /** * Query in the Lucene query string syntax * * API name: {@code q} */ public final Builder q(@Nullable String value) { this.q = value; return this; } /** * Defines the search definition using the Query DSL. * * API name: {@code query} */ public final Builder query(@Nullable Query value) { this.query = value; return this; } /** * Defines the search definition using the Query DSL. * * API name: {@code query} */ public final Builder query(Function> fn) { return this.query(fn.apply(new Query.Builder()).build()); } /** * Specify if request cache should be used for this request or not, defaults to * true * * API name: {@code request_cache} */ public final Builder requestCache(@Nullable Boolean value) { this.requestCache = value; return this; } /** * API name: {@code rescore} * * Adds all elements of list to rescore. */ public final Builder rescore(List list) { this.rescore = _listAddAll(this.rescore, list); return this; } /** * API name: {@code rescore} * * Adds one or more values to rescore. */ public final Builder rescore(Rescore value, Rescore... values) { this.rescore = _listAdd(this.rescore, value, values); return this; } /** * API name: {@code rescore} * * Adds a value to rescore using a builder lambda. */ public final Builder rescore(Function> fn) { return rescore(fn.apply(new Rescore.Builder()).build()); } /** * A comma-separated list of specific routing values * * API name: {@code routing} */ public final Builder routing(@Nullable String value) { this.routing = value; return this; } /** * Defines one or more runtime fields in the search request. These fields take * precedence over mapped fields with the same name. * * API name: {@code runtime_mappings} * * Adds all entries of map to runtimeMappings. */ public final Builder runtimeMappings(Map> map) { this.runtimeMappings = _mapPutAll(this.runtimeMappings, map); return this; } /** * Defines one or more runtime fields in the search request. These fields take * precedence over mapped fields with the same name. * * API name: {@code runtime_mappings} * * Adds an entry to runtimeMappings. */ public final Builder runtimeMappings(String key, List value) { this.runtimeMappings = _mapPut(this.runtimeMappings, key, value); return this; } /** * Retrieve a script evaluation (based on different fields) for each hit. * * API name: {@code script_fields} * * Adds all entries of map to scriptFields. */ public final Builder scriptFields(Map map) { this.scriptFields = _mapPutAll(this.scriptFields, map); return this; } /** * Retrieve a script evaluation (based on different fields) for each hit. * * API name: {@code script_fields} * * Adds an entry to scriptFields. */ public final Builder scriptFields(String key, ScriptField value) { this.scriptFields = _mapPut(this.scriptFields, key, value); return this; } /** * Retrieve a script evaluation (based on different fields) for each hit. * * API name: {@code script_fields} * * Adds an entry to scriptFields using a builder lambda. */ public final Builder scriptFields(String key, Function> fn) { return scriptFields(key, fn.apply(new ScriptField.Builder()).build()); } /** * API name: {@code scroll} */ public final Builder scroll(@Nullable Time value) { this.scroll = value; return this; } /** * API name: {@code scroll} */ public final Builder scroll(Function> fn) { return this.scroll(fn.apply(new Time.Builder()).build()); } /** * API name: {@code search_after} * * Adds all elements of list to searchAfter. */ public final Builder searchAfter(List list) { this.searchAfter = _listAddAll(this.searchAfter, list); return this; } /** * API name: {@code search_after} * * Adds one or more values to searchAfter. */ public final Builder searchAfter(String value, String... values) { this.searchAfter = _listAdd(this.searchAfter, value, values); return this; } /** * Search operation type * * API name: {@code search_type} */ public final Builder searchType(@Nullable SearchType value) { this.searchType = value; return this; } /** * If true, returns sequence number and primary term of the last modification of * each hit. See Optimistic concurrency control. * * API name: {@code seq_no_primary_term} */ public final Builder seqNoPrimaryTerm(@Nullable Boolean value) { this.seqNoPrimaryTerm = value; return this; } /** * The number of hits to return. By default, you cannot page through more than * 10,000 hits using the from and size parameters. To page through more hits, * use the search_after parameter. * * API name: {@code size} */ public final Builder size(@Nullable Integer value) { this.size = value; return this; } /** * API name: {@code slice} */ public final Builder slice(@Nullable SlicedScroll value) { this.slice = value; return this; } /** * API name: {@code slice} */ public final Builder slice(Function> fn) { return this.slice(fn.apply(new SlicedScroll.Builder()).build()); } /** * API name: {@code sort} * * Adds all elements of list to sort. */ public final Builder sort(List list) { this.sort = _listAddAll(this.sort, list); return this; } /** * API name: {@code sort} * * Adds one or more values to sort. */ public final Builder sort(SortOptions value, SortOptions... values) { this.sort = _listAdd(this.sort, value, values); return this; } /** * API name: {@code sort} * * Adds a value to sort using a builder lambda. */ public final Builder sort(Function> fn) { return sort(fn.apply(new SortOptions.Builder()).build()); } /** * Stats groups to associate with the search. Each group maintains a statistics * aggregation for its associated searches. You can retrieve these stats using * the indices stats API. * * API name: {@code stats} * * Adds all elements of list to stats. */ public final Builder stats(List list) { this.stats = _listAddAll(this.stats, list); return this; } /** * Stats groups to associate with the search. Each group maintains a statistics * aggregation for its associated searches. You can retrieve these stats using * the indices stats API. * * API name: {@code stats} * * Adds one or more values to stats. */ public final Builder stats(String value, String... values) { this.stats = _listAdd(this.stats, value, values); return this; } /** * List of stored fields to return as part of a hit. If no fields are specified, * no stored fields are included in the response. If this field is specified, * the _source parameter defaults to false. You can pass _source: true to return * both source fields and stored fields in the search response. * * API name: {@code stored_fields} * * Adds all elements of list to storedFields. */ public final Builder storedFields(List list) { this.storedFields = _listAddAll(this.storedFields, list); return this; } /** * List of stored fields to return as part of a hit. If no fields are specified, * no stored fields are included in the response. If this field is specified, * the _source parameter defaults to false. You can pass _source: true to return * both source fields and stored fields in the search response. * * API name: {@code stored_fields} * * Adds one or more values to storedFields. */ public final Builder storedFields(String value, String... values) { this.storedFields = _listAdd(this.storedFields, value, values); return this; } /** * API name: {@code suggest} */ public final Builder suggest(@Nullable Suggester value) { this.suggest = value; return this; } /** * API name: {@code suggest} */ public final Builder suggest(Function> fn) { return this.suggest(fn.apply(new Suggester.Builder()).build()); } /** * Maximum number of documents to collect for each shard. If a query reaches * this limit, Elasticsearch terminates the query early. Elasticsearch collects * documents before sorting. Defaults to 0, which does not terminate query * execution early. * * API name: {@code terminate_after} */ public final Builder terminateAfter(@Nullable Long value) { this.terminateAfter = value; return this; } /** * Specifies the period of time to wait for a response from each shard. If no * response is received before the timeout expires, the request fails and * returns an error. Defaults to no timeout. * * API name: {@code timeout} */ public final Builder timeout(@Nullable String value) { this.timeout = value; return this; } /** * If true, calculate and return document scores, even if the scores are not * used for sorting. * * API name: {@code track_scores} */ public final Builder trackScores(@Nullable Boolean value) { this.trackScores = value; return this; } /** * Number of hits matching the query to count accurately. If true, the exact * number of hits is returned at the cost of some performance. If false, the * response does not include the total number of hits matching the query. * Defaults to 10,000 hits. * * API name: {@code track_total_hits} */ public final Builder trackTotalHits(@Nullable TrackHits value) { this.trackTotalHits = value; return this; } /** * Number of hits matching the query to count accurately. If true, the exact * number of hits is returned at the cost of some performance. If false, the * response does not include the total number of hits matching the query. * Defaults to 10,000 hits. * * API name: {@code track_total_hits} */ public final Builder trackTotalHits(Function> fn) { return this.trackTotalHits(fn.apply(new TrackHits.Builder()).build()); } /** * If true, returns document version as part of a hit. * * API name: {@code version} */ public final Builder version(@Nullable Boolean value) { this.version = value; return this; } /** * Specify the time that the request should block waiting for the final response * * API name: {@code wait_for_completion_timeout} */ public final Builder waitForCompletionTimeout(@Nullable Time value) { this.waitForCompletionTimeout = value; return this; } /** * Specify the time that the request should block waiting for the final response * * API name: {@code wait_for_completion_timeout} */ public final Builder waitForCompletionTimeout(Function> fn) { return this.waitForCompletionTimeout(fn.apply(new Time.Builder()).build()); } @Override protected Builder self() { return this; } /** * Builds a {@link SubmitRequest}. * * @throws NullPointerException * if some of the required fields are null. */ public SubmitRequest build() { _checkSingleUse(); return new SubmitRequest(this); } } // --------------------------------------------------------------------------------------------- /** * Json deserializer for {@link SubmitRequest} */ public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy(Builder::new, SubmitRequest::setupSubmitRequestDeserializer); protected static void setupSubmitRequestDeserializer(ObjectDeserializer op) { op.add(Builder::source, SourceConfig._DESERIALIZER, "_source"); op.add(Builder::aggregations, JsonpDeserializer.stringMapDeserializer(Aggregation._DESERIALIZER), "aggregations", "aggs"); op.add(Builder::collapse, FieldCollapse._DESERIALIZER, "collapse"); op.add(Builder::docvalueFields, JsonpDeserializer.arrayDeserializer(FieldAndFormat._DESERIALIZER), "docvalue_fields"); op.add(Builder::explain, JsonpDeserializer.booleanDeserializer(), "explain"); op.add(Builder::fields, JsonpDeserializer.arrayDeserializer(FieldAndFormat._DESERIALIZER), "fields"); op.add(Builder::from, JsonpDeserializer.integerDeserializer(), "from"); op.add(Builder::highlight, Highlight._DESERIALIZER, "highlight"); op.add(Builder::indicesBoost, JsonpDeserializer.arrayDeserializer( JsonpDeserializer.stringMapDeserializer(JsonpDeserializer.doubleDeserializer())), "indices_boost"); op.add(Builder::minScore, JsonpDeserializer.doubleDeserializer(), "min_score"); op.add(Builder::pit, PointInTimeReference._DESERIALIZER, "pit"); op.add(Builder::postFilter, Query._DESERIALIZER, "post_filter"); op.add(Builder::profile, JsonpDeserializer.booleanDeserializer(), "profile"); op.add(Builder::query, Query._DESERIALIZER, "query"); op.add(Builder::rescore, JsonpDeserializer.arrayDeserializer(Rescore._DESERIALIZER), "rescore"); op.add(Builder::runtimeMappings, JsonpDeserializer.stringMapDeserializer( JsonpDeserializer.arrayDeserializer(RuntimeField._DESERIALIZER)), "runtime_mappings"); op.add(Builder::scriptFields, JsonpDeserializer.stringMapDeserializer(ScriptField._DESERIALIZER), "script_fields"); op.add(Builder::searchAfter, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "search_after"); op.add(Builder::seqNoPrimaryTerm, JsonpDeserializer.booleanDeserializer(), "seq_no_primary_term"); op.add(Builder::size, JsonpDeserializer.integerDeserializer(), "size"); op.add(Builder::slice, SlicedScroll._DESERIALIZER, "slice"); op.add(Builder::sort, JsonpDeserializer.arrayDeserializer(SortOptions._DESERIALIZER), "sort"); op.add(Builder::stats, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "stats"); op.add(Builder::storedFields, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "stored_fields"); op.add(Builder::suggest, Suggester._DESERIALIZER, "suggest"); op.add(Builder::terminateAfter, JsonpDeserializer.longDeserializer(), "terminate_after"); op.add(Builder::timeout, JsonpDeserializer.stringDeserializer(), "timeout"); op.add(Builder::trackScores, JsonpDeserializer.booleanDeserializer(), "track_scores"); op.add(Builder::trackTotalHits, TrackHits._DESERIALIZER, "track_total_hits"); op.add(Builder::version, JsonpDeserializer.booleanDeserializer(), "version"); } // --------------------------------------------------------------------------------------------- /** * Endpoint "{@code async_search.submit}". */ public static final SimpleEndpoint _ENDPOINT = new SimpleEndpoint<>("es/async_search.submit", // Request method request -> { return "POST"; }, // Request path request -> { final int _index = 1 << 0; int propsSet = 0; if (ApiTypeHelper.isDefined(request.index())) propsSet |= _index; if (propsSet == 0) { StringBuilder buf = new StringBuilder(); buf.append("/_async_search"); return buf.toString(); } if (propsSet == (_index)) { StringBuilder buf = new StringBuilder(); buf.append("/"); SimpleEndpoint.pathEncode(request.index.stream().map(v -> v).collect(Collectors.joining(",")), buf); buf.append("/_async_search"); return buf.toString(); } throw SimpleEndpoint.noPathTemplateFound("path"); }, // Request parameters request -> { Map params = new HashMap<>(); params.put("typed_keys", "true"); if (request.df != null) { params.put("df", request.df); } if (request.preFilterShardSize != null) { params.put("pre_filter_shard_size", String.valueOf(request.preFilterShardSize)); } if (request.minCompatibleShardNode != null) { params.put("min_compatible_shard_node", request.minCompatibleShardNode); } if (request.lenient != null) { params.put("lenient", String.valueOf(request.lenient)); } if (request.routing != null) { params.put("routing", request.routing); } if (request.ignoreUnavailable != null) { params.put("ignore_unavailable", String.valueOf(request.ignoreUnavailable)); } if (request.allowNoIndices != null) { params.put("allow_no_indices", String.valueOf(request.allowNoIndices)); } if (request.analyzer != null) { params.put("analyzer", request.analyzer); } if (request.ignoreThrottled != null) { params.put("ignore_throttled", String.valueOf(request.ignoreThrottled)); } if (request.keepOnCompletion != null) { params.put("keep_on_completion", String.valueOf(request.keepOnCompletion)); } if (request.maxConcurrentShardRequests != null) { params.put("max_concurrent_shard_requests", String.valueOf(request.maxConcurrentShardRequests)); } if (request.allowPartialSearchResults != null) { params.put("allow_partial_search_results", String.valueOf(request.allowPartialSearchResults)); } if (ApiTypeHelper.isDefined(request.expandWildcards)) { params.put("expand_wildcards", request.expandWildcards.stream().map(v -> v.jsonValue()).collect(Collectors.joining(","))); } if (request.preference != null) { params.put("preference", request.preference); } if (request.analyzeWildcard != null) { params.put("analyze_wildcard", String.valueOf(request.analyzeWildcard)); } if (request.scroll != null) { params.put("scroll", request.scroll._toJsonString()); } if (request.waitForCompletionTimeout != null) { params.put("wait_for_completion_timeout", request.waitForCompletionTimeout._toJsonString()); } if (request.searchType != null) { params.put("search_type", request.searchType.jsonValue()); } if (request.ccsMinimizeRoundtrips != null) { params.put("ccs_minimize_roundtrips", String.valueOf(request.ccsMinimizeRoundtrips)); } if (request.q != null) { params.put("q", request.q); } if (request.defaultOperator != null) { params.put("default_operator", request.defaultOperator.jsonValue()); } if (request.keepAlive != null) { params.put("keep_alive", request.keepAlive._toJsonString()); } if (request.requestCache != null) { params.put("request_cache", String.valueOf(request.requestCache)); } if (request.batchedReduceSize != null) { params.put("batched_reduce_size", String.valueOf(request.batchedReduceSize)); } return params; }, SimpleEndpoint.emptyMap(), true, SubmitResponse._DESERIALIZER); /** * Create an "{@code async_search.submit}" endpoint. */ public static Endpoint, ErrorResponse> createSubmitEndpoint( JsonpDeserializer tDocumentDeserializer) { return _ENDPOINT .withResponseDeserializer(SubmitResponse.createSubmitResponseDeserializer(tDocumentDeserializer)); } }
_all
* API name: {@code allow_no_indices} */ @Nullable public final Boolean allowNoIndices() { return this.allowNoIndices; } /** * Indicate if an error should be returned if there is a partial search failure * or timeout *
* API name: {@code allow_partial_search_results} */ @Nullable public final Boolean allowPartialSearchResults() { return this.allowPartialSearchResults; } /** * Specify whether wildcard and prefix queries should be analyzed (default: * false) *
* API name: {@code analyze_wildcard} */ @Nullable public final Boolean analyzeWildcard() { return this.analyzeWildcard; } /** * The analyzer to use for the query string *
* API name: {@code analyzer} */ @Nullable public final String analyzer() { return this.analyzer; } /** * The number of shard results that should be reduced at once on the * coordinating node. This value should be used as the granularity at which * progress results will be made available. *
* API name: {@code batched_reduce_size} */ @Nullable public final Long batchedReduceSize() { return this.batchedReduceSize; } /** * API name: {@code ccs_minimize_roundtrips} */ @Nullable public final Boolean ccsMinimizeRoundtrips() { return this.ccsMinimizeRoundtrips; } /** * API name: {@code collapse} */ @Nullable public final FieldCollapse collapse() { return this.collapse; } /** * The default operator for query string query (AND or OR) *
* API name: {@code default_operator} */ @Nullable public final Operator defaultOperator() { return this.defaultOperator; } /** * The field to use as default where no field prefix is given in the query * string *
* API name: {@code df} */ @Nullable public final String df() { return this.df; } /** * Array of wildcard (*) patterns. The request returns doc values for field * names matching these patterns in the hits.fields property of the response. *
* API name: {@code docvalue_fields} */ public final List docvalueFields() { return this.docvalueFields; } /** * Whether to expand wildcard expression to concrete indices that are open, * closed or both. * * API name: {@code expand_wildcards} */ public final List expandWildcards() { return this.expandWildcards; } /** * If true, returns detailed information about score computation as part of a * hit. * * API name: {@code explain} */ @Nullable public final Boolean explain() { return this.explain; } /** * Array of wildcard (*) patterns. The request returns values for field names * matching these patterns in the hits.fields property of the response. * * API name: {@code fields} */ public final List fields() { return this.fields; } /** * Starting document offset. By default, you cannot page through more than * 10,000 hits using the from and size parameters. To page through more hits, * use the search_after parameter. * * API name: {@code from} */ @Nullable public final Integer from() { return this.from; } /** * API name: {@code highlight} */ @Nullable public final Highlight highlight() { return this.highlight; } /** * Whether specified concrete, expanded or aliased indices should be ignored * when throttled * * API name: {@code ignore_throttled} */ @Nullable public final Boolean ignoreThrottled() { return this.ignoreThrottled; } /** * Whether specified concrete indices should be ignored when unavailable * (missing or closed) * * API name: {@code ignore_unavailable} */ @Nullable public final Boolean ignoreUnavailable() { return this.ignoreUnavailable; } /** * A comma-separated list of index names to search; use _all or * empty string to perform the operation on all indices * * API name: {@code index} */ public final List index() { return this.index; } /** * Boosts the _score of documents from specified indices. * * API name: {@code indices_boost} */ public final List> indicesBoost() { return this.indicesBoost; } /** * Update the time interval in which the results (partial or final) for this * search will be available * * API name: {@code keep_alive} */ @Nullable public final Time keepAlive() { return this.keepAlive; } /** * Control whether the response should be stored in the cluster if it completed * within the provided [wait_for_completion] time (default: false) * * API name: {@code keep_on_completion} */ @Nullable public final Boolean keepOnCompletion() { return this.keepOnCompletion; } /** * Specify whether format-based query failures (such as providing text to a * numeric field) should be ignored * * API name: {@code lenient} */ @Nullable public final Boolean lenient() { return this.lenient; } /** * The number of concurrent shard requests per node this search executes * concurrently. This value should be used to limit the impact of the search on * the cluster in order to limit the number of concurrent shard requests * * API name: {@code max_concurrent_shard_requests} */ @Nullable public final Long maxConcurrentShardRequests() { return this.maxConcurrentShardRequests; } /** * API name: {@code min_compatible_shard_node} */ @Nullable public final String minCompatibleShardNode() { return this.minCompatibleShardNode; } /** * Minimum _score for matching documents. Documents with a lower _score are not * included in the search results. * * API name: {@code min_score} */ @Nullable public final Double minScore() { return this.minScore; } /** * Limits the search to a point in time (PIT). If you provide a PIT, you cannot * specify an <index> in the request path. * * API name: {@code pit} */ @Nullable public final PointInTimeReference pit() { return this.pit; } /** * API name: {@code post_filter} */ @Nullable public final Query postFilter() { return this.postFilter; } /** * API name: {@code pre_filter_shard_size} */ @Nullable public final Long preFilterShardSize() { return this.preFilterShardSize; } /** * Specify the node or shard the operation should be performed on (default: * random) * * API name: {@code preference} */ @Nullable public final String preference() { return this.preference; } /** * API name: {@code profile} */ @Nullable public final Boolean profile() { return this.profile; } /** * Query in the Lucene query string syntax * * API name: {@code q} */ @Nullable public final String q() { return this.q; } /** * Defines the search definition using the Query DSL. * * API name: {@code query} */ @Nullable public final Query query() { return this.query; } /** * Specify if request cache should be used for this request or not, defaults to * true * * API name: {@code request_cache} */ @Nullable public final Boolean requestCache() { return this.requestCache; } /** * API name: {@code rescore} */ public final List rescore() { return this.rescore; } /** * A comma-separated list of specific routing values * * API name: {@code routing} */ @Nullable public final String routing() { return this.routing; } /** * Defines one or more runtime fields in the search request. These fields take * precedence over mapped fields with the same name. * * API name: {@code runtime_mappings} */ public final Map> runtimeMappings() { return this.runtimeMappings; } /** * Retrieve a script evaluation (based on different fields) for each hit. * * API name: {@code script_fields} */ public final Map scriptFields() { return this.scriptFields; } /** * API name: {@code scroll} */ @Nullable public final Time scroll() { return this.scroll; } /** * API name: {@code search_after} */ public final List searchAfter() { return this.searchAfter; } /** * Search operation type * * API name: {@code search_type} */ @Nullable public final SearchType searchType() { return this.searchType; } /** * If true, returns sequence number and primary term of the last modification of * each hit. See Optimistic concurrency control. * * API name: {@code seq_no_primary_term} */ @Nullable public final Boolean seqNoPrimaryTerm() { return this.seqNoPrimaryTerm; } /** * The number of hits to return. By default, you cannot page through more than * 10,000 hits using the from and size parameters. To page through more hits, * use the search_after parameter. * * API name: {@code size} */ @Nullable public final Integer size() { return this.size; } /** * API name: {@code slice} */ @Nullable public final SlicedScroll slice() { return this.slice; } /** * API name: {@code sort} */ public final List sort() { return this.sort; } /** * Stats groups to associate with the search. Each group maintains a statistics * aggregation for its associated searches. You can retrieve these stats using * the indices stats API. * * API name: {@code stats} */ public final List stats() { return this.stats; } /** * List of stored fields to return as part of a hit. If no fields are specified, * no stored fields are included in the response. If this field is specified, * the _source parameter defaults to false. You can pass _source: true to return * both source fields and stored fields in the search response. * * API name: {@code stored_fields} */ public final List storedFields() { return this.storedFields; } /** * API name: {@code suggest} */ @Nullable public final Suggester suggest() { return this.suggest; } /** * Maximum number of documents to collect for each shard. If a query reaches * this limit, Elasticsearch terminates the query early. Elasticsearch collects * documents before sorting. Defaults to 0, which does not terminate query * execution early. * * API name: {@code terminate_after} */ @Nullable public final Long terminateAfter() { return this.terminateAfter; } /** * Specifies the period of time to wait for a response from each shard. If no * response is received before the timeout expires, the request fails and * returns an error. Defaults to no timeout. * * API name: {@code timeout} */ @Nullable public final String timeout() { return this.timeout; } /** * If true, calculate and return document scores, even if the scores are not * used for sorting. * * API name: {@code track_scores} */ @Nullable public final Boolean trackScores() { return this.trackScores; } /** * Number of hits matching the query to count accurately. If true, the exact * number of hits is returned at the cost of some performance. If false, the * response does not include the total number of hits matching the query. * Defaults to 10,000 hits. * * API name: {@code track_total_hits} */ @Nullable public final TrackHits trackTotalHits() { return this.trackTotalHits; } /** * If true, returns document version as part of a hit. * * API name: {@code version} */ @Nullable public final Boolean version() { return this.version; } /** * Specify the time that the request should block waiting for the final response * * API name: {@code wait_for_completion_timeout} */ @Nullable public final Time waitForCompletionTimeout() { return this.waitForCompletionTimeout; } /** * 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.source != null) { generator.writeKey("_source"); this.source.serialize(generator, mapper); } if (ApiTypeHelper.isDefined(this.aggregations)) { generator.writeKey("aggregations"); generator.writeStartObject(); for (Map.Entry item0 : this.aggregations.entrySet()) { generator.writeKey(item0.getKey()); item0.getValue().serialize(generator, mapper); } generator.writeEnd(); } if (this.collapse != null) { generator.writeKey("collapse"); this.collapse.serialize(generator, mapper); } if (ApiTypeHelper.isDefined(this.docvalueFields)) { generator.writeKey("docvalue_fields"); generator.writeStartArray(); for (FieldAndFormat item0 : this.docvalueFields) { item0.serialize(generator, mapper); } generator.writeEnd(); } if (this.explain != null) { generator.writeKey("explain"); generator.write(this.explain); } if (ApiTypeHelper.isDefined(this.fields)) { generator.writeKey("fields"); generator.writeStartArray(); for (FieldAndFormat item0 : this.fields) { item0.serialize(generator, mapper); } generator.writeEnd(); } if (this.from != null) { generator.writeKey("from"); generator.write(this.from); } if (this.highlight != null) { generator.writeKey("highlight"); this.highlight.serialize(generator, mapper); } if (ApiTypeHelper.isDefined(this.indicesBoost)) { generator.writeKey("indices_boost"); generator.writeStartArray(); for (Map item0 : this.indicesBoost) { generator.writeStartObject(); if (item0 != null) { for (Map.Entry item1 : item0.entrySet()) { generator.writeKey(item1.getKey()); generator.write(item1.getValue()); } } generator.writeEnd(); } generator.writeEnd(); } if (this.minScore != null) { generator.writeKey("min_score"); generator.write(this.minScore); } if (this.pit != null) { generator.writeKey("pit"); this.pit.serialize(generator, mapper); } if (this.postFilter != null) { generator.writeKey("post_filter"); this.postFilter.serialize(generator, mapper); } if (this.profile != null) { generator.writeKey("profile"); generator.write(this.profile); } if (this.query != null) { generator.writeKey("query"); this.query.serialize(generator, mapper); } if (ApiTypeHelper.isDefined(this.rescore)) { generator.writeKey("rescore"); generator.writeStartArray(); for (Rescore item0 : this.rescore) { item0.serialize(generator, mapper); } generator.writeEnd(); } if (ApiTypeHelper.isDefined(this.runtimeMappings)) { generator.writeKey("runtime_mappings"); generator.writeStartObject(); for (Map.Entry> item0 : this.runtimeMappings.entrySet()) { generator.writeKey(item0.getKey()); generator.writeStartArray(); if (item0.getValue() != null) { for (RuntimeField item1 : item0.getValue()) { item1.serialize(generator, mapper); } } generator.writeEnd(); } generator.writeEnd(); } if (ApiTypeHelper.isDefined(this.scriptFields)) { generator.writeKey("script_fields"); generator.writeStartObject(); for (Map.Entry item0 : this.scriptFields.entrySet()) { generator.writeKey(item0.getKey()); item0.getValue().serialize(generator, mapper); } generator.writeEnd(); } if (ApiTypeHelper.isDefined(this.searchAfter)) { generator.writeKey("search_after"); generator.writeStartArray(); for (String item0 : this.searchAfter) { generator.write(item0); } generator.writeEnd(); } if (this.seqNoPrimaryTerm != null) { generator.writeKey("seq_no_primary_term"); generator.write(this.seqNoPrimaryTerm); } if (this.size != null) { generator.writeKey("size"); generator.write(this.size); } if (this.slice != null) { generator.writeKey("slice"); this.slice.serialize(generator, mapper); } if (ApiTypeHelper.isDefined(this.sort)) { generator.writeKey("sort"); generator.writeStartArray(); for (SortOptions item0 : this.sort) { item0.serialize(generator, mapper); } generator.writeEnd(); } if (ApiTypeHelper.isDefined(this.stats)) { generator.writeKey("stats"); generator.writeStartArray(); for (String item0 : this.stats) { generator.write(item0); } generator.writeEnd(); } if (ApiTypeHelper.isDefined(this.storedFields)) { generator.writeKey("stored_fields"); generator.writeStartArray(); for (String item0 : this.storedFields) { generator.write(item0); } generator.writeEnd(); } if (this.suggest != null) { generator.writeKey("suggest"); this.suggest.serialize(generator, mapper); } if (this.terminateAfter != null) { generator.writeKey("terminate_after"); generator.write(this.terminateAfter); } if (this.timeout != null) { generator.writeKey("timeout"); generator.write(this.timeout); } if (this.trackScores != null) { generator.writeKey("track_scores"); generator.write(this.trackScores); } if (this.trackTotalHits != null) { generator.writeKey("track_total_hits"); this.trackTotalHits.serialize(generator, mapper); } if (this.version != null) { generator.writeKey("version"); generator.write(this.version); } } // --------------------------------------------------------------------------------------------- /** * Builder for {@link SubmitRequest}. */ public static class Builder extends WithJsonObjectBuilderBase implements ObjectBuilder { @Nullable private SourceConfig source; @Nullable private Map aggregations; @Nullable private Boolean allowNoIndices; @Nullable private Boolean allowPartialSearchResults; @Nullable private Boolean analyzeWildcard; @Nullable private String analyzer; @Nullable private Long batchedReduceSize; @Nullable private Boolean ccsMinimizeRoundtrips; @Nullable private FieldCollapse collapse; @Nullable private Operator defaultOperator; @Nullable private String df; @Nullable private List docvalueFields; @Nullable private List expandWildcards; @Nullable private Boolean explain; @Nullable private List fields; @Nullable private Integer from; @Nullable private Highlight highlight; @Nullable private Boolean ignoreThrottled; @Nullable private Boolean ignoreUnavailable; @Nullable private List index; @Nullable private List> indicesBoost; @Nullable private Time keepAlive; @Nullable private Boolean keepOnCompletion; @Nullable private Boolean lenient; @Nullable private Long maxConcurrentShardRequests; @Nullable private String minCompatibleShardNode; @Nullable private Double minScore; @Nullable private PointInTimeReference pit; @Nullable private Query postFilter; @Nullable private Long preFilterShardSize; @Nullable private String preference; @Nullable private Boolean profile; @Nullable private String q; @Nullable private Query query; @Nullable private Boolean requestCache; @Nullable private List rescore; @Nullable private String routing; @Nullable private Map> runtimeMappings; @Nullable private Map scriptFields; @Nullable private Time scroll; @Nullable private List searchAfter; @Nullable private SearchType searchType; @Nullable private Boolean seqNoPrimaryTerm; @Nullable private Integer size; @Nullable private SlicedScroll slice; @Nullable private List sort; @Nullable private List stats; @Nullable private List storedFields; @Nullable private Suggester suggest; @Nullable private Long terminateAfter; @Nullable private String timeout; @Nullable private Boolean trackScores; @Nullable private TrackHits trackTotalHits; @Nullable private Boolean version; @Nullable private Time waitForCompletionTimeout; /** * Indicates which source fields are returned for matching documents. These * fields are returned in the hits._source property of the search response. * * API name: {@code _source} */ public final Builder source(@Nullable SourceConfig value) { this.source = value; return this; } /** * Indicates which source fields are returned for matching documents. These * fields are returned in the hits._source property of the search response. * * API name: {@code _source} */ public final Builder source(Function> fn) { return this.source(fn.apply(new SourceConfig.Builder()).build()); } /** * API name: {@code aggregations} * * Adds all entries of map to aggregations. */ public final Builder aggregations(Map map) { this.aggregations = _mapPutAll(this.aggregations, map); return this; } /** * API name: {@code aggregations} * * Adds an entry to aggregations. */ public final Builder aggregations(String key, Aggregation value) { this.aggregations = _mapPut(this.aggregations, key, value); return this; } /** * API name: {@code aggregations} * * Adds an entry to aggregations using a builder lambda. */ public final Builder aggregations(String key, Function> fn) { return aggregations(key, fn.apply(new Aggregation.Builder()).build()); } /** * Whether to ignore if a wildcard indices expression resolves into no concrete * indices. (This includes _all string or when no indices have been * specified) * * API name: {@code allow_no_indices} */ public final Builder allowNoIndices(@Nullable Boolean value) { this.allowNoIndices = value; return this; } /** * Indicate if an error should be returned if there is a partial search failure * or timeout * * API name: {@code allow_partial_search_results} */ public final Builder allowPartialSearchResults(@Nullable Boolean value) { this.allowPartialSearchResults = value; return this; } /** * Specify whether wildcard and prefix queries should be analyzed (default: * false) * * API name: {@code analyze_wildcard} */ public final Builder analyzeWildcard(@Nullable Boolean value) { this.analyzeWildcard = value; return this; } /** * The analyzer to use for the query string * * API name: {@code analyzer} */ public final Builder analyzer(@Nullable String value) { this.analyzer = value; return this; } /** * The number of shard results that should be reduced at once on the * coordinating node. This value should be used as the granularity at which * progress results will be made available. * * API name: {@code batched_reduce_size} */ public final Builder batchedReduceSize(@Nullable Long value) { this.batchedReduceSize = value; return this; } /** * API name: {@code ccs_minimize_roundtrips} */ public final Builder ccsMinimizeRoundtrips(@Nullable Boolean value) { this.ccsMinimizeRoundtrips = value; return this; } /** * API name: {@code collapse} */ public final Builder collapse(@Nullable FieldCollapse value) { this.collapse = value; return this; } /** * API name: {@code collapse} */ public final Builder collapse(Function> fn) { return this.collapse(fn.apply(new FieldCollapse.Builder()).build()); } /** * The default operator for query string query (AND or OR) * * API name: {@code default_operator} */ public final Builder defaultOperator(@Nullable Operator value) { this.defaultOperator = value; return this; } /** * The field to use as default where no field prefix is given in the query * string * * API name: {@code df} */ public final Builder df(@Nullable String value) { this.df = value; return this; } /** * Array of wildcard (*) patterns. The request returns doc values for field * names matching these patterns in the hits.fields property of the response. * * API name: {@code docvalue_fields} * * Adds all elements of list to docvalueFields. */ public final Builder docvalueFields(List list) { this.docvalueFields = _listAddAll(this.docvalueFields, list); return this; } /** * Array of wildcard (*) patterns. The request returns doc values for field * names matching these patterns in the hits.fields property of the response. * * API name: {@code docvalue_fields} * * Adds one or more values to docvalueFields. */ public final Builder docvalueFields(FieldAndFormat value, FieldAndFormat... values) { this.docvalueFields = _listAdd(this.docvalueFields, value, values); return this; } /** * Array of wildcard (*) patterns. The request returns doc values for field * names matching these patterns in the hits.fields property of the response. * * API name: {@code docvalue_fields} * * Adds a value to docvalueFields using a builder lambda. */ public final Builder docvalueFields(Function> fn) { return docvalueFields(fn.apply(new FieldAndFormat.Builder()).build()); } /** * Whether to expand wildcard expression to concrete indices that are open, * closed or both. * * API name: {@code expand_wildcards} * * Adds all elements of list to expandWildcards. */ public final Builder expandWildcards(List list) { this.expandWildcards = _listAddAll(this.expandWildcards, list); return this; } /** * Whether to expand wildcard expression to concrete indices that are open, * closed or both. * * API name: {@code expand_wildcards} * * Adds one or more values to expandWildcards. */ public final Builder expandWildcards(ExpandWildcard value, ExpandWildcard... values) { this.expandWildcards = _listAdd(this.expandWildcards, value, values); return this; } /** * If true, returns detailed information about score computation as part of a * hit. * * API name: {@code explain} */ public final Builder explain(@Nullable Boolean value) { this.explain = value; return this; } /** * Array of wildcard (*) patterns. The request returns values for field names * matching these patterns in the hits.fields property of the response. * * API name: {@code fields} * * Adds all elements of list to fields. */ public final Builder fields(List list) { this.fields = _listAddAll(this.fields, list); return this; } /** * Array of wildcard (*) patterns. The request returns values for field names * matching these patterns in the hits.fields property of the response. * * API name: {@code fields} * * Adds one or more values to fields. */ public final Builder fields(FieldAndFormat value, FieldAndFormat... values) { this.fields = _listAdd(this.fields, value, values); return this; } /** * Array of wildcard (*) patterns. The request returns values for field names * matching these patterns in the hits.fields property of the response. * * API name: {@code fields} * * Adds a value to fields using a builder lambda. */ public final Builder fields(Function> fn) { return fields(fn.apply(new FieldAndFormat.Builder()).build()); } /** * Starting document offset. By default, you cannot page through more than * 10,000 hits using the from and size parameters. To page through more hits, * use the search_after parameter. * * API name: {@code from} */ public final Builder from(@Nullable Integer value) { this.from = value; return this; } /** * API name: {@code highlight} */ public final Builder highlight(@Nullable Highlight value) { this.highlight = value; return this; } /** * API name: {@code highlight} */ public final Builder highlight(Function> fn) { return this.highlight(fn.apply(new Highlight.Builder()).build()); } /** * Whether specified concrete, expanded or aliased indices should be ignored * when throttled * * API name: {@code ignore_throttled} */ public final Builder ignoreThrottled(@Nullable Boolean value) { this.ignoreThrottled = value; return this; } /** * Whether specified concrete indices should be ignored when unavailable * (missing or closed) * * API name: {@code ignore_unavailable} */ public final Builder ignoreUnavailable(@Nullable Boolean value) { this.ignoreUnavailable = value; return this; } /** * A comma-separated list of index names to search; use _all or * empty string to perform the operation on all indices * * API name: {@code index} * * Adds all elements of list to index. */ public final Builder index(List list) { this.index = _listAddAll(this.index, list); return this; } /** * A comma-separated list of index names to search; use _all or * empty string to perform the operation on all indices * * API name: {@code index} * * Adds one or more values to index. */ public final Builder index(String value, String... values) { this.index = _listAdd(this.index, value, values); return this; } /** * Boosts the _score of documents from specified indices. * * API name: {@code indices_boost} * * Adds all elements of list to indicesBoost. */ public final Builder indicesBoost(List> list) { this.indicesBoost = _listAddAll(this.indicesBoost, list); return this; } /** * Boosts the _score of documents from specified indices. * * API name: {@code indices_boost} * * Adds one or more values to indicesBoost. */ public final Builder indicesBoost(Map value, Map... values) { this.indicesBoost = _listAdd(this.indicesBoost, value, values); return this; } /** * Update the time interval in which the results (partial or final) for this * search will be available * * API name: {@code keep_alive} */ public final Builder keepAlive(@Nullable Time value) { this.keepAlive = value; return this; } /** * Update the time interval in which the results (partial or final) for this * search will be available * * API name: {@code keep_alive} */ public final Builder keepAlive(Function> fn) { return this.keepAlive(fn.apply(new Time.Builder()).build()); } /** * Control whether the response should be stored in the cluster if it completed * within the provided [wait_for_completion] time (default: false) * * API name: {@code keep_on_completion} */ public final Builder keepOnCompletion(@Nullable Boolean value) { this.keepOnCompletion = value; return this; } /** * Specify whether format-based query failures (such as providing text to a * numeric field) should be ignored * * API name: {@code lenient} */ public final Builder lenient(@Nullable Boolean value) { this.lenient = value; return this; } /** * The number of concurrent shard requests per node this search executes * concurrently. This value should be used to limit the impact of the search on * the cluster in order to limit the number of concurrent shard requests * * API name: {@code max_concurrent_shard_requests} */ public final Builder maxConcurrentShardRequests(@Nullable Long value) { this.maxConcurrentShardRequests = value; return this; } /** * API name: {@code min_compatible_shard_node} */ public final Builder minCompatibleShardNode(@Nullable String value) { this.minCompatibleShardNode = value; return this; } /** * Minimum _score for matching documents. Documents with a lower _score are not * included in the search results. * * API name: {@code min_score} */ public final Builder minScore(@Nullable Double value) { this.minScore = value; return this; } /** * Limits the search to a point in time (PIT). If you provide a PIT, you cannot * specify an <index> in the request path. * * API name: {@code pit} */ public final Builder pit(@Nullable PointInTimeReference value) { this.pit = value; return this; } /** * Limits the search to a point in time (PIT). If you provide a PIT, you cannot * specify an <index> in the request path. * * API name: {@code pit} */ public final Builder pit(Function> fn) { return this.pit(fn.apply(new PointInTimeReference.Builder()).build()); } /** * API name: {@code post_filter} */ public final Builder postFilter(@Nullable Query value) { this.postFilter = value; return this; } /** * API name: {@code post_filter} */ public final Builder postFilter(Function> fn) { return this.postFilter(fn.apply(new Query.Builder()).build()); } /** * API name: {@code pre_filter_shard_size} */ public final Builder preFilterShardSize(@Nullable Long value) { this.preFilterShardSize = value; return this; } /** * Specify the node or shard the operation should be performed on (default: * random) * * API name: {@code preference} */ public final Builder preference(@Nullable String value) { this.preference = value; return this; } /** * API name: {@code profile} */ public final Builder profile(@Nullable Boolean value) { this.profile = value; return this; } /** * Query in the Lucene query string syntax * * API name: {@code q} */ public final Builder q(@Nullable String value) { this.q = value; return this; } /** * Defines the search definition using the Query DSL. * * API name: {@code query} */ public final Builder query(@Nullable Query value) { this.query = value; return this; } /** * Defines the search definition using the Query DSL. * * API name: {@code query} */ public final Builder query(Function> fn) { return this.query(fn.apply(new Query.Builder()).build()); } /** * Specify if request cache should be used for this request or not, defaults to * true * * API name: {@code request_cache} */ public final Builder requestCache(@Nullable Boolean value) { this.requestCache = value; return this; } /** * API name: {@code rescore} * * Adds all elements of list to rescore. */ public final Builder rescore(List list) { this.rescore = _listAddAll(this.rescore, list); return this; } /** * API name: {@code rescore} * * Adds one or more values to rescore. */ public final Builder rescore(Rescore value, Rescore... values) { this.rescore = _listAdd(this.rescore, value, values); return this; } /** * API name: {@code rescore} * * Adds a value to rescore using a builder lambda. */ public final Builder rescore(Function> fn) { return rescore(fn.apply(new Rescore.Builder()).build()); } /** * A comma-separated list of specific routing values * * API name: {@code routing} */ public final Builder routing(@Nullable String value) { this.routing = value; return this; } /** * Defines one or more runtime fields in the search request. These fields take * precedence over mapped fields with the same name. * * API name: {@code runtime_mappings} * * Adds all entries of map to runtimeMappings. */ public final Builder runtimeMappings(Map> map) { this.runtimeMappings = _mapPutAll(this.runtimeMappings, map); return this; } /** * Defines one or more runtime fields in the search request. These fields take * precedence over mapped fields with the same name. * * API name: {@code runtime_mappings} * * Adds an entry to runtimeMappings. */ public final Builder runtimeMappings(String key, List value) { this.runtimeMappings = _mapPut(this.runtimeMappings, key, value); return this; } /** * Retrieve a script evaluation (based on different fields) for each hit. * * API name: {@code script_fields} * * Adds all entries of map to scriptFields. */ public final Builder scriptFields(Map map) { this.scriptFields = _mapPutAll(this.scriptFields, map); return this; } /** * Retrieve a script evaluation (based on different fields) for each hit. * * API name: {@code script_fields} * * Adds an entry to scriptFields. */ public final Builder scriptFields(String key, ScriptField value) { this.scriptFields = _mapPut(this.scriptFields, key, value); return this; } /** * Retrieve a script evaluation (based on different fields) for each hit. * * API name: {@code script_fields} * * Adds an entry to scriptFields using a builder lambda. */ public final Builder scriptFields(String key, Function> fn) { return scriptFields(key, fn.apply(new ScriptField.Builder()).build()); } /** * API name: {@code scroll} */ public final Builder scroll(@Nullable Time value) { this.scroll = value; return this; } /** * API name: {@code scroll} */ public final Builder scroll(Function> fn) { return this.scroll(fn.apply(new Time.Builder()).build()); } /** * API name: {@code search_after} * * Adds all elements of list to searchAfter. */ public final Builder searchAfter(List list) { this.searchAfter = _listAddAll(this.searchAfter, list); return this; } /** * API name: {@code search_after} * * Adds one or more values to searchAfter. */ public final Builder searchAfter(String value, String... values) { this.searchAfter = _listAdd(this.searchAfter, value, values); return this; } /** * Search operation type * * API name: {@code search_type} */ public final Builder searchType(@Nullable SearchType value) { this.searchType = value; return this; } /** * If true, returns sequence number and primary term of the last modification of * each hit. See Optimistic concurrency control. * * API name: {@code seq_no_primary_term} */ public final Builder seqNoPrimaryTerm(@Nullable Boolean value) { this.seqNoPrimaryTerm = value; return this; } /** * The number of hits to return. By default, you cannot page through more than * 10,000 hits using the from and size parameters. To page through more hits, * use the search_after parameter. * * API name: {@code size} */ public final Builder size(@Nullable Integer value) { this.size = value; return this; } /** * API name: {@code slice} */ public final Builder slice(@Nullable SlicedScroll value) { this.slice = value; return this; } /** * API name: {@code slice} */ public final Builder slice(Function> fn) { return this.slice(fn.apply(new SlicedScroll.Builder()).build()); } /** * API name: {@code sort} * * Adds all elements of list to sort. */ public final Builder sort(List list) { this.sort = _listAddAll(this.sort, list); return this; } /** * API name: {@code sort} * * Adds one or more values to sort. */ public final Builder sort(SortOptions value, SortOptions... values) { this.sort = _listAdd(this.sort, value, values); return this; } /** * API name: {@code sort} * * Adds a value to sort using a builder lambda. */ public final Builder sort(Function> fn) { return sort(fn.apply(new SortOptions.Builder()).build()); } /** * Stats groups to associate with the search. Each group maintains a statistics * aggregation for its associated searches. You can retrieve these stats using * the indices stats API. * * API name: {@code stats} * * Adds all elements of list to stats. */ public final Builder stats(List list) { this.stats = _listAddAll(this.stats, list); return this; } /** * Stats groups to associate with the search. Each group maintains a statistics * aggregation for its associated searches. You can retrieve these stats using * the indices stats API. * * API name: {@code stats} * * Adds one or more values to stats. */ public final Builder stats(String value, String... values) { this.stats = _listAdd(this.stats, value, values); return this; } /** * List of stored fields to return as part of a hit. If no fields are specified, * no stored fields are included in the response. If this field is specified, * the _source parameter defaults to false. You can pass _source: true to return * both source fields and stored fields in the search response. * * API name: {@code stored_fields} * * Adds all elements of list to storedFields. */ public final Builder storedFields(List list) { this.storedFields = _listAddAll(this.storedFields, list); return this; } /** * List of stored fields to return as part of a hit. If no fields are specified, * no stored fields are included in the response. If this field is specified, * the _source parameter defaults to false. You can pass _source: true to return * both source fields and stored fields in the search response. * * API name: {@code stored_fields} * * Adds one or more values to storedFields. */ public final Builder storedFields(String value, String... values) { this.storedFields = _listAdd(this.storedFields, value, values); return this; } /** * API name: {@code suggest} */ public final Builder suggest(@Nullable Suggester value) { this.suggest = value; return this; } /** * API name: {@code suggest} */ public final Builder suggest(Function> fn) { return this.suggest(fn.apply(new Suggester.Builder()).build()); } /** * Maximum number of documents to collect for each shard. If a query reaches * this limit, Elasticsearch terminates the query early. Elasticsearch collects * documents before sorting. Defaults to 0, which does not terminate query * execution early. * * API name: {@code terminate_after} */ public final Builder terminateAfter(@Nullable Long value) { this.terminateAfter = value; return this; } /** * Specifies the period of time to wait for a response from each shard. If no * response is received before the timeout expires, the request fails and * returns an error. Defaults to no timeout. * * API name: {@code timeout} */ public final Builder timeout(@Nullable String value) { this.timeout = value; return this; } /** * If true, calculate and return document scores, even if the scores are not * used for sorting. * * API name: {@code track_scores} */ public final Builder trackScores(@Nullable Boolean value) { this.trackScores = value; return this; } /** * Number of hits matching the query to count accurately. If true, the exact * number of hits is returned at the cost of some performance. If false, the * response does not include the total number of hits matching the query. * Defaults to 10,000 hits. * * API name: {@code track_total_hits} */ public final Builder trackTotalHits(@Nullable TrackHits value) { this.trackTotalHits = value; return this; } /** * Number of hits matching the query to count accurately. If true, the exact * number of hits is returned at the cost of some performance. If false, the * response does not include the total number of hits matching the query. * Defaults to 10,000 hits. * * API name: {@code track_total_hits} */ public final Builder trackTotalHits(Function> fn) { return this.trackTotalHits(fn.apply(new TrackHits.Builder()).build()); } /** * If true, returns document version as part of a hit. * * API name: {@code version} */ public final Builder version(@Nullable Boolean value) { this.version = value; return this; } /** * Specify the time that the request should block waiting for the final response * * API name: {@code wait_for_completion_timeout} */ public final Builder waitForCompletionTimeout(@Nullable Time value) { this.waitForCompletionTimeout = value; return this; } /** * Specify the time that the request should block waiting for the final response * * API name: {@code wait_for_completion_timeout} */ public final Builder waitForCompletionTimeout(Function> fn) { return this.waitForCompletionTimeout(fn.apply(new Time.Builder()).build()); } @Override protected Builder self() { return this; } /** * Builds a {@link SubmitRequest}. * * @throws NullPointerException * if some of the required fields are null. */ public SubmitRequest build() { _checkSingleUse(); return new SubmitRequest(this); } } // --------------------------------------------------------------------------------------------- /** * Json deserializer for {@link SubmitRequest} */ public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy(Builder::new, SubmitRequest::setupSubmitRequestDeserializer); protected static void setupSubmitRequestDeserializer(ObjectDeserializer op) { op.add(Builder::source, SourceConfig._DESERIALIZER, "_source"); op.add(Builder::aggregations, JsonpDeserializer.stringMapDeserializer(Aggregation._DESERIALIZER), "aggregations", "aggs"); op.add(Builder::collapse, FieldCollapse._DESERIALIZER, "collapse"); op.add(Builder::docvalueFields, JsonpDeserializer.arrayDeserializer(FieldAndFormat._DESERIALIZER), "docvalue_fields"); op.add(Builder::explain, JsonpDeserializer.booleanDeserializer(), "explain"); op.add(Builder::fields, JsonpDeserializer.arrayDeserializer(FieldAndFormat._DESERIALIZER), "fields"); op.add(Builder::from, JsonpDeserializer.integerDeserializer(), "from"); op.add(Builder::highlight, Highlight._DESERIALIZER, "highlight"); op.add(Builder::indicesBoost, JsonpDeserializer.arrayDeserializer( JsonpDeserializer.stringMapDeserializer(JsonpDeserializer.doubleDeserializer())), "indices_boost"); op.add(Builder::minScore, JsonpDeserializer.doubleDeserializer(), "min_score"); op.add(Builder::pit, PointInTimeReference._DESERIALIZER, "pit"); op.add(Builder::postFilter, Query._DESERIALIZER, "post_filter"); op.add(Builder::profile, JsonpDeserializer.booleanDeserializer(), "profile"); op.add(Builder::query, Query._DESERIALIZER, "query"); op.add(Builder::rescore, JsonpDeserializer.arrayDeserializer(Rescore._DESERIALIZER), "rescore"); op.add(Builder::runtimeMappings, JsonpDeserializer.stringMapDeserializer( JsonpDeserializer.arrayDeserializer(RuntimeField._DESERIALIZER)), "runtime_mappings"); op.add(Builder::scriptFields, JsonpDeserializer.stringMapDeserializer(ScriptField._DESERIALIZER), "script_fields"); op.add(Builder::searchAfter, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "search_after"); op.add(Builder::seqNoPrimaryTerm, JsonpDeserializer.booleanDeserializer(), "seq_no_primary_term"); op.add(Builder::size, JsonpDeserializer.integerDeserializer(), "size"); op.add(Builder::slice, SlicedScroll._DESERIALIZER, "slice"); op.add(Builder::sort, JsonpDeserializer.arrayDeserializer(SortOptions._DESERIALIZER), "sort"); op.add(Builder::stats, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "stats"); op.add(Builder::storedFields, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "stored_fields"); op.add(Builder::suggest, Suggester._DESERIALIZER, "suggest"); op.add(Builder::terminateAfter, JsonpDeserializer.longDeserializer(), "terminate_after"); op.add(Builder::timeout, JsonpDeserializer.stringDeserializer(), "timeout"); op.add(Builder::trackScores, JsonpDeserializer.booleanDeserializer(), "track_scores"); op.add(Builder::trackTotalHits, TrackHits._DESERIALIZER, "track_total_hits"); op.add(Builder::version, JsonpDeserializer.booleanDeserializer(), "version"); } // --------------------------------------------------------------------------------------------- /** * Endpoint "{@code async_search.submit}". */ public static final SimpleEndpoint _ENDPOINT = new SimpleEndpoint<>("es/async_search.submit", // Request method request -> { return "POST"; }, // Request path request -> { final int _index = 1 << 0; int propsSet = 0; if (ApiTypeHelper.isDefined(request.index())) propsSet |= _index; if (propsSet == 0) { StringBuilder buf = new StringBuilder(); buf.append("/_async_search"); return buf.toString(); } if (propsSet == (_index)) { StringBuilder buf = new StringBuilder(); buf.append("/"); SimpleEndpoint.pathEncode(request.index.stream().map(v -> v).collect(Collectors.joining(",")), buf); buf.append("/_async_search"); return buf.toString(); } throw SimpleEndpoint.noPathTemplateFound("path"); }, // Request parameters request -> { Map params = new HashMap<>(); params.put("typed_keys", "true"); if (request.df != null) { params.put("df", request.df); } if (request.preFilterShardSize != null) { params.put("pre_filter_shard_size", String.valueOf(request.preFilterShardSize)); } if (request.minCompatibleShardNode != null) { params.put("min_compatible_shard_node", request.minCompatibleShardNode); } if (request.lenient != null) { params.put("lenient", String.valueOf(request.lenient)); } if (request.routing != null) { params.put("routing", request.routing); } if (request.ignoreUnavailable != null) { params.put("ignore_unavailable", String.valueOf(request.ignoreUnavailable)); } if (request.allowNoIndices != null) { params.put("allow_no_indices", String.valueOf(request.allowNoIndices)); } if (request.analyzer != null) { params.put("analyzer", request.analyzer); } if (request.ignoreThrottled != null) { params.put("ignore_throttled", String.valueOf(request.ignoreThrottled)); } if (request.keepOnCompletion != null) { params.put("keep_on_completion", String.valueOf(request.keepOnCompletion)); } if (request.maxConcurrentShardRequests != null) { params.put("max_concurrent_shard_requests", String.valueOf(request.maxConcurrentShardRequests)); } if (request.allowPartialSearchResults != null) { params.put("allow_partial_search_results", String.valueOf(request.allowPartialSearchResults)); } if (ApiTypeHelper.isDefined(request.expandWildcards)) { params.put("expand_wildcards", request.expandWildcards.stream().map(v -> v.jsonValue()).collect(Collectors.joining(","))); } if (request.preference != null) { params.put("preference", request.preference); } if (request.analyzeWildcard != null) { params.put("analyze_wildcard", String.valueOf(request.analyzeWildcard)); } if (request.scroll != null) { params.put("scroll", request.scroll._toJsonString()); } if (request.waitForCompletionTimeout != null) { params.put("wait_for_completion_timeout", request.waitForCompletionTimeout._toJsonString()); } if (request.searchType != null) { params.put("search_type", request.searchType.jsonValue()); } if (request.ccsMinimizeRoundtrips != null) { params.put("ccs_minimize_roundtrips", String.valueOf(request.ccsMinimizeRoundtrips)); } if (request.q != null) { params.put("q", request.q); } if (request.defaultOperator != null) { params.put("default_operator", request.defaultOperator.jsonValue()); } if (request.keepAlive != null) { params.put("keep_alive", request.keepAlive._toJsonString()); } if (request.requestCache != null) { params.put("request_cache", String.valueOf(request.requestCache)); } if (request.batchedReduceSize != null) { params.put("batched_reduce_size", String.valueOf(request.batchedReduceSize)); } return params; }, SimpleEndpoint.emptyMap(), true, SubmitResponse._DESERIALIZER); /** * Create an "{@code async_search.submit}" endpoint. */ public static Endpoint, ErrorResponse> createSubmitEndpoint( JsonpDeserializer tDocumentDeserializer) { return _ENDPOINT .withResponseDeserializer(SubmitResponse.createSubmitResponseDeserializer(tDocumentDeserializer)); } }
* API name: {@code expand_wildcards} */ public final List expandWildcards() { return this.expandWildcards; } /** * If true, returns detailed information about score computation as part of a * hit. * * API name: {@code explain} */ @Nullable public final Boolean explain() { return this.explain; } /** * Array of wildcard (*) patterns. The request returns values for field names * matching these patterns in the hits.fields property of the response. * * API name: {@code fields} */ public final List fields() { return this.fields; } /** * Starting document offset. By default, you cannot page through more than * 10,000 hits using the from and size parameters. To page through more hits, * use the search_after parameter. * * API name: {@code from} */ @Nullable public final Integer from() { return this.from; } /** * API name: {@code highlight} */ @Nullable public final Highlight highlight() { return this.highlight; } /** * Whether specified concrete, expanded or aliased indices should be ignored * when throttled * * API name: {@code ignore_throttled} */ @Nullable public final Boolean ignoreThrottled() { return this.ignoreThrottled; } /** * Whether specified concrete indices should be ignored when unavailable * (missing or closed) * * API name: {@code ignore_unavailable} */ @Nullable public final Boolean ignoreUnavailable() { return this.ignoreUnavailable; } /** * A comma-separated list of index names to search; use _all or * empty string to perform the operation on all indices * * API name: {@code index} */ public final List index() { return this.index; } /** * Boosts the _score of documents from specified indices. * * API name: {@code indices_boost} */ public final List> indicesBoost() { return this.indicesBoost; } /** * Update the time interval in which the results (partial or final) for this * search will be available * * API name: {@code keep_alive} */ @Nullable public final Time keepAlive() { return this.keepAlive; } /** * Control whether the response should be stored in the cluster if it completed * within the provided [wait_for_completion] time (default: false) * * API name: {@code keep_on_completion} */ @Nullable public final Boolean keepOnCompletion() { return this.keepOnCompletion; } /** * Specify whether format-based query failures (such as providing text to a * numeric field) should be ignored * * API name: {@code lenient} */ @Nullable public final Boolean lenient() { return this.lenient; } /** * The number of concurrent shard requests per node this search executes * concurrently. This value should be used to limit the impact of the search on * the cluster in order to limit the number of concurrent shard requests * * API name: {@code max_concurrent_shard_requests} */ @Nullable public final Long maxConcurrentShardRequests() { return this.maxConcurrentShardRequests; } /** * API name: {@code min_compatible_shard_node} */ @Nullable public final String minCompatibleShardNode() { return this.minCompatibleShardNode; } /** * Minimum _score for matching documents. Documents with a lower _score are not * included in the search results. * * API name: {@code min_score} */ @Nullable public final Double minScore() { return this.minScore; } /** * Limits the search to a point in time (PIT). If you provide a PIT, you cannot * specify an <index> in the request path. * * API name: {@code pit} */ @Nullable public final PointInTimeReference pit() { return this.pit; } /** * API name: {@code post_filter} */ @Nullable public final Query postFilter() { return this.postFilter; } /** * API name: {@code pre_filter_shard_size} */ @Nullable public final Long preFilterShardSize() { return this.preFilterShardSize; } /** * Specify the node or shard the operation should be performed on (default: * random) * * API name: {@code preference} */ @Nullable public final String preference() { return this.preference; } /** * API name: {@code profile} */ @Nullable public final Boolean profile() { return this.profile; } /** * Query in the Lucene query string syntax * * API name: {@code q} */ @Nullable public final String q() { return this.q; } /** * Defines the search definition using the Query DSL. * * API name: {@code query} */ @Nullable public final Query query() { return this.query; } /** * Specify if request cache should be used for this request or not, defaults to * true * * API name: {@code request_cache} */ @Nullable public final Boolean requestCache() { return this.requestCache; } /** * API name: {@code rescore} */ public final List rescore() { return this.rescore; } /** * A comma-separated list of specific routing values * * API name: {@code routing} */ @Nullable public final String routing() { return this.routing; } /** * Defines one or more runtime fields in the search request. These fields take * precedence over mapped fields with the same name. * * API name: {@code runtime_mappings} */ public final Map> runtimeMappings() { return this.runtimeMappings; } /** * Retrieve a script evaluation (based on different fields) for each hit. * * API name: {@code script_fields} */ public final Map scriptFields() { return this.scriptFields; } /** * API name: {@code scroll} */ @Nullable public final Time scroll() { return this.scroll; } /** * API name: {@code search_after} */ public final List searchAfter() { return this.searchAfter; } /** * Search operation type * * API name: {@code search_type} */ @Nullable public final SearchType searchType() { return this.searchType; } /** * If true, returns sequence number and primary term of the last modification of * each hit. See Optimistic concurrency control. * * API name: {@code seq_no_primary_term} */ @Nullable public final Boolean seqNoPrimaryTerm() { return this.seqNoPrimaryTerm; } /** * The number of hits to return. By default, you cannot page through more than * 10,000 hits using the from and size parameters. To page through more hits, * use the search_after parameter. * * API name: {@code size} */ @Nullable public final Integer size() { return this.size; } /** * API name: {@code slice} */ @Nullable public final SlicedScroll slice() { return this.slice; } /** * API name: {@code sort} */ public final List sort() { return this.sort; } /** * Stats groups to associate with the search. Each group maintains a statistics * aggregation for its associated searches. You can retrieve these stats using * the indices stats API. * * API name: {@code stats} */ public final List stats() { return this.stats; } /** * List of stored fields to return as part of a hit. If no fields are specified, * no stored fields are included in the response. If this field is specified, * the _source parameter defaults to false. You can pass _source: true to return * both source fields and stored fields in the search response. * * API name: {@code stored_fields} */ public final List storedFields() { return this.storedFields; } /** * API name: {@code suggest} */ @Nullable public final Suggester suggest() { return this.suggest; } /** * Maximum number of documents to collect for each shard. If a query reaches * this limit, Elasticsearch terminates the query early. Elasticsearch collects * documents before sorting. Defaults to 0, which does not terminate query * execution early. * * API name: {@code terminate_after} */ @Nullable public final Long terminateAfter() { return this.terminateAfter; } /** * Specifies the period of time to wait for a response from each shard. If no * response is received before the timeout expires, the request fails and * returns an error. Defaults to no timeout. * * API name: {@code timeout} */ @Nullable public final String timeout() { return this.timeout; } /** * If true, calculate and return document scores, even if the scores are not * used for sorting. * * API name: {@code track_scores} */ @Nullable public final Boolean trackScores() { return this.trackScores; } /** * Number of hits matching the query to count accurately. If true, the exact * number of hits is returned at the cost of some performance. If false, the * response does not include the total number of hits matching the query. * Defaults to 10,000 hits. * * API name: {@code track_total_hits} */ @Nullable public final TrackHits trackTotalHits() { return this.trackTotalHits; } /** * If true, returns document version as part of a hit. * * API name: {@code version} */ @Nullable public final Boolean version() { return this.version; } /** * Specify the time that the request should block waiting for the final response * * API name: {@code wait_for_completion_timeout} */ @Nullable public final Time waitForCompletionTimeout() { return this.waitForCompletionTimeout; } /** * 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.source != null) { generator.writeKey("_source"); this.source.serialize(generator, mapper); } if (ApiTypeHelper.isDefined(this.aggregations)) { generator.writeKey("aggregations"); generator.writeStartObject(); for (Map.Entry item0 : this.aggregations.entrySet()) { generator.writeKey(item0.getKey()); item0.getValue().serialize(generator, mapper); } generator.writeEnd(); } if (this.collapse != null) { generator.writeKey("collapse"); this.collapse.serialize(generator, mapper); } if (ApiTypeHelper.isDefined(this.docvalueFields)) { generator.writeKey("docvalue_fields"); generator.writeStartArray(); for (FieldAndFormat item0 : this.docvalueFields) { item0.serialize(generator, mapper); } generator.writeEnd(); } if (this.explain != null) { generator.writeKey("explain"); generator.write(this.explain); } if (ApiTypeHelper.isDefined(this.fields)) { generator.writeKey("fields"); generator.writeStartArray(); for (FieldAndFormat item0 : this.fields) { item0.serialize(generator, mapper); } generator.writeEnd(); } if (this.from != null) { generator.writeKey("from"); generator.write(this.from); } if (this.highlight != null) { generator.writeKey("highlight"); this.highlight.serialize(generator, mapper); } if (ApiTypeHelper.isDefined(this.indicesBoost)) { generator.writeKey("indices_boost"); generator.writeStartArray(); for (Map item0 : this.indicesBoost) { generator.writeStartObject(); if (item0 != null) { for (Map.Entry item1 : item0.entrySet()) { generator.writeKey(item1.getKey()); generator.write(item1.getValue()); } } generator.writeEnd(); } generator.writeEnd(); } if (this.minScore != null) { generator.writeKey("min_score"); generator.write(this.minScore); } if (this.pit != null) { generator.writeKey("pit"); this.pit.serialize(generator, mapper); } if (this.postFilter != null) { generator.writeKey("post_filter"); this.postFilter.serialize(generator, mapper); } if (this.profile != null) { generator.writeKey("profile"); generator.write(this.profile); } if (this.query != null) { generator.writeKey("query"); this.query.serialize(generator, mapper); } if (ApiTypeHelper.isDefined(this.rescore)) { generator.writeKey("rescore"); generator.writeStartArray(); for (Rescore item0 : this.rescore) { item0.serialize(generator, mapper); } generator.writeEnd(); } if (ApiTypeHelper.isDefined(this.runtimeMappings)) { generator.writeKey("runtime_mappings"); generator.writeStartObject(); for (Map.Entry> item0 : this.runtimeMappings.entrySet()) { generator.writeKey(item0.getKey()); generator.writeStartArray(); if (item0.getValue() != null) { for (RuntimeField item1 : item0.getValue()) { item1.serialize(generator, mapper); } } generator.writeEnd(); } generator.writeEnd(); } if (ApiTypeHelper.isDefined(this.scriptFields)) { generator.writeKey("script_fields"); generator.writeStartObject(); for (Map.Entry item0 : this.scriptFields.entrySet()) { generator.writeKey(item0.getKey()); item0.getValue().serialize(generator, mapper); } generator.writeEnd(); } if (ApiTypeHelper.isDefined(this.searchAfter)) { generator.writeKey("search_after"); generator.writeStartArray(); for (String item0 : this.searchAfter) { generator.write(item0); } generator.writeEnd(); } if (this.seqNoPrimaryTerm != null) { generator.writeKey("seq_no_primary_term"); generator.write(this.seqNoPrimaryTerm); } if (this.size != null) { generator.writeKey("size"); generator.write(this.size); } if (this.slice != null) { generator.writeKey("slice"); this.slice.serialize(generator, mapper); } if (ApiTypeHelper.isDefined(this.sort)) { generator.writeKey("sort"); generator.writeStartArray(); for (SortOptions item0 : this.sort) { item0.serialize(generator, mapper); } generator.writeEnd(); } if (ApiTypeHelper.isDefined(this.stats)) { generator.writeKey("stats"); generator.writeStartArray(); for (String item0 : this.stats) { generator.write(item0); } generator.writeEnd(); } if (ApiTypeHelper.isDefined(this.storedFields)) { generator.writeKey("stored_fields"); generator.writeStartArray(); for (String item0 : this.storedFields) { generator.write(item0); } generator.writeEnd(); } if (this.suggest != null) { generator.writeKey("suggest"); this.suggest.serialize(generator, mapper); } if (this.terminateAfter != null) { generator.writeKey("terminate_after"); generator.write(this.terminateAfter); } if (this.timeout != null) { generator.writeKey("timeout"); generator.write(this.timeout); } if (this.trackScores != null) { generator.writeKey("track_scores"); generator.write(this.trackScores); } if (this.trackTotalHits != null) { generator.writeKey("track_total_hits"); this.trackTotalHits.serialize(generator, mapper); } if (this.version != null) { generator.writeKey("version"); generator.write(this.version); } } // --------------------------------------------------------------------------------------------- /** * Builder for {@link SubmitRequest}. */ public static class Builder extends WithJsonObjectBuilderBase implements ObjectBuilder { @Nullable private SourceConfig source; @Nullable private Map aggregations; @Nullable private Boolean allowNoIndices; @Nullable private Boolean allowPartialSearchResults; @Nullable private Boolean analyzeWildcard; @Nullable private String analyzer; @Nullable private Long batchedReduceSize; @Nullable private Boolean ccsMinimizeRoundtrips; @Nullable private FieldCollapse collapse; @Nullable private Operator defaultOperator; @Nullable private String df; @Nullable private List docvalueFields; @Nullable private List expandWildcards; @Nullable private Boolean explain; @Nullable private List fields; @Nullable private Integer from; @Nullable private Highlight highlight; @Nullable private Boolean ignoreThrottled; @Nullable private Boolean ignoreUnavailable; @Nullable private List index; @Nullable private List> indicesBoost; @Nullable private Time keepAlive; @Nullable private Boolean keepOnCompletion; @Nullable private Boolean lenient; @Nullable private Long maxConcurrentShardRequests; @Nullable private String minCompatibleShardNode; @Nullable private Double minScore; @Nullable private PointInTimeReference pit; @Nullable private Query postFilter; @Nullable private Long preFilterShardSize; @Nullable private String preference; @Nullable private Boolean profile; @Nullable private String q; @Nullable private Query query; @Nullable private Boolean requestCache; @Nullable private List rescore; @Nullable private String routing; @Nullable private Map> runtimeMappings; @Nullable private Map scriptFields; @Nullable private Time scroll; @Nullable private List searchAfter; @Nullable private SearchType searchType; @Nullable private Boolean seqNoPrimaryTerm; @Nullable private Integer size; @Nullable private SlicedScroll slice; @Nullable private List sort; @Nullable private List stats; @Nullable private List storedFields; @Nullable private Suggester suggest; @Nullable private Long terminateAfter; @Nullable private String timeout; @Nullable private Boolean trackScores; @Nullable private TrackHits trackTotalHits; @Nullable private Boolean version; @Nullable private Time waitForCompletionTimeout; /** * Indicates which source fields are returned for matching documents. These * fields are returned in the hits._source property of the search response. * * API name: {@code _source} */ public final Builder source(@Nullable SourceConfig value) { this.source = value; return this; } /** * Indicates which source fields are returned for matching documents. These * fields are returned in the hits._source property of the search response. * * API name: {@code _source} */ public final Builder source(Function> fn) { return this.source(fn.apply(new SourceConfig.Builder()).build()); } /** * API name: {@code aggregations} * * Adds all entries of map to aggregations. */ public final Builder aggregations(Map map) { this.aggregations = _mapPutAll(this.aggregations, map); return this; } /** * API name: {@code aggregations} * * Adds an entry to aggregations. */ public final Builder aggregations(String key, Aggregation value) { this.aggregations = _mapPut(this.aggregations, key, value); return this; } /** * API name: {@code aggregations} * * Adds an entry to aggregations using a builder lambda. */ public final Builder aggregations(String key, Function> fn) { return aggregations(key, fn.apply(new Aggregation.Builder()).build()); } /** * Whether to ignore if a wildcard indices expression resolves into no concrete * indices. (This includes _all string or when no indices have been * specified) * * API name: {@code allow_no_indices} */ public final Builder allowNoIndices(@Nullable Boolean value) { this.allowNoIndices = value; return this; } /** * Indicate if an error should be returned if there is a partial search failure * or timeout * * API name: {@code allow_partial_search_results} */ public final Builder allowPartialSearchResults(@Nullable Boolean value) { this.allowPartialSearchResults = value; return this; } /** * Specify whether wildcard and prefix queries should be analyzed (default: * false) * * API name: {@code analyze_wildcard} */ public final Builder analyzeWildcard(@Nullable Boolean value) { this.analyzeWildcard = value; return this; } /** * The analyzer to use for the query string * * API name: {@code analyzer} */ public final Builder analyzer(@Nullable String value) { this.analyzer = value; return this; } /** * The number of shard results that should be reduced at once on the * coordinating node. This value should be used as the granularity at which * progress results will be made available. * * API name: {@code batched_reduce_size} */ public final Builder batchedReduceSize(@Nullable Long value) { this.batchedReduceSize = value; return this; } /** * API name: {@code ccs_minimize_roundtrips} */ public final Builder ccsMinimizeRoundtrips(@Nullable Boolean value) { this.ccsMinimizeRoundtrips = value; return this; } /** * API name: {@code collapse} */ public final Builder collapse(@Nullable FieldCollapse value) { this.collapse = value; return this; } /** * API name: {@code collapse} */ public final Builder collapse(Function> fn) { return this.collapse(fn.apply(new FieldCollapse.Builder()).build()); } /** * The default operator for query string query (AND or OR) * * API name: {@code default_operator} */ public final Builder defaultOperator(@Nullable Operator value) { this.defaultOperator = value; return this; } /** * The field to use as default where no field prefix is given in the query * string * * API name: {@code df} */ public final Builder df(@Nullable String value) { this.df = value; return this; } /** * Array of wildcard (*) patterns. The request returns doc values for field * names matching these patterns in the hits.fields property of the response. * * API name: {@code docvalue_fields} * * Adds all elements of list to docvalueFields. */ public final Builder docvalueFields(List list) { this.docvalueFields = _listAddAll(this.docvalueFields, list); return this; } /** * Array of wildcard (*) patterns. The request returns doc values for field * names matching these patterns in the hits.fields property of the response. * * API name: {@code docvalue_fields} * * Adds one or more values to docvalueFields. */ public final Builder docvalueFields(FieldAndFormat value, FieldAndFormat... values) { this.docvalueFields = _listAdd(this.docvalueFields, value, values); return this; } /** * Array of wildcard (*) patterns. The request returns doc values for field * names matching these patterns in the hits.fields property of the response. * * API name: {@code docvalue_fields} * * Adds a value to docvalueFields using a builder lambda. */ public final Builder docvalueFields(Function> fn) { return docvalueFields(fn.apply(new FieldAndFormat.Builder()).build()); } /** * Whether to expand wildcard expression to concrete indices that are open, * closed or both. * * API name: {@code expand_wildcards} * * Adds all elements of list to expandWildcards. */ public final Builder expandWildcards(List list) { this.expandWildcards = _listAddAll(this.expandWildcards, list); return this; } /** * Whether to expand wildcard expression to concrete indices that are open, * closed or both. * * API name: {@code expand_wildcards} * * Adds one or more values to expandWildcards. */ public final Builder expandWildcards(ExpandWildcard value, ExpandWildcard... values) { this.expandWildcards = _listAdd(this.expandWildcards, value, values); return this; } /** * If true, returns detailed information about score computation as part of a * hit. * * API name: {@code explain} */ public final Builder explain(@Nullable Boolean value) { this.explain = value; return this; } /** * Array of wildcard (*) patterns. The request returns values for field names * matching these patterns in the hits.fields property of the response. * * API name: {@code fields} * * Adds all elements of list to fields. */ public final Builder fields(List list) { this.fields = _listAddAll(this.fields, list); return this; } /** * Array of wildcard (*) patterns. The request returns values for field names * matching these patterns in the hits.fields property of the response. * * API name: {@code fields} * * Adds one or more values to fields. */ public final Builder fields(FieldAndFormat value, FieldAndFormat... values) { this.fields = _listAdd(this.fields, value, values); return this; } /** * Array of wildcard (*) patterns. The request returns values for field names * matching these patterns in the hits.fields property of the response. * * API name: {@code fields} * * Adds a value to fields using a builder lambda. */ public final Builder fields(Function> fn) { return fields(fn.apply(new FieldAndFormat.Builder()).build()); } /** * Starting document offset. By default, you cannot page through more than * 10,000 hits using the from and size parameters. To page through more hits, * use the search_after parameter. * * API name: {@code from} */ public final Builder from(@Nullable Integer value) { this.from = value; return this; } /** * API name: {@code highlight} */ public final Builder highlight(@Nullable Highlight value) { this.highlight = value; return this; } /** * API name: {@code highlight} */ public final Builder highlight(Function> fn) { return this.highlight(fn.apply(new Highlight.Builder()).build()); } /** * Whether specified concrete, expanded or aliased indices should be ignored * when throttled * * API name: {@code ignore_throttled} */ public final Builder ignoreThrottled(@Nullable Boolean value) { this.ignoreThrottled = value; return this; } /** * Whether specified concrete indices should be ignored when unavailable * (missing or closed) * * API name: {@code ignore_unavailable} */ public final Builder ignoreUnavailable(@Nullable Boolean value) { this.ignoreUnavailable = value; return this; } /** * A comma-separated list of index names to search; use _all or * empty string to perform the operation on all indices * * API name: {@code index} * * Adds all elements of list to index. */ public final Builder index(List list) { this.index = _listAddAll(this.index, list); return this; } /** * A comma-separated list of index names to search; use _all or * empty string to perform the operation on all indices * * API name: {@code index} * * Adds one or more values to index. */ public final Builder index(String value, String... values) { this.index = _listAdd(this.index, value, values); return this; } /** * Boosts the _score of documents from specified indices. * * API name: {@code indices_boost} * * Adds all elements of list to indicesBoost. */ public final Builder indicesBoost(List> list) { this.indicesBoost = _listAddAll(this.indicesBoost, list); return this; } /** * Boosts the _score of documents from specified indices. * * API name: {@code indices_boost} * * Adds one or more values to indicesBoost. */ public final Builder indicesBoost(Map value, Map... values) { this.indicesBoost = _listAdd(this.indicesBoost, value, values); return this; } /** * Update the time interval in which the results (partial or final) for this * search will be available * * API name: {@code keep_alive} */ public final Builder keepAlive(@Nullable Time value) { this.keepAlive = value; return this; } /** * Update the time interval in which the results (partial or final) for this * search will be available * * API name: {@code keep_alive} */ public final Builder keepAlive(Function> fn) { return this.keepAlive(fn.apply(new Time.Builder()).build()); } /** * Control whether the response should be stored in the cluster if it completed * within the provided [wait_for_completion] time (default: false) * * API name: {@code keep_on_completion} */ public final Builder keepOnCompletion(@Nullable Boolean value) { this.keepOnCompletion = value; return this; } /** * Specify whether format-based query failures (such as providing text to a * numeric field) should be ignored * * API name: {@code lenient} */ public final Builder lenient(@Nullable Boolean value) { this.lenient = value; return this; } /** * The number of concurrent shard requests per node this search executes * concurrently. This value should be used to limit the impact of the search on * the cluster in order to limit the number of concurrent shard requests * * API name: {@code max_concurrent_shard_requests} */ public final Builder maxConcurrentShardRequests(@Nullable Long value) { this.maxConcurrentShardRequests = value; return this; } /** * API name: {@code min_compatible_shard_node} */ public final Builder minCompatibleShardNode(@Nullable String value) { this.minCompatibleShardNode = value; return this; } /** * Minimum _score for matching documents. Documents with a lower _score are not * included in the search results. * * API name: {@code min_score} */ public final Builder minScore(@Nullable Double value) { this.minScore = value; return this; } /** * Limits the search to a point in time (PIT). If you provide a PIT, you cannot * specify an <index> in the request path. * * API name: {@code pit} */ public final Builder pit(@Nullable PointInTimeReference value) { this.pit = value; return this; } /** * Limits the search to a point in time (PIT). If you provide a PIT, you cannot * specify an <index> in the request path. * * API name: {@code pit} */ public final Builder pit(Function> fn) { return this.pit(fn.apply(new PointInTimeReference.Builder()).build()); } /** * API name: {@code post_filter} */ public final Builder postFilter(@Nullable Query value) { this.postFilter = value; return this; } /** * API name: {@code post_filter} */ public final Builder postFilter(Function> fn) { return this.postFilter(fn.apply(new Query.Builder()).build()); } /** * API name: {@code pre_filter_shard_size} */ public final Builder preFilterShardSize(@Nullable Long value) { this.preFilterShardSize = value; return this; } /** * Specify the node or shard the operation should be performed on (default: * random) * * API name: {@code preference} */ public final Builder preference(@Nullable String value) { this.preference = value; return this; } /** * API name: {@code profile} */ public final Builder profile(@Nullable Boolean value) { this.profile = value; return this; } /** * Query in the Lucene query string syntax * * API name: {@code q} */ public final Builder q(@Nullable String value) { this.q = value; return this; } /** * Defines the search definition using the Query DSL. * * API name: {@code query} */ public final Builder query(@Nullable Query value) { this.query = value; return this; } /** * Defines the search definition using the Query DSL. * * API name: {@code query} */ public final Builder query(Function> fn) { return this.query(fn.apply(new Query.Builder()).build()); } /** * Specify if request cache should be used for this request or not, defaults to * true * * API name: {@code request_cache} */ public final Builder requestCache(@Nullable Boolean value) { this.requestCache = value; return this; } /** * API name: {@code rescore} * * Adds all elements of list to rescore. */ public final Builder rescore(List list) { this.rescore = _listAddAll(this.rescore, list); return this; } /** * API name: {@code rescore} * * Adds one or more values to rescore. */ public final Builder rescore(Rescore value, Rescore... values) { this.rescore = _listAdd(this.rescore, value, values); return this; } /** * API name: {@code rescore} * * Adds a value to rescore using a builder lambda. */ public final Builder rescore(Function> fn) { return rescore(fn.apply(new Rescore.Builder()).build()); } /** * A comma-separated list of specific routing values * * API name: {@code routing} */ public final Builder routing(@Nullable String value) { this.routing = value; return this; } /** * Defines one or more runtime fields in the search request. These fields take * precedence over mapped fields with the same name. * * API name: {@code runtime_mappings} * * Adds all entries of map to runtimeMappings. */ public final Builder runtimeMappings(Map> map) { this.runtimeMappings = _mapPutAll(this.runtimeMappings, map); return this; } /** * Defines one or more runtime fields in the search request. These fields take * precedence over mapped fields with the same name. * * API name: {@code runtime_mappings} * * Adds an entry to runtimeMappings. */ public final Builder runtimeMappings(String key, List value) { this.runtimeMappings = _mapPut(this.runtimeMappings, key, value); return this; } /** * Retrieve a script evaluation (based on different fields) for each hit. * * API name: {@code script_fields} * * Adds all entries of map to scriptFields. */ public final Builder scriptFields(Map map) { this.scriptFields = _mapPutAll(this.scriptFields, map); return this; } /** * Retrieve a script evaluation (based on different fields) for each hit. * * API name: {@code script_fields} * * Adds an entry to scriptFields. */ public final Builder scriptFields(String key, ScriptField value) { this.scriptFields = _mapPut(this.scriptFields, key, value); return this; } /** * Retrieve a script evaluation (based on different fields) for each hit. * * API name: {@code script_fields} * * Adds an entry to scriptFields using a builder lambda. */ public final Builder scriptFields(String key, Function> fn) { return scriptFields(key, fn.apply(new ScriptField.Builder()).build()); } /** * API name: {@code scroll} */ public final Builder scroll(@Nullable Time value) { this.scroll = value; return this; } /** * API name: {@code scroll} */ public final Builder scroll(Function> fn) { return this.scroll(fn.apply(new Time.Builder()).build()); } /** * API name: {@code search_after} * * Adds all elements of list to searchAfter. */ public final Builder searchAfter(List list) { this.searchAfter = _listAddAll(this.searchAfter, list); return this; } /** * API name: {@code search_after} * * Adds one or more values to searchAfter. */ public final Builder searchAfter(String value, String... values) { this.searchAfter = _listAdd(this.searchAfter, value, values); return this; } /** * Search operation type * * API name: {@code search_type} */ public final Builder searchType(@Nullable SearchType value) { this.searchType = value; return this; } /** * If true, returns sequence number and primary term of the last modification of * each hit. See Optimistic concurrency control. * * API name: {@code seq_no_primary_term} */ public final Builder seqNoPrimaryTerm(@Nullable Boolean value) { this.seqNoPrimaryTerm = value; return this; } /** * The number of hits to return. By default, you cannot page through more than * 10,000 hits using the from and size parameters. To page through more hits, * use the search_after parameter. * * API name: {@code size} */ public final Builder size(@Nullable Integer value) { this.size = value; return this; } /** * API name: {@code slice} */ public final Builder slice(@Nullable SlicedScroll value) { this.slice = value; return this; } /** * API name: {@code slice} */ public final Builder slice(Function> fn) { return this.slice(fn.apply(new SlicedScroll.Builder()).build()); } /** * API name: {@code sort} * * Adds all elements of list to sort. */ public final Builder sort(List list) { this.sort = _listAddAll(this.sort, list); return this; } /** * API name: {@code sort} * * Adds one or more values to sort. */ public final Builder sort(SortOptions value, SortOptions... values) { this.sort = _listAdd(this.sort, value, values); return this; } /** * API name: {@code sort} * * Adds a value to sort using a builder lambda. */ public final Builder sort(Function> fn) { return sort(fn.apply(new SortOptions.Builder()).build()); } /** * Stats groups to associate with the search. Each group maintains a statistics * aggregation for its associated searches. You can retrieve these stats using * the indices stats API. * * API name: {@code stats} * * Adds all elements of list to stats. */ public final Builder stats(List list) { this.stats = _listAddAll(this.stats, list); return this; } /** * Stats groups to associate with the search. Each group maintains a statistics * aggregation for its associated searches. You can retrieve these stats using * the indices stats API. * * API name: {@code stats} * * Adds one or more values to stats. */ public final Builder stats(String value, String... values) { this.stats = _listAdd(this.stats, value, values); return this; } /** * List of stored fields to return as part of a hit. If no fields are specified, * no stored fields are included in the response. If this field is specified, * the _source parameter defaults to false. You can pass _source: true to return * both source fields and stored fields in the search response. * * API name: {@code stored_fields} * * Adds all elements of list to storedFields. */ public final Builder storedFields(List list) { this.storedFields = _listAddAll(this.storedFields, list); return this; } /** * List of stored fields to return as part of a hit. If no fields are specified, * no stored fields are included in the response. If this field is specified, * the _source parameter defaults to false. You can pass _source: true to return * both source fields and stored fields in the search response. * * API name: {@code stored_fields} * * Adds one or more values to storedFields. */ public final Builder storedFields(String value, String... values) { this.storedFields = _listAdd(this.storedFields, value, values); return this; } /** * API name: {@code suggest} */ public final Builder suggest(@Nullable Suggester value) { this.suggest = value; return this; } /** * API name: {@code suggest} */ public final Builder suggest(Function> fn) { return this.suggest(fn.apply(new Suggester.Builder()).build()); } /** * Maximum number of documents to collect for each shard. If a query reaches * this limit, Elasticsearch terminates the query early. Elasticsearch collects * documents before sorting. Defaults to 0, which does not terminate query * execution early. * * API name: {@code terminate_after} */ public final Builder terminateAfter(@Nullable Long value) { this.terminateAfter = value; return this; } /** * Specifies the period of time to wait for a response from each shard. If no * response is received before the timeout expires, the request fails and * returns an error. Defaults to no timeout. * * API name: {@code timeout} */ public final Builder timeout(@Nullable String value) { this.timeout = value; return this; } /** * If true, calculate and return document scores, even if the scores are not * used for sorting. * * API name: {@code track_scores} */ public final Builder trackScores(@Nullable Boolean value) { this.trackScores = value; return this; } /** * Number of hits matching the query to count accurately. If true, the exact * number of hits is returned at the cost of some performance. If false, the * response does not include the total number of hits matching the query. * Defaults to 10,000 hits. * * API name: {@code track_total_hits} */ public final Builder trackTotalHits(@Nullable TrackHits value) { this.trackTotalHits = value; return this; } /** * Number of hits matching the query to count accurately. If true, the exact * number of hits is returned at the cost of some performance. If false, the * response does not include the total number of hits matching the query. * Defaults to 10,000 hits. * * API name: {@code track_total_hits} */ public final Builder trackTotalHits(Function> fn) { return this.trackTotalHits(fn.apply(new TrackHits.Builder()).build()); } /** * If true, returns document version as part of a hit. * * API name: {@code version} */ public final Builder version(@Nullable Boolean value) { this.version = value; return this; } /** * Specify the time that the request should block waiting for the final response * * API name: {@code wait_for_completion_timeout} */ public final Builder waitForCompletionTimeout(@Nullable Time value) { this.waitForCompletionTimeout = value; return this; } /** * Specify the time that the request should block waiting for the final response * * API name: {@code wait_for_completion_timeout} */ public final Builder waitForCompletionTimeout(Function> fn) { return this.waitForCompletionTimeout(fn.apply(new Time.Builder()).build()); } @Override protected Builder self() { return this; } /** * Builds a {@link SubmitRequest}. * * @throws NullPointerException * if some of the required fields are null. */ public SubmitRequest build() { _checkSingleUse(); return new SubmitRequest(this); } } // --------------------------------------------------------------------------------------------- /** * Json deserializer for {@link SubmitRequest} */ public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy(Builder::new, SubmitRequest::setupSubmitRequestDeserializer); protected static void setupSubmitRequestDeserializer(ObjectDeserializer op) { op.add(Builder::source, SourceConfig._DESERIALIZER, "_source"); op.add(Builder::aggregations, JsonpDeserializer.stringMapDeserializer(Aggregation._DESERIALIZER), "aggregations", "aggs"); op.add(Builder::collapse, FieldCollapse._DESERIALIZER, "collapse"); op.add(Builder::docvalueFields, JsonpDeserializer.arrayDeserializer(FieldAndFormat._DESERIALIZER), "docvalue_fields"); op.add(Builder::explain, JsonpDeserializer.booleanDeserializer(), "explain"); op.add(Builder::fields, JsonpDeserializer.arrayDeserializer(FieldAndFormat._DESERIALIZER), "fields"); op.add(Builder::from, JsonpDeserializer.integerDeserializer(), "from"); op.add(Builder::highlight, Highlight._DESERIALIZER, "highlight"); op.add(Builder::indicesBoost, JsonpDeserializer.arrayDeserializer( JsonpDeserializer.stringMapDeserializer(JsonpDeserializer.doubleDeserializer())), "indices_boost"); op.add(Builder::minScore, JsonpDeserializer.doubleDeserializer(), "min_score"); op.add(Builder::pit, PointInTimeReference._DESERIALIZER, "pit"); op.add(Builder::postFilter, Query._DESERIALIZER, "post_filter"); op.add(Builder::profile, JsonpDeserializer.booleanDeserializer(), "profile"); op.add(Builder::query, Query._DESERIALIZER, "query"); op.add(Builder::rescore, JsonpDeserializer.arrayDeserializer(Rescore._DESERIALIZER), "rescore"); op.add(Builder::runtimeMappings, JsonpDeserializer.stringMapDeserializer( JsonpDeserializer.arrayDeserializer(RuntimeField._DESERIALIZER)), "runtime_mappings"); op.add(Builder::scriptFields, JsonpDeserializer.stringMapDeserializer(ScriptField._DESERIALIZER), "script_fields"); op.add(Builder::searchAfter, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "search_after"); op.add(Builder::seqNoPrimaryTerm, JsonpDeserializer.booleanDeserializer(), "seq_no_primary_term"); op.add(Builder::size, JsonpDeserializer.integerDeserializer(), "size"); op.add(Builder::slice, SlicedScroll._DESERIALIZER, "slice"); op.add(Builder::sort, JsonpDeserializer.arrayDeserializer(SortOptions._DESERIALIZER), "sort"); op.add(Builder::stats, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "stats"); op.add(Builder::storedFields, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "stored_fields"); op.add(Builder::suggest, Suggester._DESERIALIZER, "suggest"); op.add(Builder::terminateAfter, JsonpDeserializer.longDeserializer(), "terminate_after"); op.add(Builder::timeout, JsonpDeserializer.stringDeserializer(), "timeout"); op.add(Builder::trackScores, JsonpDeserializer.booleanDeserializer(), "track_scores"); op.add(Builder::trackTotalHits, TrackHits._DESERIALIZER, "track_total_hits"); op.add(Builder::version, JsonpDeserializer.booleanDeserializer(), "version"); } // --------------------------------------------------------------------------------------------- /** * Endpoint "{@code async_search.submit}". */ public static final SimpleEndpoint _ENDPOINT = new SimpleEndpoint<>("es/async_search.submit", // Request method request -> { return "POST"; }, // Request path request -> { final int _index = 1 << 0; int propsSet = 0; if (ApiTypeHelper.isDefined(request.index())) propsSet |= _index; if (propsSet == 0) { StringBuilder buf = new StringBuilder(); buf.append("/_async_search"); return buf.toString(); } if (propsSet == (_index)) { StringBuilder buf = new StringBuilder(); buf.append("/"); SimpleEndpoint.pathEncode(request.index.stream().map(v -> v).collect(Collectors.joining(",")), buf); buf.append("/_async_search"); return buf.toString(); } throw SimpleEndpoint.noPathTemplateFound("path"); }, // Request parameters request -> { Map params = new HashMap<>(); params.put("typed_keys", "true"); if (request.df != null) { params.put("df", request.df); } if (request.preFilterShardSize != null) { params.put("pre_filter_shard_size", String.valueOf(request.preFilterShardSize)); } if (request.minCompatibleShardNode != null) { params.put("min_compatible_shard_node", request.minCompatibleShardNode); } if (request.lenient != null) { params.put("lenient", String.valueOf(request.lenient)); } if (request.routing != null) { params.put("routing", request.routing); } if (request.ignoreUnavailable != null) { params.put("ignore_unavailable", String.valueOf(request.ignoreUnavailable)); } if (request.allowNoIndices != null) { params.put("allow_no_indices", String.valueOf(request.allowNoIndices)); } if (request.analyzer != null) { params.put("analyzer", request.analyzer); } if (request.ignoreThrottled != null) { params.put("ignore_throttled", String.valueOf(request.ignoreThrottled)); } if (request.keepOnCompletion != null) { params.put("keep_on_completion", String.valueOf(request.keepOnCompletion)); } if (request.maxConcurrentShardRequests != null) { params.put("max_concurrent_shard_requests", String.valueOf(request.maxConcurrentShardRequests)); } if (request.allowPartialSearchResults != null) { params.put("allow_partial_search_results", String.valueOf(request.allowPartialSearchResults)); } if (ApiTypeHelper.isDefined(request.expandWildcards)) { params.put("expand_wildcards", request.expandWildcards.stream().map(v -> v.jsonValue()).collect(Collectors.joining(","))); } if (request.preference != null) { params.put("preference", request.preference); } if (request.analyzeWildcard != null) { params.put("analyze_wildcard", String.valueOf(request.analyzeWildcard)); } if (request.scroll != null) { params.put("scroll", request.scroll._toJsonString()); } if (request.waitForCompletionTimeout != null) { params.put("wait_for_completion_timeout", request.waitForCompletionTimeout._toJsonString()); } if (request.searchType != null) { params.put("search_type", request.searchType.jsonValue()); } if (request.ccsMinimizeRoundtrips != null) { params.put("ccs_minimize_roundtrips", String.valueOf(request.ccsMinimizeRoundtrips)); } if (request.q != null) { params.put("q", request.q); } if (request.defaultOperator != null) { params.put("default_operator", request.defaultOperator.jsonValue()); } if (request.keepAlive != null) { params.put("keep_alive", request.keepAlive._toJsonString()); } if (request.requestCache != null) { params.put("request_cache", String.valueOf(request.requestCache)); } if (request.batchedReduceSize != null) { params.put("batched_reduce_size", String.valueOf(request.batchedReduceSize)); } return params; }, SimpleEndpoint.emptyMap(), true, SubmitResponse._DESERIALIZER); /** * Create an "{@code async_search.submit}" endpoint. */ public static Endpoint, ErrorResponse> createSubmitEndpoint( JsonpDeserializer tDocumentDeserializer) { return _ENDPOINT .withResponseDeserializer(SubmitResponse.createSubmitResponseDeserializer(tDocumentDeserializer)); } }
* API name: {@code explain} */ @Nullable public final Boolean explain() { return this.explain; } /** * Array of wildcard (*) patterns. The request returns values for field names * matching these patterns in the hits.fields property of the response. *
* API name: {@code fields} */ public final List fields() { return this.fields; } /** * Starting document offset. By default, you cannot page through more than * 10,000 hits using the from and size parameters. To page through more hits, * use the search_after parameter. * * API name: {@code from} */ @Nullable public final Integer from() { return this.from; } /** * API name: {@code highlight} */ @Nullable public final Highlight highlight() { return this.highlight; } /** * Whether specified concrete, expanded or aliased indices should be ignored * when throttled * * API name: {@code ignore_throttled} */ @Nullable public final Boolean ignoreThrottled() { return this.ignoreThrottled; } /** * Whether specified concrete indices should be ignored when unavailable * (missing or closed) * * API name: {@code ignore_unavailable} */ @Nullable public final Boolean ignoreUnavailable() { return this.ignoreUnavailable; } /** * A comma-separated list of index names to search; use _all or * empty string to perform the operation on all indices * * API name: {@code index} */ public final List index() { return this.index; } /** * Boosts the _score of documents from specified indices. * * API name: {@code indices_boost} */ public final List> indicesBoost() { return this.indicesBoost; } /** * Update the time interval in which the results (partial or final) for this * search will be available * * API name: {@code keep_alive} */ @Nullable public final Time keepAlive() { return this.keepAlive; } /** * Control whether the response should be stored in the cluster if it completed * within the provided [wait_for_completion] time (default: false) * * API name: {@code keep_on_completion} */ @Nullable public final Boolean keepOnCompletion() { return this.keepOnCompletion; } /** * Specify whether format-based query failures (such as providing text to a * numeric field) should be ignored * * API name: {@code lenient} */ @Nullable public final Boolean lenient() { return this.lenient; } /** * The number of concurrent shard requests per node this search executes * concurrently. This value should be used to limit the impact of the search on * the cluster in order to limit the number of concurrent shard requests * * API name: {@code max_concurrent_shard_requests} */ @Nullable public final Long maxConcurrentShardRequests() { return this.maxConcurrentShardRequests; } /** * API name: {@code min_compatible_shard_node} */ @Nullable public final String minCompatibleShardNode() { return this.minCompatibleShardNode; } /** * Minimum _score for matching documents. Documents with a lower _score are not * included in the search results. * * API name: {@code min_score} */ @Nullable public final Double minScore() { return this.minScore; } /** * Limits the search to a point in time (PIT). If you provide a PIT, you cannot * specify an <index> in the request path. * * API name: {@code pit} */ @Nullable public final PointInTimeReference pit() { return this.pit; } /** * API name: {@code post_filter} */ @Nullable public final Query postFilter() { return this.postFilter; } /** * API name: {@code pre_filter_shard_size} */ @Nullable public final Long preFilterShardSize() { return this.preFilterShardSize; } /** * Specify the node or shard the operation should be performed on (default: * random) * * API name: {@code preference} */ @Nullable public final String preference() { return this.preference; } /** * API name: {@code profile} */ @Nullable public final Boolean profile() { return this.profile; } /** * Query in the Lucene query string syntax * * API name: {@code q} */ @Nullable public final String q() { return this.q; } /** * Defines the search definition using the Query DSL. * * API name: {@code query} */ @Nullable public final Query query() { return this.query; } /** * Specify if request cache should be used for this request or not, defaults to * true * * API name: {@code request_cache} */ @Nullable public final Boolean requestCache() { return this.requestCache; } /** * API name: {@code rescore} */ public final List rescore() { return this.rescore; } /** * A comma-separated list of specific routing values * * API name: {@code routing} */ @Nullable public final String routing() { return this.routing; } /** * Defines one or more runtime fields in the search request. These fields take * precedence over mapped fields with the same name. * * API name: {@code runtime_mappings} */ public final Map> runtimeMappings() { return this.runtimeMappings; } /** * Retrieve a script evaluation (based on different fields) for each hit. * * API name: {@code script_fields} */ public final Map scriptFields() { return this.scriptFields; } /** * API name: {@code scroll} */ @Nullable public final Time scroll() { return this.scroll; } /** * API name: {@code search_after} */ public final List searchAfter() { return this.searchAfter; } /** * Search operation type * * API name: {@code search_type} */ @Nullable public final SearchType searchType() { return this.searchType; } /** * If true, returns sequence number and primary term of the last modification of * each hit. See Optimistic concurrency control. * * API name: {@code seq_no_primary_term} */ @Nullable public final Boolean seqNoPrimaryTerm() { return this.seqNoPrimaryTerm; } /** * The number of hits to return. By default, you cannot page through more than * 10,000 hits using the from and size parameters. To page through more hits, * use the search_after parameter. * * API name: {@code size} */ @Nullable public final Integer size() { return this.size; } /** * API name: {@code slice} */ @Nullable public final SlicedScroll slice() { return this.slice; } /** * API name: {@code sort} */ public final List sort() { return this.sort; } /** * Stats groups to associate with the search. Each group maintains a statistics * aggregation for its associated searches. You can retrieve these stats using * the indices stats API. * * API name: {@code stats} */ public final List stats() { return this.stats; } /** * List of stored fields to return as part of a hit. If no fields are specified, * no stored fields are included in the response. If this field is specified, * the _source parameter defaults to false. You can pass _source: true to return * both source fields and stored fields in the search response. * * API name: {@code stored_fields} */ public final List storedFields() { return this.storedFields; } /** * API name: {@code suggest} */ @Nullable public final Suggester suggest() { return this.suggest; } /** * Maximum number of documents to collect for each shard. If a query reaches * this limit, Elasticsearch terminates the query early. Elasticsearch collects * documents before sorting. Defaults to 0, which does not terminate query * execution early. * * API name: {@code terminate_after} */ @Nullable public final Long terminateAfter() { return this.terminateAfter; } /** * Specifies the period of time to wait for a response from each shard. If no * response is received before the timeout expires, the request fails and * returns an error. Defaults to no timeout. * * API name: {@code timeout} */ @Nullable public final String timeout() { return this.timeout; } /** * If true, calculate and return document scores, even if the scores are not * used for sorting. * * API name: {@code track_scores} */ @Nullable public final Boolean trackScores() { return this.trackScores; } /** * Number of hits matching the query to count accurately. If true, the exact * number of hits is returned at the cost of some performance. If false, the * response does not include the total number of hits matching the query. * Defaults to 10,000 hits. * * API name: {@code track_total_hits} */ @Nullable public final TrackHits trackTotalHits() { return this.trackTotalHits; } /** * If true, returns document version as part of a hit. * * API name: {@code version} */ @Nullable public final Boolean version() { return this.version; } /** * Specify the time that the request should block waiting for the final response * * API name: {@code wait_for_completion_timeout} */ @Nullable public final Time waitForCompletionTimeout() { return this.waitForCompletionTimeout; } /** * 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.source != null) { generator.writeKey("_source"); this.source.serialize(generator, mapper); } if (ApiTypeHelper.isDefined(this.aggregations)) { generator.writeKey("aggregations"); generator.writeStartObject(); for (Map.Entry item0 : this.aggregations.entrySet()) { generator.writeKey(item0.getKey()); item0.getValue().serialize(generator, mapper); } generator.writeEnd(); } if (this.collapse != null) { generator.writeKey("collapse"); this.collapse.serialize(generator, mapper); } if (ApiTypeHelper.isDefined(this.docvalueFields)) { generator.writeKey("docvalue_fields"); generator.writeStartArray(); for (FieldAndFormat item0 : this.docvalueFields) { item0.serialize(generator, mapper); } generator.writeEnd(); } if (this.explain != null) { generator.writeKey("explain"); generator.write(this.explain); } if (ApiTypeHelper.isDefined(this.fields)) { generator.writeKey("fields"); generator.writeStartArray(); for (FieldAndFormat item0 : this.fields) { item0.serialize(generator, mapper); } generator.writeEnd(); } if (this.from != null) { generator.writeKey("from"); generator.write(this.from); } if (this.highlight != null) { generator.writeKey("highlight"); this.highlight.serialize(generator, mapper); } if (ApiTypeHelper.isDefined(this.indicesBoost)) { generator.writeKey("indices_boost"); generator.writeStartArray(); for (Map item0 : this.indicesBoost) { generator.writeStartObject(); if (item0 != null) { for (Map.Entry item1 : item0.entrySet()) { generator.writeKey(item1.getKey()); generator.write(item1.getValue()); } } generator.writeEnd(); } generator.writeEnd(); } if (this.minScore != null) { generator.writeKey("min_score"); generator.write(this.minScore); } if (this.pit != null) { generator.writeKey("pit"); this.pit.serialize(generator, mapper); } if (this.postFilter != null) { generator.writeKey("post_filter"); this.postFilter.serialize(generator, mapper); } if (this.profile != null) { generator.writeKey("profile"); generator.write(this.profile); } if (this.query != null) { generator.writeKey("query"); this.query.serialize(generator, mapper); } if (ApiTypeHelper.isDefined(this.rescore)) { generator.writeKey("rescore"); generator.writeStartArray(); for (Rescore item0 : this.rescore) { item0.serialize(generator, mapper); } generator.writeEnd(); } if (ApiTypeHelper.isDefined(this.runtimeMappings)) { generator.writeKey("runtime_mappings"); generator.writeStartObject(); for (Map.Entry> item0 : this.runtimeMappings.entrySet()) { generator.writeKey(item0.getKey()); generator.writeStartArray(); if (item0.getValue() != null) { for (RuntimeField item1 : item0.getValue()) { item1.serialize(generator, mapper); } } generator.writeEnd(); } generator.writeEnd(); } if (ApiTypeHelper.isDefined(this.scriptFields)) { generator.writeKey("script_fields"); generator.writeStartObject(); for (Map.Entry item0 : this.scriptFields.entrySet()) { generator.writeKey(item0.getKey()); item0.getValue().serialize(generator, mapper); } generator.writeEnd(); } if (ApiTypeHelper.isDefined(this.searchAfter)) { generator.writeKey("search_after"); generator.writeStartArray(); for (String item0 : this.searchAfter) { generator.write(item0); } generator.writeEnd(); } if (this.seqNoPrimaryTerm != null) { generator.writeKey("seq_no_primary_term"); generator.write(this.seqNoPrimaryTerm); } if (this.size != null) { generator.writeKey("size"); generator.write(this.size); } if (this.slice != null) { generator.writeKey("slice"); this.slice.serialize(generator, mapper); } if (ApiTypeHelper.isDefined(this.sort)) { generator.writeKey("sort"); generator.writeStartArray(); for (SortOptions item0 : this.sort) { item0.serialize(generator, mapper); } generator.writeEnd(); } if (ApiTypeHelper.isDefined(this.stats)) { generator.writeKey("stats"); generator.writeStartArray(); for (String item0 : this.stats) { generator.write(item0); } generator.writeEnd(); } if (ApiTypeHelper.isDefined(this.storedFields)) { generator.writeKey("stored_fields"); generator.writeStartArray(); for (String item0 : this.storedFields) { generator.write(item0); } generator.writeEnd(); } if (this.suggest != null) { generator.writeKey("suggest"); this.suggest.serialize(generator, mapper); } if (this.terminateAfter != null) { generator.writeKey("terminate_after"); generator.write(this.terminateAfter); } if (this.timeout != null) { generator.writeKey("timeout"); generator.write(this.timeout); } if (this.trackScores != null) { generator.writeKey("track_scores"); generator.write(this.trackScores); } if (this.trackTotalHits != null) { generator.writeKey("track_total_hits"); this.trackTotalHits.serialize(generator, mapper); } if (this.version != null) { generator.writeKey("version"); generator.write(this.version); } } // --------------------------------------------------------------------------------------------- /** * Builder for {@link SubmitRequest}. */ public static class Builder extends WithJsonObjectBuilderBase implements ObjectBuilder { @Nullable private SourceConfig source; @Nullable private Map aggregations; @Nullable private Boolean allowNoIndices; @Nullable private Boolean allowPartialSearchResults; @Nullable private Boolean analyzeWildcard; @Nullable private String analyzer; @Nullable private Long batchedReduceSize; @Nullable private Boolean ccsMinimizeRoundtrips; @Nullable private FieldCollapse collapse; @Nullable private Operator defaultOperator; @Nullable private String df; @Nullable private List docvalueFields; @Nullable private List expandWildcards; @Nullable private Boolean explain; @Nullable private List fields; @Nullable private Integer from; @Nullable private Highlight highlight; @Nullable private Boolean ignoreThrottled; @Nullable private Boolean ignoreUnavailable; @Nullable private List index; @Nullable private List> indicesBoost; @Nullable private Time keepAlive; @Nullable private Boolean keepOnCompletion; @Nullable private Boolean lenient; @Nullable private Long maxConcurrentShardRequests; @Nullable private String minCompatibleShardNode; @Nullable private Double minScore; @Nullable private PointInTimeReference pit; @Nullable private Query postFilter; @Nullable private Long preFilterShardSize; @Nullable private String preference; @Nullable private Boolean profile; @Nullable private String q; @Nullable private Query query; @Nullable private Boolean requestCache; @Nullable private List rescore; @Nullable private String routing; @Nullable private Map> runtimeMappings; @Nullable private Map scriptFields; @Nullable private Time scroll; @Nullable private List searchAfter; @Nullable private SearchType searchType; @Nullable private Boolean seqNoPrimaryTerm; @Nullable private Integer size; @Nullable private SlicedScroll slice; @Nullable private List sort; @Nullable private List stats; @Nullable private List storedFields; @Nullable private Suggester suggest; @Nullable private Long terminateAfter; @Nullable private String timeout; @Nullable private Boolean trackScores; @Nullable private TrackHits trackTotalHits; @Nullable private Boolean version; @Nullable private Time waitForCompletionTimeout; /** * Indicates which source fields are returned for matching documents. These * fields are returned in the hits._source property of the search response. * * API name: {@code _source} */ public final Builder source(@Nullable SourceConfig value) { this.source = value; return this; } /** * Indicates which source fields are returned for matching documents. These * fields are returned in the hits._source property of the search response. * * API name: {@code _source} */ public final Builder source(Function> fn) { return this.source(fn.apply(new SourceConfig.Builder()).build()); } /** * API name: {@code aggregations} * * Adds all entries of map to aggregations. */ public final Builder aggregations(Map map) { this.aggregations = _mapPutAll(this.aggregations, map); return this; } /** * API name: {@code aggregations} * * Adds an entry to aggregations. */ public final Builder aggregations(String key, Aggregation value) { this.aggregations = _mapPut(this.aggregations, key, value); return this; } /** * API name: {@code aggregations} * * Adds an entry to aggregations using a builder lambda. */ public final Builder aggregations(String key, Function> fn) { return aggregations(key, fn.apply(new Aggregation.Builder()).build()); } /** * Whether to ignore if a wildcard indices expression resolves into no concrete * indices. (This includes _all string or when no indices have been * specified) * * API name: {@code allow_no_indices} */ public final Builder allowNoIndices(@Nullable Boolean value) { this.allowNoIndices = value; return this; } /** * Indicate if an error should be returned if there is a partial search failure * or timeout * * API name: {@code allow_partial_search_results} */ public final Builder allowPartialSearchResults(@Nullable Boolean value) { this.allowPartialSearchResults = value; return this; } /** * Specify whether wildcard and prefix queries should be analyzed (default: * false) * * API name: {@code analyze_wildcard} */ public final Builder analyzeWildcard(@Nullable Boolean value) { this.analyzeWildcard = value; return this; } /** * The analyzer to use for the query string * * API name: {@code analyzer} */ public final Builder analyzer(@Nullable String value) { this.analyzer = value; return this; } /** * The number of shard results that should be reduced at once on the * coordinating node. This value should be used as the granularity at which * progress results will be made available. * * API name: {@code batched_reduce_size} */ public final Builder batchedReduceSize(@Nullable Long value) { this.batchedReduceSize = value; return this; } /** * API name: {@code ccs_minimize_roundtrips} */ public final Builder ccsMinimizeRoundtrips(@Nullable Boolean value) { this.ccsMinimizeRoundtrips = value; return this; } /** * API name: {@code collapse} */ public final Builder collapse(@Nullable FieldCollapse value) { this.collapse = value; return this; } /** * API name: {@code collapse} */ public final Builder collapse(Function> fn) { return this.collapse(fn.apply(new FieldCollapse.Builder()).build()); } /** * The default operator for query string query (AND or OR) * * API name: {@code default_operator} */ public final Builder defaultOperator(@Nullable Operator value) { this.defaultOperator = value; return this; } /** * The field to use as default where no field prefix is given in the query * string * * API name: {@code df} */ public final Builder df(@Nullable String value) { this.df = value; return this; } /** * Array of wildcard (*) patterns. The request returns doc values for field * names matching these patterns in the hits.fields property of the response. * * API name: {@code docvalue_fields} * * Adds all elements of list to docvalueFields. */ public final Builder docvalueFields(List list) { this.docvalueFields = _listAddAll(this.docvalueFields, list); return this; } /** * Array of wildcard (*) patterns. The request returns doc values for field * names matching these patterns in the hits.fields property of the response. * * API name: {@code docvalue_fields} * * Adds one or more values to docvalueFields. */ public final Builder docvalueFields(FieldAndFormat value, FieldAndFormat... values) { this.docvalueFields = _listAdd(this.docvalueFields, value, values); return this; } /** * Array of wildcard (*) patterns. The request returns doc values for field * names matching these patterns in the hits.fields property of the response. * * API name: {@code docvalue_fields} * * Adds a value to docvalueFields using a builder lambda. */ public final Builder docvalueFields(Function> fn) { return docvalueFields(fn.apply(new FieldAndFormat.Builder()).build()); } /** * Whether to expand wildcard expression to concrete indices that are open, * closed or both. * * API name: {@code expand_wildcards} * * Adds all elements of list to expandWildcards. */ public final Builder expandWildcards(List list) { this.expandWildcards = _listAddAll(this.expandWildcards, list); return this; } /** * Whether to expand wildcard expression to concrete indices that are open, * closed or both. * * API name: {@code expand_wildcards} * * Adds one or more values to expandWildcards. */ public final Builder expandWildcards(ExpandWildcard value, ExpandWildcard... values) { this.expandWildcards = _listAdd(this.expandWildcards, value, values); return this; } /** * If true, returns detailed information about score computation as part of a * hit. * * API name: {@code explain} */ public final Builder explain(@Nullable Boolean value) { this.explain = value; return this; } /** * Array of wildcard (*) patterns. The request returns values for field names * matching these patterns in the hits.fields property of the response. * * API name: {@code fields} * * Adds all elements of list to fields. */ public final Builder fields(List list) { this.fields = _listAddAll(this.fields, list); return this; } /** * Array of wildcard (*) patterns. The request returns values for field names * matching these patterns in the hits.fields property of the response. * * API name: {@code fields} * * Adds one or more values to fields. */ public final Builder fields(FieldAndFormat value, FieldAndFormat... values) { this.fields = _listAdd(this.fields, value, values); return this; } /** * Array of wildcard (*) patterns. The request returns values for field names * matching these patterns in the hits.fields property of the response. * * API name: {@code fields} * * Adds a value to fields using a builder lambda. */ public final Builder fields(Function> fn) { return fields(fn.apply(new FieldAndFormat.Builder()).build()); } /** * Starting document offset. By default, you cannot page through more than * 10,000 hits using the from and size parameters. To page through more hits, * use the search_after parameter. * * API name: {@code from} */ public final Builder from(@Nullable Integer value) { this.from = value; return this; } /** * API name: {@code highlight} */ public final Builder highlight(@Nullable Highlight value) { this.highlight = value; return this; } /** * API name: {@code highlight} */ public final Builder highlight(Function> fn) { return this.highlight(fn.apply(new Highlight.Builder()).build()); } /** * Whether specified concrete, expanded or aliased indices should be ignored * when throttled * * API name: {@code ignore_throttled} */ public final Builder ignoreThrottled(@Nullable Boolean value) { this.ignoreThrottled = value; return this; } /** * Whether specified concrete indices should be ignored when unavailable * (missing or closed) * * API name: {@code ignore_unavailable} */ public final Builder ignoreUnavailable(@Nullable Boolean value) { this.ignoreUnavailable = value; return this; } /** * A comma-separated list of index names to search; use _all or * empty string to perform the operation on all indices * * API name: {@code index} * * Adds all elements of list to index. */ public final Builder index(List list) { this.index = _listAddAll(this.index, list); return this; } /** * A comma-separated list of index names to search; use _all or * empty string to perform the operation on all indices * * API name: {@code index} * * Adds one or more values to index. */ public final Builder index(String value, String... values) { this.index = _listAdd(this.index, value, values); return this; } /** * Boosts the _score of documents from specified indices. * * API name: {@code indices_boost} * * Adds all elements of list to indicesBoost. */ public final Builder indicesBoost(List> list) { this.indicesBoost = _listAddAll(this.indicesBoost, list); return this; } /** * Boosts the _score of documents from specified indices. * * API name: {@code indices_boost} * * Adds one or more values to indicesBoost. */ public final Builder indicesBoost(Map value, Map... values) { this.indicesBoost = _listAdd(this.indicesBoost, value, values); return this; } /** * Update the time interval in which the results (partial or final) for this * search will be available * * API name: {@code keep_alive} */ public final Builder keepAlive(@Nullable Time value) { this.keepAlive = value; return this; } /** * Update the time interval in which the results (partial or final) for this * search will be available * * API name: {@code keep_alive} */ public final Builder keepAlive(Function> fn) { return this.keepAlive(fn.apply(new Time.Builder()).build()); } /** * Control whether the response should be stored in the cluster if it completed * within the provided [wait_for_completion] time (default: false) * * API name: {@code keep_on_completion} */ public final Builder keepOnCompletion(@Nullable Boolean value) { this.keepOnCompletion = value; return this; } /** * Specify whether format-based query failures (such as providing text to a * numeric field) should be ignored * * API name: {@code lenient} */ public final Builder lenient(@Nullable Boolean value) { this.lenient = value; return this; } /** * The number of concurrent shard requests per node this search executes * concurrently. This value should be used to limit the impact of the search on * the cluster in order to limit the number of concurrent shard requests * * API name: {@code max_concurrent_shard_requests} */ public final Builder maxConcurrentShardRequests(@Nullable Long value) { this.maxConcurrentShardRequests = value; return this; } /** * API name: {@code min_compatible_shard_node} */ public final Builder minCompatibleShardNode(@Nullable String value) { this.minCompatibleShardNode = value; return this; } /** * Minimum _score for matching documents. Documents with a lower _score are not * included in the search results. * * API name: {@code min_score} */ public final Builder minScore(@Nullable Double value) { this.minScore = value; return this; } /** * Limits the search to a point in time (PIT). If you provide a PIT, you cannot * specify an <index> in the request path. * * API name: {@code pit} */ public final Builder pit(@Nullable PointInTimeReference value) { this.pit = value; return this; } /** * Limits the search to a point in time (PIT). If you provide a PIT, you cannot * specify an <index> in the request path. * * API name: {@code pit} */ public final Builder pit(Function> fn) { return this.pit(fn.apply(new PointInTimeReference.Builder()).build()); } /** * API name: {@code post_filter} */ public final Builder postFilter(@Nullable Query value) { this.postFilter = value; return this; } /** * API name: {@code post_filter} */ public final Builder postFilter(Function> fn) { return this.postFilter(fn.apply(new Query.Builder()).build()); } /** * API name: {@code pre_filter_shard_size} */ public final Builder preFilterShardSize(@Nullable Long value) { this.preFilterShardSize = value; return this; } /** * Specify the node or shard the operation should be performed on (default: * random) * * API name: {@code preference} */ public final Builder preference(@Nullable String value) { this.preference = value; return this; } /** * API name: {@code profile} */ public final Builder profile(@Nullable Boolean value) { this.profile = value; return this; } /** * Query in the Lucene query string syntax * * API name: {@code q} */ public final Builder q(@Nullable String value) { this.q = value; return this; } /** * Defines the search definition using the Query DSL. * * API name: {@code query} */ public final Builder query(@Nullable Query value) { this.query = value; return this; } /** * Defines the search definition using the Query DSL. * * API name: {@code query} */ public final Builder query(Function> fn) { return this.query(fn.apply(new Query.Builder()).build()); } /** * Specify if request cache should be used for this request or not, defaults to * true * * API name: {@code request_cache} */ public final Builder requestCache(@Nullable Boolean value) { this.requestCache = value; return this; } /** * API name: {@code rescore} * * Adds all elements of list to rescore. */ public final Builder rescore(List list) { this.rescore = _listAddAll(this.rescore, list); return this; } /** * API name: {@code rescore} * * Adds one or more values to rescore. */ public final Builder rescore(Rescore value, Rescore... values) { this.rescore = _listAdd(this.rescore, value, values); return this; } /** * API name: {@code rescore} * * Adds a value to rescore using a builder lambda. */ public final Builder rescore(Function> fn) { return rescore(fn.apply(new Rescore.Builder()).build()); } /** * A comma-separated list of specific routing values * * API name: {@code routing} */ public final Builder routing(@Nullable String value) { this.routing = value; return this; } /** * Defines one or more runtime fields in the search request. These fields take * precedence over mapped fields with the same name. * * API name: {@code runtime_mappings} * * Adds all entries of map to runtimeMappings. */ public final Builder runtimeMappings(Map> map) { this.runtimeMappings = _mapPutAll(this.runtimeMappings, map); return this; } /** * Defines one or more runtime fields in the search request. These fields take * precedence over mapped fields with the same name. * * API name: {@code runtime_mappings} * * Adds an entry to runtimeMappings. */ public final Builder runtimeMappings(String key, List value) { this.runtimeMappings = _mapPut(this.runtimeMappings, key, value); return this; } /** * Retrieve a script evaluation (based on different fields) for each hit. * * API name: {@code script_fields} * * Adds all entries of map to scriptFields. */ public final Builder scriptFields(Map map) { this.scriptFields = _mapPutAll(this.scriptFields, map); return this; } /** * Retrieve a script evaluation (based on different fields) for each hit. * * API name: {@code script_fields} * * Adds an entry to scriptFields. */ public final Builder scriptFields(String key, ScriptField value) { this.scriptFields = _mapPut(this.scriptFields, key, value); return this; } /** * Retrieve a script evaluation (based on different fields) for each hit. * * API name: {@code script_fields} * * Adds an entry to scriptFields using a builder lambda. */ public final Builder scriptFields(String key, Function> fn) { return scriptFields(key, fn.apply(new ScriptField.Builder()).build()); } /** * API name: {@code scroll} */ public final Builder scroll(@Nullable Time value) { this.scroll = value; return this; } /** * API name: {@code scroll} */ public final Builder scroll(Function> fn) { return this.scroll(fn.apply(new Time.Builder()).build()); } /** * API name: {@code search_after} * * Adds all elements of list to searchAfter. */ public final Builder searchAfter(List list) { this.searchAfter = _listAddAll(this.searchAfter, list); return this; } /** * API name: {@code search_after} * * Adds one or more values to searchAfter. */ public final Builder searchAfter(String value, String... values) { this.searchAfter = _listAdd(this.searchAfter, value, values); return this; } /** * Search operation type * * API name: {@code search_type} */ public final Builder searchType(@Nullable SearchType value) { this.searchType = value; return this; } /** * If true, returns sequence number and primary term of the last modification of * each hit. See Optimistic concurrency control. * * API name: {@code seq_no_primary_term} */ public final Builder seqNoPrimaryTerm(@Nullable Boolean value) { this.seqNoPrimaryTerm = value; return this; } /** * The number of hits to return. By default, you cannot page through more than * 10,000 hits using the from and size parameters. To page through more hits, * use the search_after parameter. * * API name: {@code size} */ public final Builder size(@Nullable Integer value) { this.size = value; return this; } /** * API name: {@code slice} */ public final Builder slice(@Nullable SlicedScroll value) { this.slice = value; return this; } /** * API name: {@code slice} */ public final Builder slice(Function> fn) { return this.slice(fn.apply(new SlicedScroll.Builder()).build()); } /** * API name: {@code sort} * * Adds all elements of list to sort. */ public final Builder sort(List list) { this.sort = _listAddAll(this.sort, list); return this; } /** * API name: {@code sort} * * Adds one or more values to sort. */ public final Builder sort(SortOptions value, SortOptions... values) { this.sort = _listAdd(this.sort, value, values); return this; } /** * API name: {@code sort} * * Adds a value to sort using a builder lambda. */ public final Builder sort(Function> fn) { return sort(fn.apply(new SortOptions.Builder()).build()); } /** * Stats groups to associate with the search. Each group maintains a statistics * aggregation for its associated searches. You can retrieve these stats using * the indices stats API. * * API name: {@code stats} * * Adds all elements of list to stats. */ public final Builder stats(List list) { this.stats = _listAddAll(this.stats, list); return this; } /** * Stats groups to associate with the search. Each group maintains a statistics * aggregation for its associated searches. You can retrieve these stats using * the indices stats API. * * API name: {@code stats} * * Adds one or more values to stats. */ public final Builder stats(String value, String... values) { this.stats = _listAdd(this.stats, value, values); return this; } /** * List of stored fields to return as part of a hit. If no fields are specified, * no stored fields are included in the response. If this field is specified, * the _source parameter defaults to false. You can pass _source: true to return * both source fields and stored fields in the search response. * * API name: {@code stored_fields} * * Adds all elements of list to storedFields. */ public final Builder storedFields(List list) { this.storedFields = _listAddAll(this.storedFields, list); return this; } /** * List of stored fields to return as part of a hit. If no fields are specified, * no stored fields are included in the response. If this field is specified, * the _source parameter defaults to false. You can pass _source: true to return * both source fields and stored fields in the search response. * * API name: {@code stored_fields} * * Adds one or more values to storedFields. */ public final Builder storedFields(String value, String... values) { this.storedFields = _listAdd(this.storedFields, value, values); return this; } /** * API name: {@code suggest} */ public final Builder suggest(@Nullable Suggester value) { this.suggest = value; return this; } /** * API name: {@code suggest} */ public final Builder suggest(Function> fn) { return this.suggest(fn.apply(new Suggester.Builder()).build()); } /** * Maximum number of documents to collect for each shard. If a query reaches * this limit, Elasticsearch terminates the query early. Elasticsearch collects * documents before sorting. Defaults to 0, which does not terminate query * execution early. * * API name: {@code terminate_after} */ public final Builder terminateAfter(@Nullable Long value) { this.terminateAfter = value; return this; } /** * Specifies the period of time to wait for a response from each shard. If no * response is received before the timeout expires, the request fails and * returns an error. Defaults to no timeout. * * API name: {@code timeout} */ public final Builder timeout(@Nullable String value) { this.timeout = value; return this; } /** * If true, calculate and return document scores, even if the scores are not * used for sorting. * * API name: {@code track_scores} */ public final Builder trackScores(@Nullable Boolean value) { this.trackScores = value; return this; } /** * Number of hits matching the query to count accurately. If true, the exact * number of hits is returned at the cost of some performance. If false, the * response does not include the total number of hits matching the query. * Defaults to 10,000 hits. * * API name: {@code track_total_hits} */ public final Builder trackTotalHits(@Nullable TrackHits value) { this.trackTotalHits = value; return this; } /** * Number of hits matching the query to count accurately. If true, the exact * number of hits is returned at the cost of some performance. If false, the * response does not include the total number of hits matching the query. * Defaults to 10,000 hits. * * API name: {@code track_total_hits} */ public final Builder trackTotalHits(Function> fn) { return this.trackTotalHits(fn.apply(new TrackHits.Builder()).build()); } /** * If true, returns document version as part of a hit. * * API name: {@code version} */ public final Builder version(@Nullable Boolean value) { this.version = value; return this; } /** * Specify the time that the request should block waiting for the final response * * API name: {@code wait_for_completion_timeout} */ public final Builder waitForCompletionTimeout(@Nullable Time value) { this.waitForCompletionTimeout = value; return this; } /** * Specify the time that the request should block waiting for the final response * * API name: {@code wait_for_completion_timeout} */ public final Builder waitForCompletionTimeout(Function> fn) { return this.waitForCompletionTimeout(fn.apply(new Time.Builder()).build()); } @Override protected Builder self() { return this; } /** * Builds a {@link SubmitRequest}. * * @throws NullPointerException * if some of the required fields are null. */ public SubmitRequest build() { _checkSingleUse(); return new SubmitRequest(this); } } // --------------------------------------------------------------------------------------------- /** * Json deserializer for {@link SubmitRequest} */ public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy(Builder::new, SubmitRequest::setupSubmitRequestDeserializer); protected static void setupSubmitRequestDeserializer(ObjectDeserializer op) { op.add(Builder::source, SourceConfig._DESERIALIZER, "_source"); op.add(Builder::aggregations, JsonpDeserializer.stringMapDeserializer(Aggregation._DESERIALIZER), "aggregations", "aggs"); op.add(Builder::collapse, FieldCollapse._DESERIALIZER, "collapse"); op.add(Builder::docvalueFields, JsonpDeserializer.arrayDeserializer(FieldAndFormat._DESERIALIZER), "docvalue_fields"); op.add(Builder::explain, JsonpDeserializer.booleanDeserializer(), "explain"); op.add(Builder::fields, JsonpDeserializer.arrayDeserializer(FieldAndFormat._DESERIALIZER), "fields"); op.add(Builder::from, JsonpDeserializer.integerDeserializer(), "from"); op.add(Builder::highlight, Highlight._DESERIALIZER, "highlight"); op.add(Builder::indicesBoost, JsonpDeserializer.arrayDeserializer( JsonpDeserializer.stringMapDeserializer(JsonpDeserializer.doubleDeserializer())), "indices_boost"); op.add(Builder::minScore, JsonpDeserializer.doubleDeserializer(), "min_score"); op.add(Builder::pit, PointInTimeReference._DESERIALIZER, "pit"); op.add(Builder::postFilter, Query._DESERIALIZER, "post_filter"); op.add(Builder::profile, JsonpDeserializer.booleanDeserializer(), "profile"); op.add(Builder::query, Query._DESERIALIZER, "query"); op.add(Builder::rescore, JsonpDeserializer.arrayDeserializer(Rescore._DESERIALIZER), "rescore"); op.add(Builder::runtimeMappings, JsonpDeserializer.stringMapDeserializer( JsonpDeserializer.arrayDeserializer(RuntimeField._DESERIALIZER)), "runtime_mappings"); op.add(Builder::scriptFields, JsonpDeserializer.stringMapDeserializer(ScriptField._DESERIALIZER), "script_fields"); op.add(Builder::searchAfter, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "search_after"); op.add(Builder::seqNoPrimaryTerm, JsonpDeserializer.booleanDeserializer(), "seq_no_primary_term"); op.add(Builder::size, JsonpDeserializer.integerDeserializer(), "size"); op.add(Builder::slice, SlicedScroll._DESERIALIZER, "slice"); op.add(Builder::sort, JsonpDeserializer.arrayDeserializer(SortOptions._DESERIALIZER), "sort"); op.add(Builder::stats, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "stats"); op.add(Builder::storedFields, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "stored_fields"); op.add(Builder::suggest, Suggester._DESERIALIZER, "suggest"); op.add(Builder::terminateAfter, JsonpDeserializer.longDeserializer(), "terminate_after"); op.add(Builder::timeout, JsonpDeserializer.stringDeserializer(), "timeout"); op.add(Builder::trackScores, JsonpDeserializer.booleanDeserializer(), "track_scores"); op.add(Builder::trackTotalHits, TrackHits._DESERIALIZER, "track_total_hits"); op.add(Builder::version, JsonpDeserializer.booleanDeserializer(), "version"); } // --------------------------------------------------------------------------------------------- /** * Endpoint "{@code async_search.submit}". */ public static final SimpleEndpoint _ENDPOINT = new SimpleEndpoint<>("es/async_search.submit", // Request method request -> { return "POST"; }, // Request path request -> { final int _index = 1 << 0; int propsSet = 0; if (ApiTypeHelper.isDefined(request.index())) propsSet |= _index; if (propsSet == 0) { StringBuilder buf = new StringBuilder(); buf.append("/_async_search"); return buf.toString(); } if (propsSet == (_index)) { StringBuilder buf = new StringBuilder(); buf.append("/"); SimpleEndpoint.pathEncode(request.index.stream().map(v -> v).collect(Collectors.joining(",")), buf); buf.append("/_async_search"); return buf.toString(); } throw SimpleEndpoint.noPathTemplateFound("path"); }, // Request parameters request -> { Map params = new HashMap<>(); params.put("typed_keys", "true"); if (request.df != null) { params.put("df", request.df); } if (request.preFilterShardSize != null) { params.put("pre_filter_shard_size", String.valueOf(request.preFilterShardSize)); } if (request.minCompatibleShardNode != null) { params.put("min_compatible_shard_node", request.minCompatibleShardNode); } if (request.lenient != null) { params.put("lenient", String.valueOf(request.lenient)); } if (request.routing != null) { params.put("routing", request.routing); } if (request.ignoreUnavailable != null) { params.put("ignore_unavailable", String.valueOf(request.ignoreUnavailable)); } if (request.allowNoIndices != null) { params.put("allow_no_indices", String.valueOf(request.allowNoIndices)); } if (request.analyzer != null) { params.put("analyzer", request.analyzer); } if (request.ignoreThrottled != null) { params.put("ignore_throttled", String.valueOf(request.ignoreThrottled)); } if (request.keepOnCompletion != null) { params.put("keep_on_completion", String.valueOf(request.keepOnCompletion)); } if (request.maxConcurrentShardRequests != null) { params.put("max_concurrent_shard_requests", String.valueOf(request.maxConcurrentShardRequests)); } if (request.allowPartialSearchResults != null) { params.put("allow_partial_search_results", String.valueOf(request.allowPartialSearchResults)); } if (ApiTypeHelper.isDefined(request.expandWildcards)) { params.put("expand_wildcards", request.expandWildcards.stream().map(v -> v.jsonValue()).collect(Collectors.joining(","))); } if (request.preference != null) { params.put("preference", request.preference); } if (request.analyzeWildcard != null) { params.put("analyze_wildcard", String.valueOf(request.analyzeWildcard)); } if (request.scroll != null) { params.put("scroll", request.scroll._toJsonString()); } if (request.waitForCompletionTimeout != null) { params.put("wait_for_completion_timeout", request.waitForCompletionTimeout._toJsonString()); } if (request.searchType != null) { params.put("search_type", request.searchType.jsonValue()); } if (request.ccsMinimizeRoundtrips != null) { params.put("ccs_minimize_roundtrips", String.valueOf(request.ccsMinimizeRoundtrips)); } if (request.q != null) { params.put("q", request.q); } if (request.defaultOperator != null) { params.put("default_operator", request.defaultOperator.jsonValue()); } if (request.keepAlive != null) { params.put("keep_alive", request.keepAlive._toJsonString()); } if (request.requestCache != null) { params.put("request_cache", String.valueOf(request.requestCache)); } if (request.batchedReduceSize != null) { params.put("batched_reduce_size", String.valueOf(request.batchedReduceSize)); } return params; }, SimpleEndpoint.emptyMap(), true, SubmitResponse._DESERIALIZER); /** * Create an "{@code async_search.submit}" endpoint. */ public static Endpoint, ErrorResponse> createSubmitEndpoint( JsonpDeserializer tDocumentDeserializer) { return _ENDPOINT .withResponseDeserializer(SubmitResponse.createSubmitResponseDeserializer(tDocumentDeserializer)); } }
* API name: {@code from} */ @Nullable public final Integer from() { return this.from; } /** * API name: {@code highlight} */ @Nullable public final Highlight highlight() { return this.highlight; } /** * Whether specified concrete, expanded or aliased indices should be ignored * when throttled *
* API name: {@code ignore_throttled} */ @Nullable public final Boolean ignoreThrottled() { return this.ignoreThrottled; } /** * Whether specified concrete indices should be ignored when unavailable * (missing or closed) *
* API name: {@code ignore_unavailable} */ @Nullable public final Boolean ignoreUnavailable() { return this.ignoreUnavailable; } /** * A comma-separated list of index names to search; use _all or * empty string to perform the operation on all indices *
* API name: {@code index} */ public final List index() { return this.index; } /** * Boosts the _score of documents from specified indices. * * API name: {@code indices_boost} */ public final List> indicesBoost() { return this.indicesBoost; } /** * Update the time interval in which the results (partial or final) for this * search will be available * * API name: {@code keep_alive} */ @Nullable public final Time keepAlive() { return this.keepAlive; } /** * Control whether the response should be stored in the cluster if it completed * within the provided [wait_for_completion] time (default: false) * * API name: {@code keep_on_completion} */ @Nullable public final Boolean keepOnCompletion() { return this.keepOnCompletion; } /** * Specify whether format-based query failures (such as providing text to a * numeric field) should be ignored * * API name: {@code lenient} */ @Nullable public final Boolean lenient() { return this.lenient; } /** * The number of concurrent shard requests per node this search executes * concurrently. This value should be used to limit the impact of the search on * the cluster in order to limit the number of concurrent shard requests * * API name: {@code max_concurrent_shard_requests} */ @Nullable public final Long maxConcurrentShardRequests() { return this.maxConcurrentShardRequests; } /** * API name: {@code min_compatible_shard_node} */ @Nullable public final String minCompatibleShardNode() { return this.minCompatibleShardNode; } /** * Minimum _score for matching documents. Documents with a lower _score are not * included in the search results. * * API name: {@code min_score} */ @Nullable public final Double minScore() { return this.minScore; } /** * Limits the search to a point in time (PIT). If you provide a PIT, you cannot * specify an <index> in the request path. * * API name: {@code pit} */ @Nullable public final PointInTimeReference pit() { return this.pit; } /** * API name: {@code post_filter} */ @Nullable public final Query postFilter() { return this.postFilter; } /** * API name: {@code pre_filter_shard_size} */ @Nullable public final Long preFilterShardSize() { return this.preFilterShardSize; } /** * Specify the node or shard the operation should be performed on (default: * random) * * API name: {@code preference} */ @Nullable public final String preference() { return this.preference; } /** * API name: {@code profile} */ @Nullable public final Boolean profile() { return this.profile; } /** * Query in the Lucene query string syntax * * API name: {@code q} */ @Nullable public final String q() { return this.q; } /** * Defines the search definition using the Query DSL. * * API name: {@code query} */ @Nullable public final Query query() { return this.query; } /** * Specify if request cache should be used for this request or not, defaults to * true * * API name: {@code request_cache} */ @Nullable public final Boolean requestCache() { return this.requestCache; } /** * API name: {@code rescore} */ public final List rescore() { return this.rescore; } /** * A comma-separated list of specific routing values * * API name: {@code routing} */ @Nullable public final String routing() { return this.routing; } /** * Defines one or more runtime fields in the search request. These fields take * precedence over mapped fields with the same name. * * API name: {@code runtime_mappings} */ public final Map> runtimeMappings() { return this.runtimeMappings; } /** * Retrieve a script evaluation (based on different fields) for each hit. * * API name: {@code script_fields} */ public final Map scriptFields() { return this.scriptFields; } /** * API name: {@code scroll} */ @Nullable public final Time scroll() { return this.scroll; } /** * API name: {@code search_after} */ public final List searchAfter() { return this.searchAfter; } /** * Search operation type * * API name: {@code search_type} */ @Nullable public final SearchType searchType() { return this.searchType; } /** * If true, returns sequence number and primary term of the last modification of * each hit. See Optimistic concurrency control. * * API name: {@code seq_no_primary_term} */ @Nullable public final Boolean seqNoPrimaryTerm() { return this.seqNoPrimaryTerm; } /** * The number of hits to return. By default, you cannot page through more than * 10,000 hits using the from and size parameters. To page through more hits, * use the search_after parameter. * * API name: {@code size} */ @Nullable public final Integer size() { return this.size; } /** * API name: {@code slice} */ @Nullable public final SlicedScroll slice() { return this.slice; } /** * API name: {@code sort} */ public final List sort() { return this.sort; } /** * Stats groups to associate with the search. Each group maintains a statistics * aggregation for its associated searches. You can retrieve these stats using * the indices stats API. * * API name: {@code stats} */ public final List stats() { return this.stats; } /** * List of stored fields to return as part of a hit. If no fields are specified, * no stored fields are included in the response. If this field is specified, * the _source parameter defaults to false. You can pass _source: true to return * both source fields and stored fields in the search response. * * API name: {@code stored_fields} */ public final List storedFields() { return this.storedFields; } /** * API name: {@code suggest} */ @Nullable public final Suggester suggest() { return this.suggest; } /** * Maximum number of documents to collect for each shard. If a query reaches * this limit, Elasticsearch terminates the query early. Elasticsearch collects * documents before sorting. Defaults to 0, which does not terminate query * execution early. * * API name: {@code terminate_after} */ @Nullable public final Long terminateAfter() { return this.terminateAfter; } /** * Specifies the period of time to wait for a response from each shard. If no * response is received before the timeout expires, the request fails and * returns an error. Defaults to no timeout. * * API name: {@code timeout} */ @Nullable public final String timeout() { return this.timeout; } /** * If true, calculate and return document scores, even if the scores are not * used for sorting. * * API name: {@code track_scores} */ @Nullable public final Boolean trackScores() { return this.trackScores; } /** * Number of hits matching the query to count accurately. If true, the exact * number of hits is returned at the cost of some performance. If false, the * response does not include the total number of hits matching the query. * Defaults to 10,000 hits. * * API name: {@code track_total_hits} */ @Nullable public final TrackHits trackTotalHits() { return this.trackTotalHits; } /** * If true, returns document version as part of a hit. * * API name: {@code version} */ @Nullable public final Boolean version() { return this.version; } /** * Specify the time that the request should block waiting for the final response * * API name: {@code wait_for_completion_timeout} */ @Nullable public final Time waitForCompletionTimeout() { return this.waitForCompletionTimeout; } /** * 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.source != null) { generator.writeKey("_source"); this.source.serialize(generator, mapper); } if (ApiTypeHelper.isDefined(this.aggregations)) { generator.writeKey("aggregations"); generator.writeStartObject(); for (Map.Entry item0 : this.aggregations.entrySet()) { generator.writeKey(item0.getKey()); item0.getValue().serialize(generator, mapper); } generator.writeEnd(); } if (this.collapse != null) { generator.writeKey("collapse"); this.collapse.serialize(generator, mapper); } if (ApiTypeHelper.isDefined(this.docvalueFields)) { generator.writeKey("docvalue_fields"); generator.writeStartArray(); for (FieldAndFormat item0 : this.docvalueFields) { item0.serialize(generator, mapper); } generator.writeEnd(); } if (this.explain != null) { generator.writeKey("explain"); generator.write(this.explain); } if (ApiTypeHelper.isDefined(this.fields)) { generator.writeKey("fields"); generator.writeStartArray(); for (FieldAndFormat item0 : this.fields) { item0.serialize(generator, mapper); } generator.writeEnd(); } if (this.from != null) { generator.writeKey("from"); generator.write(this.from); } if (this.highlight != null) { generator.writeKey("highlight"); this.highlight.serialize(generator, mapper); } if (ApiTypeHelper.isDefined(this.indicesBoost)) { generator.writeKey("indices_boost"); generator.writeStartArray(); for (Map item0 : this.indicesBoost) { generator.writeStartObject(); if (item0 != null) { for (Map.Entry item1 : item0.entrySet()) { generator.writeKey(item1.getKey()); generator.write(item1.getValue()); } } generator.writeEnd(); } generator.writeEnd(); } if (this.minScore != null) { generator.writeKey("min_score"); generator.write(this.minScore); } if (this.pit != null) { generator.writeKey("pit"); this.pit.serialize(generator, mapper); } if (this.postFilter != null) { generator.writeKey("post_filter"); this.postFilter.serialize(generator, mapper); } if (this.profile != null) { generator.writeKey("profile"); generator.write(this.profile); } if (this.query != null) { generator.writeKey("query"); this.query.serialize(generator, mapper); } if (ApiTypeHelper.isDefined(this.rescore)) { generator.writeKey("rescore"); generator.writeStartArray(); for (Rescore item0 : this.rescore) { item0.serialize(generator, mapper); } generator.writeEnd(); } if (ApiTypeHelper.isDefined(this.runtimeMappings)) { generator.writeKey("runtime_mappings"); generator.writeStartObject(); for (Map.Entry> item0 : this.runtimeMappings.entrySet()) { generator.writeKey(item0.getKey()); generator.writeStartArray(); if (item0.getValue() != null) { for (RuntimeField item1 : item0.getValue()) { item1.serialize(generator, mapper); } } generator.writeEnd(); } generator.writeEnd(); } if (ApiTypeHelper.isDefined(this.scriptFields)) { generator.writeKey("script_fields"); generator.writeStartObject(); for (Map.Entry item0 : this.scriptFields.entrySet()) { generator.writeKey(item0.getKey()); item0.getValue().serialize(generator, mapper); } generator.writeEnd(); } if (ApiTypeHelper.isDefined(this.searchAfter)) { generator.writeKey("search_after"); generator.writeStartArray(); for (String item0 : this.searchAfter) { generator.write(item0); } generator.writeEnd(); } if (this.seqNoPrimaryTerm != null) { generator.writeKey("seq_no_primary_term"); generator.write(this.seqNoPrimaryTerm); } if (this.size != null) { generator.writeKey("size"); generator.write(this.size); } if (this.slice != null) { generator.writeKey("slice"); this.slice.serialize(generator, mapper); } if (ApiTypeHelper.isDefined(this.sort)) { generator.writeKey("sort"); generator.writeStartArray(); for (SortOptions item0 : this.sort) { item0.serialize(generator, mapper); } generator.writeEnd(); } if (ApiTypeHelper.isDefined(this.stats)) { generator.writeKey("stats"); generator.writeStartArray(); for (String item0 : this.stats) { generator.write(item0); } generator.writeEnd(); } if (ApiTypeHelper.isDefined(this.storedFields)) { generator.writeKey("stored_fields"); generator.writeStartArray(); for (String item0 : this.storedFields) { generator.write(item0); } generator.writeEnd(); } if (this.suggest != null) { generator.writeKey("suggest"); this.suggest.serialize(generator, mapper); } if (this.terminateAfter != null) { generator.writeKey("terminate_after"); generator.write(this.terminateAfter); } if (this.timeout != null) { generator.writeKey("timeout"); generator.write(this.timeout); } if (this.trackScores != null) { generator.writeKey("track_scores"); generator.write(this.trackScores); } if (this.trackTotalHits != null) { generator.writeKey("track_total_hits"); this.trackTotalHits.serialize(generator, mapper); } if (this.version != null) { generator.writeKey("version"); generator.write(this.version); } } // --------------------------------------------------------------------------------------------- /** * Builder for {@link SubmitRequest}. */ public static class Builder extends WithJsonObjectBuilderBase implements ObjectBuilder { @Nullable private SourceConfig source; @Nullable private Map aggregations; @Nullable private Boolean allowNoIndices; @Nullable private Boolean allowPartialSearchResults; @Nullable private Boolean analyzeWildcard; @Nullable private String analyzer; @Nullable private Long batchedReduceSize; @Nullable private Boolean ccsMinimizeRoundtrips; @Nullable private FieldCollapse collapse; @Nullable private Operator defaultOperator; @Nullable private String df; @Nullable private List docvalueFields; @Nullable private List expandWildcards; @Nullable private Boolean explain; @Nullable private List fields; @Nullable private Integer from; @Nullable private Highlight highlight; @Nullable private Boolean ignoreThrottled; @Nullable private Boolean ignoreUnavailable; @Nullable private List index; @Nullable private List> indicesBoost; @Nullable private Time keepAlive; @Nullable private Boolean keepOnCompletion; @Nullable private Boolean lenient; @Nullable private Long maxConcurrentShardRequests; @Nullable private String minCompatibleShardNode; @Nullable private Double minScore; @Nullable private PointInTimeReference pit; @Nullable private Query postFilter; @Nullable private Long preFilterShardSize; @Nullable private String preference; @Nullable private Boolean profile; @Nullable private String q; @Nullable private Query query; @Nullable private Boolean requestCache; @Nullable private List rescore; @Nullable private String routing; @Nullable private Map> runtimeMappings; @Nullable private Map scriptFields; @Nullable private Time scroll; @Nullable private List searchAfter; @Nullable private SearchType searchType; @Nullable private Boolean seqNoPrimaryTerm; @Nullable private Integer size; @Nullable private SlicedScroll slice; @Nullable private List sort; @Nullable private List stats; @Nullable private List storedFields; @Nullable private Suggester suggest; @Nullable private Long terminateAfter; @Nullable private String timeout; @Nullable private Boolean trackScores; @Nullable private TrackHits trackTotalHits; @Nullable private Boolean version; @Nullable private Time waitForCompletionTimeout; /** * Indicates which source fields are returned for matching documents. These * fields are returned in the hits._source property of the search response. * * API name: {@code _source} */ public final Builder source(@Nullable SourceConfig value) { this.source = value; return this; } /** * Indicates which source fields are returned for matching documents. These * fields are returned in the hits._source property of the search response. * * API name: {@code _source} */ public final Builder source(Function> fn) { return this.source(fn.apply(new SourceConfig.Builder()).build()); } /** * API name: {@code aggregations} * * Adds all entries of map to aggregations. */ public final Builder aggregations(Map map) { this.aggregations = _mapPutAll(this.aggregations, map); return this; } /** * API name: {@code aggregations} * * Adds an entry to aggregations. */ public final Builder aggregations(String key, Aggregation value) { this.aggregations = _mapPut(this.aggregations, key, value); return this; } /** * API name: {@code aggregations} * * Adds an entry to aggregations using a builder lambda. */ public final Builder aggregations(String key, Function> fn) { return aggregations(key, fn.apply(new Aggregation.Builder()).build()); } /** * Whether to ignore if a wildcard indices expression resolves into no concrete * indices. (This includes _all string or when no indices have been * specified) * * API name: {@code allow_no_indices} */ public final Builder allowNoIndices(@Nullable Boolean value) { this.allowNoIndices = value; return this; } /** * Indicate if an error should be returned if there is a partial search failure * or timeout * * API name: {@code allow_partial_search_results} */ public final Builder allowPartialSearchResults(@Nullable Boolean value) { this.allowPartialSearchResults = value; return this; } /** * Specify whether wildcard and prefix queries should be analyzed (default: * false) * * API name: {@code analyze_wildcard} */ public final Builder analyzeWildcard(@Nullable Boolean value) { this.analyzeWildcard = value; return this; } /** * The analyzer to use for the query string * * API name: {@code analyzer} */ public final Builder analyzer(@Nullable String value) { this.analyzer = value; return this; } /** * The number of shard results that should be reduced at once on the * coordinating node. This value should be used as the granularity at which * progress results will be made available. * * API name: {@code batched_reduce_size} */ public final Builder batchedReduceSize(@Nullable Long value) { this.batchedReduceSize = value; return this; } /** * API name: {@code ccs_minimize_roundtrips} */ public final Builder ccsMinimizeRoundtrips(@Nullable Boolean value) { this.ccsMinimizeRoundtrips = value; return this; } /** * API name: {@code collapse} */ public final Builder collapse(@Nullable FieldCollapse value) { this.collapse = value; return this; } /** * API name: {@code collapse} */ public final Builder collapse(Function> fn) { return this.collapse(fn.apply(new FieldCollapse.Builder()).build()); } /** * The default operator for query string query (AND or OR) * * API name: {@code default_operator} */ public final Builder defaultOperator(@Nullable Operator value) { this.defaultOperator = value; return this; } /** * The field to use as default where no field prefix is given in the query * string * * API name: {@code df} */ public final Builder df(@Nullable String value) { this.df = value; return this; } /** * Array of wildcard (*) patterns. The request returns doc values for field * names matching these patterns in the hits.fields property of the response. * * API name: {@code docvalue_fields} * * Adds all elements of list to docvalueFields. */ public final Builder docvalueFields(List list) { this.docvalueFields = _listAddAll(this.docvalueFields, list); return this; } /** * Array of wildcard (*) patterns. The request returns doc values for field * names matching these patterns in the hits.fields property of the response. * * API name: {@code docvalue_fields} * * Adds one or more values to docvalueFields. */ public final Builder docvalueFields(FieldAndFormat value, FieldAndFormat... values) { this.docvalueFields = _listAdd(this.docvalueFields, value, values); return this; } /** * Array of wildcard (*) patterns. The request returns doc values for field * names matching these patterns in the hits.fields property of the response. * * API name: {@code docvalue_fields} * * Adds a value to docvalueFields using a builder lambda. */ public final Builder docvalueFields(Function> fn) { return docvalueFields(fn.apply(new FieldAndFormat.Builder()).build()); } /** * Whether to expand wildcard expression to concrete indices that are open, * closed or both. * * API name: {@code expand_wildcards} * * Adds all elements of list to expandWildcards. */ public final Builder expandWildcards(List list) { this.expandWildcards = _listAddAll(this.expandWildcards, list); return this; } /** * Whether to expand wildcard expression to concrete indices that are open, * closed or both. * * API name: {@code expand_wildcards} * * Adds one or more values to expandWildcards. */ public final Builder expandWildcards(ExpandWildcard value, ExpandWildcard... values) { this.expandWildcards = _listAdd(this.expandWildcards, value, values); return this; } /** * If true, returns detailed information about score computation as part of a * hit. * * API name: {@code explain} */ public final Builder explain(@Nullable Boolean value) { this.explain = value; return this; } /** * Array of wildcard (*) patterns. The request returns values for field names * matching these patterns in the hits.fields property of the response. * * API name: {@code fields} * * Adds all elements of list to fields. */ public final Builder fields(List list) { this.fields = _listAddAll(this.fields, list); return this; } /** * Array of wildcard (*) patterns. The request returns values for field names * matching these patterns in the hits.fields property of the response. * * API name: {@code fields} * * Adds one or more values to fields. */ public final Builder fields(FieldAndFormat value, FieldAndFormat... values) { this.fields = _listAdd(this.fields, value, values); return this; } /** * Array of wildcard (*) patterns. The request returns values for field names * matching these patterns in the hits.fields property of the response. * * API name: {@code fields} * * Adds a value to fields using a builder lambda. */ public final Builder fields(Function> fn) { return fields(fn.apply(new FieldAndFormat.Builder()).build()); } /** * Starting document offset. By default, you cannot page through more than * 10,000 hits using the from and size parameters. To page through more hits, * use the search_after parameter. * * API name: {@code from} */ public final Builder from(@Nullable Integer value) { this.from = value; return this; } /** * API name: {@code highlight} */ public final Builder highlight(@Nullable Highlight value) { this.highlight = value; return this; } /** * API name: {@code highlight} */ public final Builder highlight(Function> fn) { return this.highlight(fn.apply(new Highlight.Builder()).build()); } /** * Whether specified concrete, expanded or aliased indices should be ignored * when throttled * * API name: {@code ignore_throttled} */ public final Builder ignoreThrottled(@Nullable Boolean value) { this.ignoreThrottled = value; return this; } /** * Whether specified concrete indices should be ignored when unavailable * (missing or closed) * * API name: {@code ignore_unavailable} */ public final Builder ignoreUnavailable(@Nullable Boolean value) { this.ignoreUnavailable = value; return this; } /** * A comma-separated list of index names to search; use _all or * empty string to perform the operation on all indices * * API name: {@code index} * * Adds all elements of list to index. */ public final Builder index(List list) { this.index = _listAddAll(this.index, list); return this; } /** * A comma-separated list of index names to search; use _all or * empty string to perform the operation on all indices * * API name: {@code index} * * Adds one or more values to index. */ public final Builder index(String value, String... values) { this.index = _listAdd(this.index, value, values); return this; } /** * Boosts the _score of documents from specified indices. * * API name: {@code indices_boost} * * Adds all elements of list to indicesBoost. */ public final Builder indicesBoost(List> list) { this.indicesBoost = _listAddAll(this.indicesBoost, list); return this; } /** * Boosts the _score of documents from specified indices. * * API name: {@code indices_boost} * * Adds one or more values to indicesBoost. */ public final Builder indicesBoost(Map value, Map... values) { this.indicesBoost = _listAdd(this.indicesBoost, value, values); return this; } /** * Update the time interval in which the results (partial or final) for this * search will be available * * API name: {@code keep_alive} */ public final Builder keepAlive(@Nullable Time value) { this.keepAlive = value; return this; } /** * Update the time interval in which the results (partial or final) for this * search will be available * * API name: {@code keep_alive} */ public final Builder keepAlive(Function> fn) { return this.keepAlive(fn.apply(new Time.Builder()).build()); } /** * Control whether the response should be stored in the cluster if it completed * within the provided [wait_for_completion] time (default: false) * * API name: {@code keep_on_completion} */ public final Builder keepOnCompletion(@Nullable Boolean value) { this.keepOnCompletion = value; return this; } /** * Specify whether format-based query failures (such as providing text to a * numeric field) should be ignored * * API name: {@code lenient} */ public final Builder lenient(@Nullable Boolean value) { this.lenient = value; return this; } /** * The number of concurrent shard requests per node this search executes * concurrently. This value should be used to limit the impact of the search on * the cluster in order to limit the number of concurrent shard requests * * API name: {@code max_concurrent_shard_requests} */ public final Builder maxConcurrentShardRequests(@Nullable Long value) { this.maxConcurrentShardRequests = value; return this; } /** * API name: {@code min_compatible_shard_node} */ public final Builder minCompatibleShardNode(@Nullable String value) { this.minCompatibleShardNode = value; return this; } /** * Minimum _score for matching documents. Documents with a lower _score are not * included in the search results. * * API name: {@code min_score} */ public final Builder minScore(@Nullable Double value) { this.minScore = value; return this; } /** * Limits the search to a point in time (PIT). If you provide a PIT, you cannot * specify an <index> in the request path. * * API name: {@code pit} */ public final Builder pit(@Nullable PointInTimeReference value) { this.pit = value; return this; } /** * Limits the search to a point in time (PIT). If you provide a PIT, you cannot * specify an <index> in the request path. * * API name: {@code pit} */ public final Builder pit(Function> fn) { return this.pit(fn.apply(new PointInTimeReference.Builder()).build()); } /** * API name: {@code post_filter} */ public final Builder postFilter(@Nullable Query value) { this.postFilter = value; return this; } /** * API name: {@code post_filter} */ public final Builder postFilter(Function> fn) { return this.postFilter(fn.apply(new Query.Builder()).build()); } /** * API name: {@code pre_filter_shard_size} */ public final Builder preFilterShardSize(@Nullable Long value) { this.preFilterShardSize = value; return this; } /** * Specify the node or shard the operation should be performed on (default: * random) * * API name: {@code preference} */ public final Builder preference(@Nullable String value) { this.preference = value; return this; } /** * API name: {@code profile} */ public final Builder profile(@Nullable Boolean value) { this.profile = value; return this; } /** * Query in the Lucene query string syntax * * API name: {@code q} */ public final Builder q(@Nullable String value) { this.q = value; return this; } /** * Defines the search definition using the Query DSL. * * API name: {@code query} */ public final Builder query(@Nullable Query value) { this.query = value; return this; } /** * Defines the search definition using the Query DSL. * * API name: {@code query} */ public final Builder query(Function> fn) { return this.query(fn.apply(new Query.Builder()).build()); } /** * Specify if request cache should be used for this request or not, defaults to * true * * API name: {@code request_cache} */ public final Builder requestCache(@Nullable Boolean value) { this.requestCache = value; return this; } /** * API name: {@code rescore} * * Adds all elements of list to rescore. */ public final Builder rescore(List list) { this.rescore = _listAddAll(this.rescore, list); return this; } /** * API name: {@code rescore} * * Adds one or more values to rescore. */ public final Builder rescore(Rescore value, Rescore... values) { this.rescore = _listAdd(this.rescore, value, values); return this; } /** * API name: {@code rescore} * * Adds a value to rescore using a builder lambda. */ public final Builder rescore(Function> fn) { return rescore(fn.apply(new Rescore.Builder()).build()); } /** * A comma-separated list of specific routing values * * API name: {@code routing} */ public final Builder routing(@Nullable String value) { this.routing = value; return this; } /** * Defines one or more runtime fields in the search request. These fields take * precedence over mapped fields with the same name. * * API name: {@code runtime_mappings} * * Adds all entries of map to runtimeMappings. */ public final Builder runtimeMappings(Map> map) { this.runtimeMappings = _mapPutAll(this.runtimeMappings, map); return this; } /** * Defines one or more runtime fields in the search request. These fields take * precedence over mapped fields with the same name. * * API name: {@code runtime_mappings} * * Adds an entry to runtimeMappings. */ public final Builder runtimeMappings(String key, List value) { this.runtimeMappings = _mapPut(this.runtimeMappings, key, value); return this; } /** * Retrieve a script evaluation (based on different fields) for each hit. * * API name: {@code script_fields} * * Adds all entries of map to scriptFields. */ public final Builder scriptFields(Map map) { this.scriptFields = _mapPutAll(this.scriptFields, map); return this; } /** * Retrieve a script evaluation (based on different fields) for each hit. * * API name: {@code script_fields} * * Adds an entry to scriptFields. */ public final Builder scriptFields(String key, ScriptField value) { this.scriptFields = _mapPut(this.scriptFields, key, value); return this; } /** * Retrieve a script evaluation (based on different fields) for each hit. * * API name: {@code script_fields} * * Adds an entry to scriptFields using a builder lambda. */ public final Builder scriptFields(String key, Function> fn) { return scriptFields(key, fn.apply(new ScriptField.Builder()).build()); } /** * API name: {@code scroll} */ public final Builder scroll(@Nullable Time value) { this.scroll = value; return this; } /** * API name: {@code scroll} */ public final Builder scroll(Function> fn) { return this.scroll(fn.apply(new Time.Builder()).build()); } /** * API name: {@code search_after} * * Adds all elements of list to searchAfter. */ public final Builder searchAfter(List list) { this.searchAfter = _listAddAll(this.searchAfter, list); return this; } /** * API name: {@code search_after} * * Adds one or more values to searchAfter. */ public final Builder searchAfter(String value, String... values) { this.searchAfter = _listAdd(this.searchAfter, value, values); return this; } /** * Search operation type * * API name: {@code search_type} */ public final Builder searchType(@Nullable SearchType value) { this.searchType = value; return this; } /** * If true, returns sequence number and primary term of the last modification of * each hit. See Optimistic concurrency control. * * API name: {@code seq_no_primary_term} */ public final Builder seqNoPrimaryTerm(@Nullable Boolean value) { this.seqNoPrimaryTerm = value; return this; } /** * The number of hits to return. By default, you cannot page through more than * 10,000 hits using the from and size parameters. To page through more hits, * use the search_after parameter. * * API name: {@code size} */ public final Builder size(@Nullable Integer value) { this.size = value; return this; } /** * API name: {@code slice} */ public final Builder slice(@Nullable SlicedScroll value) { this.slice = value; return this; } /** * API name: {@code slice} */ public final Builder slice(Function> fn) { return this.slice(fn.apply(new SlicedScroll.Builder()).build()); } /** * API name: {@code sort} * * Adds all elements of list to sort. */ public final Builder sort(List list) { this.sort = _listAddAll(this.sort, list); return this; } /** * API name: {@code sort} * * Adds one or more values to sort. */ public final Builder sort(SortOptions value, SortOptions... values) { this.sort = _listAdd(this.sort, value, values); return this; } /** * API name: {@code sort} * * Adds a value to sort using a builder lambda. */ public final Builder sort(Function> fn) { return sort(fn.apply(new SortOptions.Builder()).build()); } /** * Stats groups to associate with the search. Each group maintains a statistics * aggregation for its associated searches. You can retrieve these stats using * the indices stats API. * * API name: {@code stats} * * Adds all elements of list to stats. */ public final Builder stats(List list) { this.stats = _listAddAll(this.stats, list); return this; } /** * Stats groups to associate with the search. Each group maintains a statistics * aggregation for its associated searches. You can retrieve these stats using * the indices stats API. * * API name: {@code stats} * * Adds one or more values to stats. */ public final Builder stats(String value, String... values) { this.stats = _listAdd(this.stats, value, values); return this; } /** * List of stored fields to return as part of a hit. If no fields are specified, * no stored fields are included in the response. If this field is specified, * the _source parameter defaults to false. You can pass _source: true to return * both source fields and stored fields in the search response. * * API name: {@code stored_fields} * * Adds all elements of list to storedFields. */ public final Builder storedFields(List list) { this.storedFields = _listAddAll(this.storedFields, list); return this; } /** * List of stored fields to return as part of a hit. If no fields are specified, * no stored fields are included in the response. If this field is specified, * the _source parameter defaults to false. You can pass _source: true to return * both source fields and stored fields in the search response. * * API name: {@code stored_fields} * * Adds one or more values to storedFields. */ public final Builder storedFields(String value, String... values) { this.storedFields = _listAdd(this.storedFields, value, values); return this; } /** * API name: {@code suggest} */ public final Builder suggest(@Nullable Suggester value) { this.suggest = value; return this; } /** * API name: {@code suggest} */ public final Builder suggest(Function> fn) { return this.suggest(fn.apply(new Suggester.Builder()).build()); } /** * Maximum number of documents to collect for each shard. If a query reaches * this limit, Elasticsearch terminates the query early. Elasticsearch collects * documents before sorting. Defaults to 0, which does not terminate query * execution early. * * API name: {@code terminate_after} */ public final Builder terminateAfter(@Nullable Long value) { this.terminateAfter = value; return this; } /** * Specifies the period of time to wait for a response from each shard. If no * response is received before the timeout expires, the request fails and * returns an error. Defaults to no timeout. * * API name: {@code timeout} */ public final Builder timeout(@Nullable String value) { this.timeout = value; return this; } /** * If true, calculate and return document scores, even if the scores are not * used for sorting. * * API name: {@code track_scores} */ public final Builder trackScores(@Nullable Boolean value) { this.trackScores = value; return this; } /** * Number of hits matching the query to count accurately. If true, the exact * number of hits is returned at the cost of some performance. If false, the * response does not include the total number of hits matching the query. * Defaults to 10,000 hits. * * API name: {@code track_total_hits} */ public final Builder trackTotalHits(@Nullable TrackHits value) { this.trackTotalHits = value; return this; } /** * Number of hits matching the query to count accurately. If true, the exact * number of hits is returned at the cost of some performance. If false, the * response does not include the total number of hits matching the query. * Defaults to 10,000 hits. * * API name: {@code track_total_hits} */ public final Builder trackTotalHits(Function> fn) { return this.trackTotalHits(fn.apply(new TrackHits.Builder()).build()); } /** * If true, returns document version as part of a hit. * * API name: {@code version} */ public final Builder version(@Nullable Boolean value) { this.version = value; return this; } /** * Specify the time that the request should block waiting for the final response * * API name: {@code wait_for_completion_timeout} */ public final Builder waitForCompletionTimeout(@Nullable Time value) { this.waitForCompletionTimeout = value; return this; } /** * Specify the time that the request should block waiting for the final response * * API name: {@code wait_for_completion_timeout} */ public final Builder waitForCompletionTimeout(Function> fn) { return this.waitForCompletionTimeout(fn.apply(new Time.Builder()).build()); } @Override protected Builder self() { return this; } /** * Builds a {@link SubmitRequest}. * * @throws NullPointerException * if some of the required fields are null. */ public SubmitRequest build() { _checkSingleUse(); return new SubmitRequest(this); } } // --------------------------------------------------------------------------------------------- /** * Json deserializer for {@link SubmitRequest} */ public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy(Builder::new, SubmitRequest::setupSubmitRequestDeserializer); protected static void setupSubmitRequestDeserializer(ObjectDeserializer op) { op.add(Builder::source, SourceConfig._DESERIALIZER, "_source"); op.add(Builder::aggregations, JsonpDeserializer.stringMapDeserializer(Aggregation._DESERIALIZER), "aggregations", "aggs"); op.add(Builder::collapse, FieldCollapse._DESERIALIZER, "collapse"); op.add(Builder::docvalueFields, JsonpDeserializer.arrayDeserializer(FieldAndFormat._DESERIALIZER), "docvalue_fields"); op.add(Builder::explain, JsonpDeserializer.booleanDeserializer(), "explain"); op.add(Builder::fields, JsonpDeserializer.arrayDeserializer(FieldAndFormat._DESERIALIZER), "fields"); op.add(Builder::from, JsonpDeserializer.integerDeserializer(), "from"); op.add(Builder::highlight, Highlight._DESERIALIZER, "highlight"); op.add(Builder::indicesBoost, JsonpDeserializer.arrayDeserializer( JsonpDeserializer.stringMapDeserializer(JsonpDeserializer.doubleDeserializer())), "indices_boost"); op.add(Builder::minScore, JsonpDeserializer.doubleDeserializer(), "min_score"); op.add(Builder::pit, PointInTimeReference._DESERIALIZER, "pit"); op.add(Builder::postFilter, Query._DESERIALIZER, "post_filter"); op.add(Builder::profile, JsonpDeserializer.booleanDeserializer(), "profile"); op.add(Builder::query, Query._DESERIALIZER, "query"); op.add(Builder::rescore, JsonpDeserializer.arrayDeserializer(Rescore._DESERIALIZER), "rescore"); op.add(Builder::runtimeMappings, JsonpDeserializer.stringMapDeserializer( JsonpDeserializer.arrayDeserializer(RuntimeField._DESERIALIZER)), "runtime_mappings"); op.add(Builder::scriptFields, JsonpDeserializer.stringMapDeserializer(ScriptField._DESERIALIZER), "script_fields"); op.add(Builder::searchAfter, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "search_after"); op.add(Builder::seqNoPrimaryTerm, JsonpDeserializer.booleanDeserializer(), "seq_no_primary_term"); op.add(Builder::size, JsonpDeserializer.integerDeserializer(), "size"); op.add(Builder::slice, SlicedScroll._DESERIALIZER, "slice"); op.add(Builder::sort, JsonpDeserializer.arrayDeserializer(SortOptions._DESERIALIZER), "sort"); op.add(Builder::stats, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "stats"); op.add(Builder::storedFields, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "stored_fields"); op.add(Builder::suggest, Suggester._DESERIALIZER, "suggest"); op.add(Builder::terminateAfter, JsonpDeserializer.longDeserializer(), "terminate_after"); op.add(Builder::timeout, JsonpDeserializer.stringDeserializer(), "timeout"); op.add(Builder::trackScores, JsonpDeserializer.booleanDeserializer(), "track_scores"); op.add(Builder::trackTotalHits, TrackHits._DESERIALIZER, "track_total_hits"); op.add(Builder::version, JsonpDeserializer.booleanDeserializer(), "version"); } // --------------------------------------------------------------------------------------------- /** * Endpoint "{@code async_search.submit}". */ public static final SimpleEndpoint _ENDPOINT = new SimpleEndpoint<>("es/async_search.submit", // Request method request -> { return "POST"; }, // Request path request -> { final int _index = 1 << 0; int propsSet = 0; if (ApiTypeHelper.isDefined(request.index())) propsSet |= _index; if (propsSet == 0) { StringBuilder buf = new StringBuilder(); buf.append("/_async_search"); return buf.toString(); } if (propsSet == (_index)) { StringBuilder buf = new StringBuilder(); buf.append("/"); SimpleEndpoint.pathEncode(request.index.stream().map(v -> v).collect(Collectors.joining(",")), buf); buf.append("/_async_search"); return buf.toString(); } throw SimpleEndpoint.noPathTemplateFound("path"); }, // Request parameters request -> { Map params = new HashMap<>(); params.put("typed_keys", "true"); if (request.df != null) { params.put("df", request.df); } if (request.preFilterShardSize != null) { params.put("pre_filter_shard_size", String.valueOf(request.preFilterShardSize)); } if (request.minCompatibleShardNode != null) { params.put("min_compatible_shard_node", request.minCompatibleShardNode); } if (request.lenient != null) { params.put("lenient", String.valueOf(request.lenient)); } if (request.routing != null) { params.put("routing", request.routing); } if (request.ignoreUnavailable != null) { params.put("ignore_unavailable", String.valueOf(request.ignoreUnavailable)); } if (request.allowNoIndices != null) { params.put("allow_no_indices", String.valueOf(request.allowNoIndices)); } if (request.analyzer != null) { params.put("analyzer", request.analyzer); } if (request.ignoreThrottled != null) { params.put("ignore_throttled", String.valueOf(request.ignoreThrottled)); } if (request.keepOnCompletion != null) { params.put("keep_on_completion", String.valueOf(request.keepOnCompletion)); } if (request.maxConcurrentShardRequests != null) { params.put("max_concurrent_shard_requests", String.valueOf(request.maxConcurrentShardRequests)); } if (request.allowPartialSearchResults != null) { params.put("allow_partial_search_results", String.valueOf(request.allowPartialSearchResults)); } if (ApiTypeHelper.isDefined(request.expandWildcards)) { params.put("expand_wildcards", request.expandWildcards.stream().map(v -> v.jsonValue()).collect(Collectors.joining(","))); } if (request.preference != null) { params.put("preference", request.preference); } if (request.analyzeWildcard != null) { params.put("analyze_wildcard", String.valueOf(request.analyzeWildcard)); } if (request.scroll != null) { params.put("scroll", request.scroll._toJsonString()); } if (request.waitForCompletionTimeout != null) { params.put("wait_for_completion_timeout", request.waitForCompletionTimeout._toJsonString()); } if (request.searchType != null) { params.put("search_type", request.searchType.jsonValue()); } if (request.ccsMinimizeRoundtrips != null) { params.put("ccs_minimize_roundtrips", String.valueOf(request.ccsMinimizeRoundtrips)); } if (request.q != null) { params.put("q", request.q); } if (request.defaultOperator != null) { params.put("default_operator", request.defaultOperator.jsonValue()); } if (request.keepAlive != null) { params.put("keep_alive", request.keepAlive._toJsonString()); } if (request.requestCache != null) { params.put("request_cache", String.valueOf(request.requestCache)); } if (request.batchedReduceSize != null) { params.put("batched_reduce_size", String.valueOf(request.batchedReduceSize)); } return params; }, SimpleEndpoint.emptyMap(), true, SubmitResponse._DESERIALIZER); /** * Create an "{@code async_search.submit}" endpoint. */ public static Endpoint, ErrorResponse> createSubmitEndpoint( JsonpDeserializer tDocumentDeserializer) { return _ENDPOINT .withResponseDeserializer(SubmitResponse.createSubmitResponseDeserializer(tDocumentDeserializer)); } }
* API name: {@code indices_boost} */ public final List> indicesBoost() { return this.indicesBoost; } /** * Update the time interval in which the results (partial or final) for this * search will be available * * API name: {@code keep_alive} */ @Nullable public final Time keepAlive() { return this.keepAlive; } /** * Control whether the response should be stored in the cluster if it completed * within the provided [wait_for_completion] time (default: false) * * API name: {@code keep_on_completion} */ @Nullable public final Boolean keepOnCompletion() { return this.keepOnCompletion; } /** * Specify whether format-based query failures (such as providing text to a * numeric field) should be ignored * * API name: {@code lenient} */ @Nullable public final Boolean lenient() { return this.lenient; } /** * The number of concurrent shard requests per node this search executes * concurrently. This value should be used to limit the impact of the search on * the cluster in order to limit the number of concurrent shard requests * * API name: {@code max_concurrent_shard_requests} */ @Nullable public final Long maxConcurrentShardRequests() { return this.maxConcurrentShardRequests; } /** * API name: {@code min_compatible_shard_node} */ @Nullable public final String minCompatibleShardNode() { return this.minCompatibleShardNode; } /** * Minimum _score for matching documents. Documents with a lower _score are not * included in the search results. * * API name: {@code min_score} */ @Nullable public final Double minScore() { return this.minScore; } /** * Limits the search to a point in time (PIT). If you provide a PIT, you cannot * specify an <index> in the request path. * * API name: {@code pit} */ @Nullable public final PointInTimeReference pit() { return this.pit; } /** * API name: {@code post_filter} */ @Nullable public final Query postFilter() { return this.postFilter; } /** * API name: {@code pre_filter_shard_size} */ @Nullable public final Long preFilterShardSize() { return this.preFilterShardSize; } /** * Specify the node or shard the operation should be performed on (default: * random) * * API name: {@code preference} */ @Nullable public final String preference() { return this.preference; } /** * API name: {@code profile} */ @Nullable public final Boolean profile() { return this.profile; } /** * Query in the Lucene query string syntax * * API name: {@code q} */ @Nullable public final String q() { return this.q; } /** * Defines the search definition using the Query DSL. * * API name: {@code query} */ @Nullable public final Query query() { return this.query; } /** * Specify if request cache should be used for this request or not, defaults to * true * * API name: {@code request_cache} */ @Nullable public final Boolean requestCache() { return this.requestCache; } /** * API name: {@code rescore} */ public final List rescore() { return this.rescore; } /** * A comma-separated list of specific routing values * * API name: {@code routing} */ @Nullable public final String routing() { return this.routing; } /** * Defines one or more runtime fields in the search request. These fields take * precedence over mapped fields with the same name. * * API name: {@code runtime_mappings} */ public final Map> runtimeMappings() { return this.runtimeMappings; } /** * Retrieve a script evaluation (based on different fields) for each hit. * * API name: {@code script_fields} */ public final Map scriptFields() { return this.scriptFields; } /** * API name: {@code scroll} */ @Nullable public final Time scroll() { return this.scroll; } /** * API name: {@code search_after} */ public final List searchAfter() { return this.searchAfter; } /** * Search operation type * * API name: {@code search_type} */ @Nullable public final SearchType searchType() { return this.searchType; } /** * If true, returns sequence number and primary term of the last modification of * each hit. See Optimistic concurrency control. * * API name: {@code seq_no_primary_term} */ @Nullable public final Boolean seqNoPrimaryTerm() { return this.seqNoPrimaryTerm; } /** * The number of hits to return. By default, you cannot page through more than * 10,000 hits using the from and size parameters. To page through more hits, * use the search_after parameter. * * API name: {@code size} */ @Nullable public final Integer size() { return this.size; } /** * API name: {@code slice} */ @Nullable public final SlicedScroll slice() { return this.slice; } /** * API name: {@code sort} */ public final List sort() { return this.sort; } /** * Stats groups to associate with the search. Each group maintains a statistics * aggregation for its associated searches. You can retrieve these stats using * the indices stats API. * * API name: {@code stats} */ public final List stats() { return this.stats; } /** * List of stored fields to return as part of a hit. If no fields are specified, * no stored fields are included in the response. If this field is specified, * the _source parameter defaults to false. You can pass _source: true to return * both source fields and stored fields in the search response. * * API name: {@code stored_fields} */ public final List storedFields() { return this.storedFields; } /** * API name: {@code suggest} */ @Nullable public final Suggester suggest() { return this.suggest; } /** * Maximum number of documents to collect for each shard. If a query reaches * this limit, Elasticsearch terminates the query early. Elasticsearch collects * documents before sorting. Defaults to 0, which does not terminate query * execution early. * * API name: {@code terminate_after} */ @Nullable public final Long terminateAfter() { return this.terminateAfter; } /** * Specifies the period of time to wait for a response from each shard. If no * response is received before the timeout expires, the request fails and * returns an error. Defaults to no timeout. * * API name: {@code timeout} */ @Nullable public final String timeout() { return this.timeout; } /** * If true, calculate and return document scores, even if the scores are not * used for sorting. * * API name: {@code track_scores} */ @Nullable public final Boolean trackScores() { return this.trackScores; } /** * Number of hits matching the query to count accurately. If true, the exact * number of hits is returned at the cost of some performance. If false, the * response does not include the total number of hits matching the query. * Defaults to 10,000 hits. * * API name: {@code track_total_hits} */ @Nullable public final TrackHits trackTotalHits() { return this.trackTotalHits; } /** * If true, returns document version as part of a hit. * * API name: {@code version} */ @Nullable public final Boolean version() { return this.version; } /** * Specify the time that the request should block waiting for the final response * * API name: {@code wait_for_completion_timeout} */ @Nullable public final Time waitForCompletionTimeout() { return this.waitForCompletionTimeout; } /** * 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.source != null) { generator.writeKey("_source"); this.source.serialize(generator, mapper); } if (ApiTypeHelper.isDefined(this.aggregations)) { generator.writeKey("aggregations"); generator.writeStartObject(); for (Map.Entry item0 : this.aggregations.entrySet()) { generator.writeKey(item0.getKey()); item0.getValue().serialize(generator, mapper); } generator.writeEnd(); } if (this.collapse != null) { generator.writeKey("collapse"); this.collapse.serialize(generator, mapper); } if (ApiTypeHelper.isDefined(this.docvalueFields)) { generator.writeKey("docvalue_fields"); generator.writeStartArray(); for (FieldAndFormat item0 : this.docvalueFields) { item0.serialize(generator, mapper); } generator.writeEnd(); } if (this.explain != null) { generator.writeKey("explain"); generator.write(this.explain); } if (ApiTypeHelper.isDefined(this.fields)) { generator.writeKey("fields"); generator.writeStartArray(); for (FieldAndFormat item0 : this.fields) { item0.serialize(generator, mapper); } generator.writeEnd(); } if (this.from != null) { generator.writeKey("from"); generator.write(this.from); } if (this.highlight != null) { generator.writeKey("highlight"); this.highlight.serialize(generator, mapper); } if (ApiTypeHelper.isDefined(this.indicesBoost)) { generator.writeKey("indices_boost"); generator.writeStartArray(); for (Map item0 : this.indicesBoost) { generator.writeStartObject(); if (item0 != null) { for (Map.Entry item1 : item0.entrySet()) { generator.writeKey(item1.getKey()); generator.write(item1.getValue()); } } generator.writeEnd(); } generator.writeEnd(); } if (this.minScore != null) { generator.writeKey("min_score"); generator.write(this.minScore); } if (this.pit != null) { generator.writeKey("pit"); this.pit.serialize(generator, mapper); } if (this.postFilter != null) { generator.writeKey("post_filter"); this.postFilter.serialize(generator, mapper); } if (this.profile != null) { generator.writeKey("profile"); generator.write(this.profile); } if (this.query != null) { generator.writeKey("query"); this.query.serialize(generator, mapper); } if (ApiTypeHelper.isDefined(this.rescore)) { generator.writeKey("rescore"); generator.writeStartArray(); for (Rescore item0 : this.rescore) { item0.serialize(generator, mapper); } generator.writeEnd(); } if (ApiTypeHelper.isDefined(this.runtimeMappings)) { generator.writeKey("runtime_mappings"); generator.writeStartObject(); for (Map.Entry> item0 : this.runtimeMappings.entrySet()) { generator.writeKey(item0.getKey()); generator.writeStartArray(); if (item0.getValue() != null) { for (RuntimeField item1 : item0.getValue()) { item1.serialize(generator, mapper); } } generator.writeEnd(); } generator.writeEnd(); } if (ApiTypeHelper.isDefined(this.scriptFields)) { generator.writeKey("script_fields"); generator.writeStartObject(); for (Map.Entry item0 : this.scriptFields.entrySet()) { generator.writeKey(item0.getKey()); item0.getValue().serialize(generator, mapper); } generator.writeEnd(); } if (ApiTypeHelper.isDefined(this.searchAfter)) { generator.writeKey("search_after"); generator.writeStartArray(); for (String item0 : this.searchAfter) { generator.write(item0); } generator.writeEnd(); } if (this.seqNoPrimaryTerm != null) { generator.writeKey("seq_no_primary_term"); generator.write(this.seqNoPrimaryTerm); } if (this.size != null) { generator.writeKey("size"); generator.write(this.size); } if (this.slice != null) { generator.writeKey("slice"); this.slice.serialize(generator, mapper); } if (ApiTypeHelper.isDefined(this.sort)) { generator.writeKey("sort"); generator.writeStartArray(); for (SortOptions item0 : this.sort) { item0.serialize(generator, mapper); } generator.writeEnd(); } if (ApiTypeHelper.isDefined(this.stats)) { generator.writeKey("stats"); generator.writeStartArray(); for (String item0 : this.stats) { generator.write(item0); } generator.writeEnd(); } if (ApiTypeHelper.isDefined(this.storedFields)) { generator.writeKey("stored_fields"); generator.writeStartArray(); for (String item0 : this.storedFields) { generator.write(item0); } generator.writeEnd(); } if (this.suggest != null) { generator.writeKey("suggest"); this.suggest.serialize(generator, mapper); } if (this.terminateAfter != null) { generator.writeKey("terminate_after"); generator.write(this.terminateAfter); } if (this.timeout != null) { generator.writeKey("timeout"); generator.write(this.timeout); } if (this.trackScores != null) { generator.writeKey("track_scores"); generator.write(this.trackScores); } if (this.trackTotalHits != null) { generator.writeKey("track_total_hits"); this.trackTotalHits.serialize(generator, mapper); } if (this.version != null) { generator.writeKey("version"); generator.write(this.version); } } // --------------------------------------------------------------------------------------------- /** * Builder for {@link SubmitRequest}. */ public static class Builder extends WithJsonObjectBuilderBase implements ObjectBuilder { @Nullable private SourceConfig source; @Nullable private Map aggregations; @Nullable private Boolean allowNoIndices; @Nullable private Boolean allowPartialSearchResults; @Nullable private Boolean analyzeWildcard; @Nullable private String analyzer; @Nullable private Long batchedReduceSize; @Nullable private Boolean ccsMinimizeRoundtrips; @Nullable private FieldCollapse collapse; @Nullable private Operator defaultOperator; @Nullable private String df; @Nullable private List docvalueFields; @Nullable private List expandWildcards; @Nullable private Boolean explain; @Nullable private List fields; @Nullable private Integer from; @Nullable private Highlight highlight; @Nullable private Boolean ignoreThrottled; @Nullable private Boolean ignoreUnavailable; @Nullable private List index; @Nullable private List> indicesBoost; @Nullable private Time keepAlive; @Nullable private Boolean keepOnCompletion; @Nullable private Boolean lenient; @Nullable private Long maxConcurrentShardRequests; @Nullable private String minCompatibleShardNode; @Nullable private Double minScore; @Nullable private PointInTimeReference pit; @Nullable private Query postFilter; @Nullable private Long preFilterShardSize; @Nullable private String preference; @Nullable private Boolean profile; @Nullable private String q; @Nullable private Query query; @Nullable private Boolean requestCache; @Nullable private List rescore; @Nullable private String routing; @Nullable private Map> runtimeMappings; @Nullable private Map scriptFields; @Nullable private Time scroll; @Nullable private List searchAfter; @Nullable private SearchType searchType; @Nullable private Boolean seqNoPrimaryTerm; @Nullable private Integer size; @Nullable private SlicedScroll slice; @Nullable private List sort; @Nullable private List stats; @Nullable private List storedFields; @Nullable private Suggester suggest; @Nullable private Long terminateAfter; @Nullable private String timeout; @Nullable private Boolean trackScores; @Nullable private TrackHits trackTotalHits; @Nullable private Boolean version; @Nullable private Time waitForCompletionTimeout; /** * Indicates which source fields are returned for matching documents. These * fields are returned in the hits._source property of the search response. * * API name: {@code _source} */ public final Builder source(@Nullable SourceConfig value) { this.source = value; return this; } /** * Indicates which source fields are returned for matching documents. These * fields are returned in the hits._source property of the search response. * * API name: {@code _source} */ public final Builder source(Function> fn) { return this.source(fn.apply(new SourceConfig.Builder()).build()); } /** * API name: {@code aggregations} * * Adds all entries of map to aggregations. */ public final Builder aggregations(Map map) { this.aggregations = _mapPutAll(this.aggregations, map); return this; } /** * API name: {@code aggregations} * * Adds an entry to aggregations. */ public final Builder aggregations(String key, Aggregation value) { this.aggregations = _mapPut(this.aggregations, key, value); return this; } /** * API name: {@code aggregations} * * Adds an entry to aggregations using a builder lambda. */ public final Builder aggregations(String key, Function> fn) { return aggregations(key, fn.apply(new Aggregation.Builder()).build()); } /** * Whether to ignore if a wildcard indices expression resolves into no concrete * indices. (This includes _all string or when no indices have been * specified) * * API name: {@code allow_no_indices} */ public final Builder allowNoIndices(@Nullable Boolean value) { this.allowNoIndices = value; return this; } /** * Indicate if an error should be returned if there is a partial search failure * or timeout * * API name: {@code allow_partial_search_results} */ public final Builder allowPartialSearchResults(@Nullable Boolean value) { this.allowPartialSearchResults = value; return this; } /** * Specify whether wildcard and prefix queries should be analyzed (default: * false) * * API name: {@code analyze_wildcard} */ public final Builder analyzeWildcard(@Nullable Boolean value) { this.analyzeWildcard = value; return this; } /** * The analyzer to use for the query string * * API name: {@code analyzer} */ public final Builder analyzer(@Nullable String value) { this.analyzer = value; return this; } /** * The number of shard results that should be reduced at once on the * coordinating node. This value should be used as the granularity at which * progress results will be made available. * * API name: {@code batched_reduce_size} */ public final Builder batchedReduceSize(@Nullable Long value) { this.batchedReduceSize = value; return this; } /** * API name: {@code ccs_minimize_roundtrips} */ public final Builder ccsMinimizeRoundtrips(@Nullable Boolean value) { this.ccsMinimizeRoundtrips = value; return this; } /** * API name: {@code collapse} */ public final Builder collapse(@Nullable FieldCollapse value) { this.collapse = value; return this; } /** * API name: {@code collapse} */ public final Builder collapse(Function> fn) { return this.collapse(fn.apply(new FieldCollapse.Builder()).build()); } /** * The default operator for query string query (AND or OR) * * API name: {@code default_operator} */ public final Builder defaultOperator(@Nullable Operator value) { this.defaultOperator = value; return this; } /** * The field to use as default where no field prefix is given in the query * string * * API name: {@code df} */ public final Builder df(@Nullable String value) { this.df = value; return this; } /** * Array of wildcard (*) patterns. The request returns doc values for field * names matching these patterns in the hits.fields property of the response. * * API name: {@code docvalue_fields} * * Adds all elements of list to docvalueFields. */ public final Builder docvalueFields(List list) { this.docvalueFields = _listAddAll(this.docvalueFields, list); return this; } /** * Array of wildcard (*) patterns. The request returns doc values for field * names matching these patterns in the hits.fields property of the response. * * API name: {@code docvalue_fields} * * Adds one or more values to docvalueFields. */ public final Builder docvalueFields(FieldAndFormat value, FieldAndFormat... values) { this.docvalueFields = _listAdd(this.docvalueFields, value, values); return this; } /** * Array of wildcard (*) patterns. The request returns doc values for field * names matching these patterns in the hits.fields property of the response. * * API name: {@code docvalue_fields} * * Adds a value to docvalueFields using a builder lambda. */ public final Builder docvalueFields(Function> fn) { return docvalueFields(fn.apply(new FieldAndFormat.Builder()).build()); } /** * Whether to expand wildcard expression to concrete indices that are open, * closed or both. * * API name: {@code expand_wildcards} * * Adds all elements of list to expandWildcards. */ public final Builder expandWildcards(List list) { this.expandWildcards = _listAddAll(this.expandWildcards, list); return this; } /** * Whether to expand wildcard expression to concrete indices that are open, * closed or both. * * API name: {@code expand_wildcards} * * Adds one or more values to expandWildcards. */ public final Builder expandWildcards(ExpandWildcard value, ExpandWildcard... values) { this.expandWildcards = _listAdd(this.expandWildcards, value, values); return this; } /** * If true, returns detailed information about score computation as part of a * hit. * * API name: {@code explain} */ public final Builder explain(@Nullable Boolean value) { this.explain = value; return this; } /** * Array of wildcard (*) patterns. The request returns values for field names * matching these patterns in the hits.fields property of the response. * * API name: {@code fields} * * Adds all elements of list to fields. */ public final Builder fields(List list) { this.fields = _listAddAll(this.fields, list); return this; } /** * Array of wildcard (*) patterns. The request returns values for field names * matching these patterns in the hits.fields property of the response. * * API name: {@code fields} * * Adds one or more values to fields. */ public final Builder fields(FieldAndFormat value, FieldAndFormat... values) { this.fields = _listAdd(this.fields, value, values); return this; } /** * Array of wildcard (*) patterns. The request returns values for field names * matching these patterns in the hits.fields property of the response. * * API name: {@code fields} * * Adds a value to fields using a builder lambda. */ public final Builder fields(Function> fn) { return fields(fn.apply(new FieldAndFormat.Builder()).build()); } /** * Starting document offset. By default, you cannot page through more than * 10,000 hits using the from and size parameters. To page through more hits, * use the search_after parameter. * * API name: {@code from} */ public final Builder from(@Nullable Integer value) { this.from = value; return this; } /** * API name: {@code highlight} */ public final Builder highlight(@Nullable Highlight value) { this.highlight = value; return this; } /** * API name: {@code highlight} */ public final Builder highlight(Function> fn) { return this.highlight(fn.apply(new Highlight.Builder()).build()); } /** * Whether specified concrete, expanded or aliased indices should be ignored * when throttled * * API name: {@code ignore_throttled} */ public final Builder ignoreThrottled(@Nullable Boolean value) { this.ignoreThrottled = value; return this; } /** * Whether specified concrete indices should be ignored when unavailable * (missing or closed) * * API name: {@code ignore_unavailable} */ public final Builder ignoreUnavailable(@Nullable Boolean value) { this.ignoreUnavailable = value; return this; } /** * A comma-separated list of index names to search; use _all or * empty string to perform the operation on all indices * * API name: {@code index} * * Adds all elements of list to index. */ public final Builder index(List list) { this.index = _listAddAll(this.index, list); return this; } /** * A comma-separated list of index names to search; use _all or * empty string to perform the operation on all indices * * API name: {@code index} * * Adds one or more values to index. */ public final Builder index(String value, String... values) { this.index = _listAdd(this.index, value, values); return this; } /** * Boosts the _score of documents from specified indices. * * API name: {@code indices_boost} * * Adds all elements of list to indicesBoost. */ public final Builder indicesBoost(List> list) { this.indicesBoost = _listAddAll(this.indicesBoost, list); return this; } /** * Boosts the _score of documents from specified indices. * * API name: {@code indices_boost} * * Adds one or more values to indicesBoost. */ public final Builder indicesBoost(Map value, Map... values) { this.indicesBoost = _listAdd(this.indicesBoost, value, values); return this; } /** * Update the time interval in which the results (partial or final) for this * search will be available * * API name: {@code keep_alive} */ public final Builder keepAlive(@Nullable Time value) { this.keepAlive = value; return this; } /** * Update the time interval in which the results (partial or final) for this * search will be available * * API name: {@code keep_alive} */ public final Builder keepAlive(Function> fn) { return this.keepAlive(fn.apply(new Time.Builder()).build()); } /** * Control whether the response should be stored in the cluster if it completed * within the provided [wait_for_completion] time (default: false) * * API name: {@code keep_on_completion} */ public final Builder keepOnCompletion(@Nullable Boolean value) { this.keepOnCompletion = value; return this; } /** * Specify whether format-based query failures (such as providing text to a * numeric field) should be ignored * * API name: {@code lenient} */ public final Builder lenient(@Nullable Boolean value) { this.lenient = value; return this; } /** * The number of concurrent shard requests per node this search executes * concurrently. This value should be used to limit the impact of the search on * the cluster in order to limit the number of concurrent shard requests * * API name: {@code max_concurrent_shard_requests} */ public final Builder maxConcurrentShardRequests(@Nullable Long value) { this.maxConcurrentShardRequests = value; return this; } /** * API name: {@code min_compatible_shard_node} */ public final Builder minCompatibleShardNode(@Nullable String value) { this.minCompatibleShardNode = value; return this; } /** * Minimum _score for matching documents. Documents with a lower _score are not * included in the search results. * * API name: {@code min_score} */ public final Builder minScore(@Nullable Double value) { this.minScore = value; return this; } /** * Limits the search to a point in time (PIT). If you provide a PIT, you cannot * specify an <index> in the request path. * * API name: {@code pit} */ public final Builder pit(@Nullable PointInTimeReference value) { this.pit = value; return this; } /** * Limits the search to a point in time (PIT). If you provide a PIT, you cannot * specify an <index> in the request path. * * API name: {@code pit} */ public final Builder pit(Function> fn) { return this.pit(fn.apply(new PointInTimeReference.Builder()).build()); } /** * API name: {@code post_filter} */ public final Builder postFilter(@Nullable Query value) { this.postFilter = value; return this; } /** * API name: {@code post_filter} */ public final Builder postFilter(Function> fn) { return this.postFilter(fn.apply(new Query.Builder()).build()); } /** * API name: {@code pre_filter_shard_size} */ public final Builder preFilterShardSize(@Nullable Long value) { this.preFilterShardSize = value; return this; } /** * Specify the node or shard the operation should be performed on (default: * random) * * API name: {@code preference} */ public final Builder preference(@Nullable String value) { this.preference = value; return this; } /** * API name: {@code profile} */ public final Builder profile(@Nullable Boolean value) { this.profile = value; return this; } /** * Query in the Lucene query string syntax * * API name: {@code q} */ public final Builder q(@Nullable String value) { this.q = value; return this; } /** * Defines the search definition using the Query DSL. * * API name: {@code query} */ public final Builder query(@Nullable Query value) { this.query = value; return this; } /** * Defines the search definition using the Query DSL. * * API name: {@code query} */ public final Builder query(Function> fn) { return this.query(fn.apply(new Query.Builder()).build()); } /** * Specify if request cache should be used for this request or not, defaults to * true * * API name: {@code request_cache} */ public final Builder requestCache(@Nullable Boolean value) { this.requestCache = value; return this; } /** * API name: {@code rescore} * * Adds all elements of list to rescore. */ public final Builder rescore(List list) { this.rescore = _listAddAll(this.rescore, list); return this; } /** * API name: {@code rescore} * * Adds one or more values to rescore. */ public final Builder rescore(Rescore value, Rescore... values) { this.rescore = _listAdd(this.rescore, value, values); return this; } /** * API name: {@code rescore} * * Adds a value to rescore using a builder lambda. */ public final Builder rescore(Function> fn) { return rescore(fn.apply(new Rescore.Builder()).build()); } /** * A comma-separated list of specific routing values * * API name: {@code routing} */ public final Builder routing(@Nullable String value) { this.routing = value; return this; } /** * Defines one or more runtime fields in the search request. These fields take * precedence over mapped fields with the same name. * * API name: {@code runtime_mappings} * * Adds all entries of map to runtimeMappings. */ public final Builder runtimeMappings(Map> map) { this.runtimeMappings = _mapPutAll(this.runtimeMappings, map); return this; } /** * Defines one or more runtime fields in the search request. These fields take * precedence over mapped fields with the same name. * * API name: {@code runtime_mappings} * * Adds an entry to runtimeMappings. */ public final Builder runtimeMappings(String key, List value) { this.runtimeMappings = _mapPut(this.runtimeMappings, key, value); return this; } /** * Retrieve a script evaluation (based on different fields) for each hit. * * API name: {@code script_fields} * * Adds all entries of map to scriptFields. */ public final Builder scriptFields(Map map) { this.scriptFields = _mapPutAll(this.scriptFields, map); return this; } /** * Retrieve a script evaluation (based on different fields) for each hit. * * API name: {@code script_fields} * * Adds an entry to scriptFields. */ public final Builder scriptFields(String key, ScriptField value) { this.scriptFields = _mapPut(this.scriptFields, key, value); return this; } /** * Retrieve a script evaluation (based on different fields) for each hit. * * API name: {@code script_fields} * * Adds an entry to scriptFields using a builder lambda. */ public final Builder scriptFields(String key, Function> fn) { return scriptFields(key, fn.apply(new ScriptField.Builder()).build()); } /** * API name: {@code scroll} */ public final Builder scroll(@Nullable Time value) { this.scroll = value; return this; } /** * API name: {@code scroll} */ public final Builder scroll(Function> fn) { return this.scroll(fn.apply(new Time.Builder()).build()); } /** * API name: {@code search_after} * * Adds all elements of list to searchAfter. */ public final Builder searchAfter(List list) { this.searchAfter = _listAddAll(this.searchAfter, list); return this; } /** * API name: {@code search_after} * * Adds one or more values to searchAfter. */ public final Builder searchAfter(String value, String... values) { this.searchAfter = _listAdd(this.searchAfter, value, values); return this; } /** * Search operation type * * API name: {@code search_type} */ public final Builder searchType(@Nullable SearchType value) { this.searchType = value; return this; } /** * If true, returns sequence number and primary term of the last modification of * each hit. See Optimistic concurrency control. * * API name: {@code seq_no_primary_term} */ public final Builder seqNoPrimaryTerm(@Nullable Boolean value) { this.seqNoPrimaryTerm = value; return this; } /** * The number of hits to return. By default, you cannot page through more than * 10,000 hits using the from and size parameters. To page through more hits, * use the search_after parameter. * * API name: {@code size} */ public final Builder size(@Nullable Integer value) { this.size = value; return this; } /** * API name: {@code slice} */ public final Builder slice(@Nullable SlicedScroll value) { this.slice = value; return this; } /** * API name: {@code slice} */ public final Builder slice(Function> fn) { return this.slice(fn.apply(new SlicedScroll.Builder()).build()); } /** * API name: {@code sort} * * Adds all elements of list to sort. */ public final Builder sort(List list) { this.sort = _listAddAll(this.sort, list); return this; } /** * API name: {@code sort} * * Adds one or more values to sort. */ public final Builder sort(SortOptions value, SortOptions... values) { this.sort = _listAdd(this.sort, value, values); return this; } /** * API name: {@code sort} * * Adds a value to sort using a builder lambda. */ public final Builder sort(Function> fn) { return sort(fn.apply(new SortOptions.Builder()).build()); } /** * Stats groups to associate with the search. Each group maintains a statistics * aggregation for its associated searches. You can retrieve these stats using * the indices stats API. * * API name: {@code stats} * * Adds all elements of list to stats. */ public final Builder stats(List list) { this.stats = _listAddAll(this.stats, list); return this; } /** * Stats groups to associate with the search. Each group maintains a statistics * aggregation for its associated searches. You can retrieve these stats using * the indices stats API. * * API name: {@code stats} * * Adds one or more values to stats. */ public final Builder stats(String value, String... values) { this.stats = _listAdd(this.stats, value, values); return this; } /** * List of stored fields to return as part of a hit. If no fields are specified, * no stored fields are included in the response. If this field is specified, * the _source parameter defaults to false. You can pass _source: true to return * both source fields and stored fields in the search response. * * API name: {@code stored_fields} * * Adds all elements of list to storedFields. */ public final Builder storedFields(List list) { this.storedFields = _listAddAll(this.storedFields, list); return this; } /** * List of stored fields to return as part of a hit. If no fields are specified, * no stored fields are included in the response. If this field is specified, * the _source parameter defaults to false. You can pass _source: true to return * both source fields and stored fields in the search response. * * API name: {@code stored_fields} * * Adds one or more values to storedFields. */ public final Builder storedFields(String value, String... values) { this.storedFields = _listAdd(this.storedFields, value, values); return this; } /** * API name: {@code suggest} */ public final Builder suggest(@Nullable Suggester value) { this.suggest = value; return this; } /** * API name: {@code suggest} */ public final Builder suggest(Function> fn) { return this.suggest(fn.apply(new Suggester.Builder()).build()); } /** * Maximum number of documents to collect for each shard. If a query reaches * this limit, Elasticsearch terminates the query early. Elasticsearch collects * documents before sorting. Defaults to 0, which does not terminate query * execution early. * * API name: {@code terminate_after} */ public final Builder terminateAfter(@Nullable Long value) { this.terminateAfter = value; return this; } /** * Specifies the period of time to wait for a response from each shard. If no * response is received before the timeout expires, the request fails and * returns an error. Defaults to no timeout. * * API name: {@code timeout} */ public final Builder timeout(@Nullable String value) { this.timeout = value; return this; } /** * If true, calculate and return document scores, even if the scores are not * used for sorting. * * API name: {@code track_scores} */ public final Builder trackScores(@Nullable Boolean value) { this.trackScores = value; return this; } /** * Number of hits matching the query to count accurately. If true, the exact * number of hits is returned at the cost of some performance. If false, the * response does not include the total number of hits matching the query. * Defaults to 10,000 hits. * * API name: {@code track_total_hits} */ public final Builder trackTotalHits(@Nullable TrackHits value) { this.trackTotalHits = value; return this; } /** * Number of hits matching the query to count accurately. If true, the exact * number of hits is returned at the cost of some performance. If false, the * response does not include the total number of hits matching the query. * Defaults to 10,000 hits. * * API name: {@code track_total_hits} */ public final Builder trackTotalHits(Function> fn) { return this.trackTotalHits(fn.apply(new TrackHits.Builder()).build()); } /** * If true, returns document version as part of a hit. * * API name: {@code version} */ public final Builder version(@Nullable Boolean value) { this.version = value; return this; } /** * Specify the time that the request should block waiting for the final response * * API name: {@code wait_for_completion_timeout} */ public final Builder waitForCompletionTimeout(@Nullable Time value) { this.waitForCompletionTimeout = value; return this; } /** * Specify the time that the request should block waiting for the final response * * API name: {@code wait_for_completion_timeout} */ public final Builder waitForCompletionTimeout(Function> fn) { return this.waitForCompletionTimeout(fn.apply(new Time.Builder()).build()); } @Override protected Builder self() { return this; } /** * Builds a {@link SubmitRequest}. * * @throws NullPointerException * if some of the required fields are null. */ public SubmitRequest build() { _checkSingleUse(); return new SubmitRequest(this); } } // --------------------------------------------------------------------------------------------- /** * Json deserializer for {@link SubmitRequest} */ public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy(Builder::new, SubmitRequest::setupSubmitRequestDeserializer); protected static void setupSubmitRequestDeserializer(ObjectDeserializer op) { op.add(Builder::source, SourceConfig._DESERIALIZER, "_source"); op.add(Builder::aggregations, JsonpDeserializer.stringMapDeserializer(Aggregation._DESERIALIZER), "aggregations", "aggs"); op.add(Builder::collapse, FieldCollapse._DESERIALIZER, "collapse"); op.add(Builder::docvalueFields, JsonpDeserializer.arrayDeserializer(FieldAndFormat._DESERIALIZER), "docvalue_fields"); op.add(Builder::explain, JsonpDeserializer.booleanDeserializer(), "explain"); op.add(Builder::fields, JsonpDeserializer.arrayDeserializer(FieldAndFormat._DESERIALIZER), "fields"); op.add(Builder::from, JsonpDeserializer.integerDeserializer(), "from"); op.add(Builder::highlight, Highlight._DESERIALIZER, "highlight"); op.add(Builder::indicesBoost, JsonpDeserializer.arrayDeserializer( JsonpDeserializer.stringMapDeserializer(JsonpDeserializer.doubleDeserializer())), "indices_boost"); op.add(Builder::minScore, JsonpDeserializer.doubleDeserializer(), "min_score"); op.add(Builder::pit, PointInTimeReference._DESERIALIZER, "pit"); op.add(Builder::postFilter, Query._DESERIALIZER, "post_filter"); op.add(Builder::profile, JsonpDeserializer.booleanDeserializer(), "profile"); op.add(Builder::query, Query._DESERIALIZER, "query"); op.add(Builder::rescore, JsonpDeserializer.arrayDeserializer(Rescore._DESERIALIZER), "rescore"); op.add(Builder::runtimeMappings, JsonpDeserializer.stringMapDeserializer( JsonpDeserializer.arrayDeserializer(RuntimeField._DESERIALIZER)), "runtime_mappings"); op.add(Builder::scriptFields, JsonpDeserializer.stringMapDeserializer(ScriptField._DESERIALIZER), "script_fields"); op.add(Builder::searchAfter, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "search_after"); op.add(Builder::seqNoPrimaryTerm, JsonpDeserializer.booleanDeserializer(), "seq_no_primary_term"); op.add(Builder::size, JsonpDeserializer.integerDeserializer(), "size"); op.add(Builder::slice, SlicedScroll._DESERIALIZER, "slice"); op.add(Builder::sort, JsonpDeserializer.arrayDeserializer(SortOptions._DESERIALIZER), "sort"); op.add(Builder::stats, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "stats"); op.add(Builder::storedFields, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "stored_fields"); op.add(Builder::suggest, Suggester._DESERIALIZER, "suggest"); op.add(Builder::terminateAfter, JsonpDeserializer.longDeserializer(), "terminate_after"); op.add(Builder::timeout, JsonpDeserializer.stringDeserializer(), "timeout"); op.add(Builder::trackScores, JsonpDeserializer.booleanDeserializer(), "track_scores"); op.add(Builder::trackTotalHits, TrackHits._DESERIALIZER, "track_total_hits"); op.add(Builder::version, JsonpDeserializer.booleanDeserializer(), "version"); } // --------------------------------------------------------------------------------------------- /** * Endpoint "{@code async_search.submit}". */ public static final SimpleEndpoint _ENDPOINT = new SimpleEndpoint<>("es/async_search.submit", // Request method request -> { return "POST"; }, // Request path request -> { final int _index = 1 << 0; int propsSet = 0; if (ApiTypeHelper.isDefined(request.index())) propsSet |= _index; if (propsSet == 0) { StringBuilder buf = new StringBuilder(); buf.append("/_async_search"); return buf.toString(); } if (propsSet == (_index)) { StringBuilder buf = new StringBuilder(); buf.append("/"); SimpleEndpoint.pathEncode(request.index.stream().map(v -> v).collect(Collectors.joining(",")), buf); buf.append("/_async_search"); return buf.toString(); } throw SimpleEndpoint.noPathTemplateFound("path"); }, // Request parameters request -> { Map params = new HashMap<>(); params.put("typed_keys", "true"); if (request.df != null) { params.put("df", request.df); } if (request.preFilterShardSize != null) { params.put("pre_filter_shard_size", String.valueOf(request.preFilterShardSize)); } if (request.minCompatibleShardNode != null) { params.put("min_compatible_shard_node", request.minCompatibleShardNode); } if (request.lenient != null) { params.put("lenient", String.valueOf(request.lenient)); } if (request.routing != null) { params.put("routing", request.routing); } if (request.ignoreUnavailable != null) { params.put("ignore_unavailable", String.valueOf(request.ignoreUnavailable)); } if (request.allowNoIndices != null) { params.put("allow_no_indices", String.valueOf(request.allowNoIndices)); } if (request.analyzer != null) { params.put("analyzer", request.analyzer); } if (request.ignoreThrottled != null) { params.put("ignore_throttled", String.valueOf(request.ignoreThrottled)); } if (request.keepOnCompletion != null) { params.put("keep_on_completion", String.valueOf(request.keepOnCompletion)); } if (request.maxConcurrentShardRequests != null) { params.put("max_concurrent_shard_requests", String.valueOf(request.maxConcurrentShardRequests)); } if (request.allowPartialSearchResults != null) { params.put("allow_partial_search_results", String.valueOf(request.allowPartialSearchResults)); } if (ApiTypeHelper.isDefined(request.expandWildcards)) { params.put("expand_wildcards", request.expandWildcards.stream().map(v -> v.jsonValue()).collect(Collectors.joining(","))); } if (request.preference != null) { params.put("preference", request.preference); } if (request.analyzeWildcard != null) { params.put("analyze_wildcard", String.valueOf(request.analyzeWildcard)); } if (request.scroll != null) { params.put("scroll", request.scroll._toJsonString()); } if (request.waitForCompletionTimeout != null) { params.put("wait_for_completion_timeout", request.waitForCompletionTimeout._toJsonString()); } if (request.searchType != null) { params.put("search_type", request.searchType.jsonValue()); } if (request.ccsMinimizeRoundtrips != null) { params.put("ccs_minimize_roundtrips", String.valueOf(request.ccsMinimizeRoundtrips)); } if (request.q != null) { params.put("q", request.q); } if (request.defaultOperator != null) { params.put("default_operator", request.defaultOperator.jsonValue()); } if (request.keepAlive != null) { params.put("keep_alive", request.keepAlive._toJsonString()); } if (request.requestCache != null) { params.put("request_cache", String.valueOf(request.requestCache)); } if (request.batchedReduceSize != null) { params.put("batched_reduce_size", String.valueOf(request.batchedReduceSize)); } return params; }, SimpleEndpoint.emptyMap(), true, SubmitResponse._DESERIALIZER); /** * Create an "{@code async_search.submit}" endpoint. */ public static Endpoint, ErrorResponse> createSubmitEndpoint( JsonpDeserializer tDocumentDeserializer) { return _ENDPOINT .withResponseDeserializer(SubmitResponse.createSubmitResponseDeserializer(tDocumentDeserializer)); } }
* API name: {@code keep_alive} */ @Nullable public final Time keepAlive() { return this.keepAlive; } /** * Control whether the response should be stored in the cluster if it completed * within the provided [wait_for_completion] time (default: false) *
* API name: {@code keep_on_completion} */ @Nullable public final Boolean keepOnCompletion() { return this.keepOnCompletion; } /** * Specify whether format-based query failures (such as providing text to a * numeric field) should be ignored *
* API name: {@code lenient} */ @Nullable public final Boolean lenient() { return this.lenient; } /** * The number of concurrent shard requests per node this search executes * concurrently. This value should be used to limit the impact of the search on * the cluster in order to limit the number of concurrent shard requests *
* API name: {@code max_concurrent_shard_requests} */ @Nullable public final Long maxConcurrentShardRequests() { return this.maxConcurrentShardRequests; } /** * API name: {@code min_compatible_shard_node} */ @Nullable public final String minCompatibleShardNode() { return this.minCompatibleShardNode; } /** * Minimum _score for matching documents. Documents with a lower _score are not * included in the search results. *
* API name: {@code min_score} */ @Nullable public final Double minScore() { return this.minScore; } /** * Limits the search to a point in time (PIT). If you provide a PIT, you cannot * specify an <index> in the request path. *
* API name: {@code pit} */ @Nullable public final PointInTimeReference pit() { return this.pit; } /** * API name: {@code post_filter} */ @Nullable public final Query postFilter() { return this.postFilter; } /** * API name: {@code pre_filter_shard_size} */ @Nullable public final Long preFilterShardSize() { return this.preFilterShardSize; } /** * Specify the node or shard the operation should be performed on (default: * random) *
* API name: {@code preference} */ @Nullable public final String preference() { return this.preference; } /** * API name: {@code profile} */ @Nullable public final Boolean profile() { return this.profile; } /** * Query in the Lucene query string syntax *
* API name: {@code q} */ @Nullable public final String q() { return this.q; } /** * Defines the search definition using the Query DSL. *
* API name: {@code query} */ @Nullable public final Query query() { return this.query; } /** * Specify if request cache should be used for this request or not, defaults to * true *
* API name: {@code request_cache} */ @Nullable public final Boolean requestCache() { return this.requestCache; } /** * API name: {@code rescore} */ public final List rescore() { return this.rescore; } /** * A comma-separated list of specific routing values * * API name: {@code routing} */ @Nullable public final String routing() { return this.routing; } /** * Defines one or more runtime fields in the search request. These fields take * precedence over mapped fields with the same name. * * API name: {@code runtime_mappings} */ public final Map> runtimeMappings() { return this.runtimeMappings; } /** * Retrieve a script evaluation (based on different fields) for each hit. * * API name: {@code script_fields} */ public final Map scriptFields() { return this.scriptFields; } /** * API name: {@code scroll} */ @Nullable public final Time scroll() { return this.scroll; } /** * API name: {@code search_after} */ public final List searchAfter() { return this.searchAfter; } /** * Search operation type * * API name: {@code search_type} */ @Nullable public final SearchType searchType() { return this.searchType; } /** * If true, returns sequence number and primary term of the last modification of * each hit. See Optimistic concurrency control. * * API name: {@code seq_no_primary_term} */ @Nullable public final Boolean seqNoPrimaryTerm() { return this.seqNoPrimaryTerm; } /** * The number of hits to return. By default, you cannot page through more than * 10,000 hits using the from and size parameters. To page through more hits, * use the search_after parameter. * * API name: {@code size} */ @Nullable public final Integer size() { return this.size; } /** * API name: {@code slice} */ @Nullable public final SlicedScroll slice() { return this.slice; } /** * API name: {@code sort} */ public final List sort() { return this.sort; } /** * Stats groups to associate with the search. Each group maintains a statistics * aggregation for its associated searches. You can retrieve these stats using * the indices stats API. * * API name: {@code stats} */ public final List stats() { return this.stats; } /** * List of stored fields to return as part of a hit. If no fields are specified, * no stored fields are included in the response. If this field is specified, * the _source parameter defaults to false. You can pass _source: true to return * both source fields and stored fields in the search response. * * API name: {@code stored_fields} */ public final List storedFields() { return this.storedFields; } /** * API name: {@code suggest} */ @Nullable public final Suggester suggest() { return this.suggest; } /** * Maximum number of documents to collect for each shard. If a query reaches * this limit, Elasticsearch terminates the query early. Elasticsearch collects * documents before sorting. Defaults to 0, which does not terminate query * execution early. * * API name: {@code terminate_after} */ @Nullable public final Long terminateAfter() { return this.terminateAfter; } /** * Specifies the period of time to wait for a response from each shard. If no * response is received before the timeout expires, the request fails and * returns an error. Defaults to no timeout. * * API name: {@code timeout} */ @Nullable public final String timeout() { return this.timeout; } /** * If true, calculate and return document scores, even if the scores are not * used for sorting. * * API name: {@code track_scores} */ @Nullable public final Boolean trackScores() { return this.trackScores; } /** * Number of hits matching the query to count accurately. If true, the exact * number of hits is returned at the cost of some performance. If false, the * response does not include the total number of hits matching the query. * Defaults to 10,000 hits. * * API name: {@code track_total_hits} */ @Nullable public final TrackHits trackTotalHits() { return this.trackTotalHits; } /** * If true, returns document version as part of a hit. * * API name: {@code version} */ @Nullable public final Boolean version() { return this.version; } /** * Specify the time that the request should block waiting for the final response * * API name: {@code wait_for_completion_timeout} */ @Nullable public final Time waitForCompletionTimeout() { return this.waitForCompletionTimeout; } /** * 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.source != null) { generator.writeKey("_source"); this.source.serialize(generator, mapper); } if (ApiTypeHelper.isDefined(this.aggregations)) { generator.writeKey("aggregations"); generator.writeStartObject(); for (Map.Entry item0 : this.aggregations.entrySet()) { generator.writeKey(item0.getKey()); item0.getValue().serialize(generator, mapper); } generator.writeEnd(); } if (this.collapse != null) { generator.writeKey("collapse"); this.collapse.serialize(generator, mapper); } if (ApiTypeHelper.isDefined(this.docvalueFields)) { generator.writeKey("docvalue_fields"); generator.writeStartArray(); for (FieldAndFormat item0 : this.docvalueFields) { item0.serialize(generator, mapper); } generator.writeEnd(); } if (this.explain != null) { generator.writeKey("explain"); generator.write(this.explain); } if (ApiTypeHelper.isDefined(this.fields)) { generator.writeKey("fields"); generator.writeStartArray(); for (FieldAndFormat item0 : this.fields) { item0.serialize(generator, mapper); } generator.writeEnd(); } if (this.from != null) { generator.writeKey("from"); generator.write(this.from); } if (this.highlight != null) { generator.writeKey("highlight"); this.highlight.serialize(generator, mapper); } if (ApiTypeHelper.isDefined(this.indicesBoost)) { generator.writeKey("indices_boost"); generator.writeStartArray(); for (Map item0 : this.indicesBoost) { generator.writeStartObject(); if (item0 != null) { for (Map.Entry item1 : item0.entrySet()) { generator.writeKey(item1.getKey()); generator.write(item1.getValue()); } } generator.writeEnd(); } generator.writeEnd(); } if (this.minScore != null) { generator.writeKey("min_score"); generator.write(this.minScore); } if (this.pit != null) { generator.writeKey("pit"); this.pit.serialize(generator, mapper); } if (this.postFilter != null) { generator.writeKey("post_filter"); this.postFilter.serialize(generator, mapper); } if (this.profile != null) { generator.writeKey("profile"); generator.write(this.profile); } if (this.query != null) { generator.writeKey("query"); this.query.serialize(generator, mapper); } if (ApiTypeHelper.isDefined(this.rescore)) { generator.writeKey("rescore"); generator.writeStartArray(); for (Rescore item0 : this.rescore) { item0.serialize(generator, mapper); } generator.writeEnd(); } if (ApiTypeHelper.isDefined(this.runtimeMappings)) { generator.writeKey("runtime_mappings"); generator.writeStartObject(); for (Map.Entry> item0 : this.runtimeMappings.entrySet()) { generator.writeKey(item0.getKey()); generator.writeStartArray(); if (item0.getValue() != null) { for (RuntimeField item1 : item0.getValue()) { item1.serialize(generator, mapper); } } generator.writeEnd(); } generator.writeEnd(); } if (ApiTypeHelper.isDefined(this.scriptFields)) { generator.writeKey("script_fields"); generator.writeStartObject(); for (Map.Entry item0 : this.scriptFields.entrySet()) { generator.writeKey(item0.getKey()); item0.getValue().serialize(generator, mapper); } generator.writeEnd(); } if (ApiTypeHelper.isDefined(this.searchAfter)) { generator.writeKey("search_after"); generator.writeStartArray(); for (String item0 : this.searchAfter) { generator.write(item0); } generator.writeEnd(); } if (this.seqNoPrimaryTerm != null) { generator.writeKey("seq_no_primary_term"); generator.write(this.seqNoPrimaryTerm); } if (this.size != null) { generator.writeKey("size"); generator.write(this.size); } if (this.slice != null) { generator.writeKey("slice"); this.slice.serialize(generator, mapper); } if (ApiTypeHelper.isDefined(this.sort)) { generator.writeKey("sort"); generator.writeStartArray(); for (SortOptions item0 : this.sort) { item0.serialize(generator, mapper); } generator.writeEnd(); } if (ApiTypeHelper.isDefined(this.stats)) { generator.writeKey("stats"); generator.writeStartArray(); for (String item0 : this.stats) { generator.write(item0); } generator.writeEnd(); } if (ApiTypeHelper.isDefined(this.storedFields)) { generator.writeKey("stored_fields"); generator.writeStartArray(); for (String item0 : this.storedFields) { generator.write(item0); } generator.writeEnd(); } if (this.suggest != null) { generator.writeKey("suggest"); this.suggest.serialize(generator, mapper); } if (this.terminateAfter != null) { generator.writeKey("terminate_after"); generator.write(this.terminateAfter); } if (this.timeout != null) { generator.writeKey("timeout"); generator.write(this.timeout); } if (this.trackScores != null) { generator.writeKey("track_scores"); generator.write(this.trackScores); } if (this.trackTotalHits != null) { generator.writeKey("track_total_hits"); this.trackTotalHits.serialize(generator, mapper); } if (this.version != null) { generator.writeKey("version"); generator.write(this.version); } } // --------------------------------------------------------------------------------------------- /** * Builder for {@link SubmitRequest}. */ public static class Builder extends WithJsonObjectBuilderBase implements ObjectBuilder { @Nullable private SourceConfig source; @Nullable private Map aggregations; @Nullable private Boolean allowNoIndices; @Nullable private Boolean allowPartialSearchResults; @Nullable private Boolean analyzeWildcard; @Nullable private String analyzer; @Nullable private Long batchedReduceSize; @Nullable private Boolean ccsMinimizeRoundtrips; @Nullable private FieldCollapse collapse; @Nullable private Operator defaultOperator; @Nullable private String df; @Nullable private List docvalueFields; @Nullable private List expandWildcards; @Nullable private Boolean explain; @Nullable private List fields; @Nullable private Integer from; @Nullable private Highlight highlight; @Nullable private Boolean ignoreThrottled; @Nullable private Boolean ignoreUnavailable; @Nullable private List index; @Nullable private List> indicesBoost; @Nullable private Time keepAlive; @Nullable private Boolean keepOnCompletion; @Nullable private Boolean lenient; @Nullable private Long maxConcurrentShardRequests; @Nullable private String minCompatibleShardNode; @Nullable private Double minScore; @Nullable private PointInTimeReference pit; @Nullable private Query postFilter; @Nullable private Long preFilterShardSize; @Nullable private String preference; @Nullable private Boolean profile; @Nullable private String q; @Nullable private Query query; @Nullable private Boolean requestCache; @Nullable private List rescore; @Nullable private String routing; @Nullable private Map> runtimeMappings; @Nullable private Map scriptFields; @Nullable private Time scroll; @Nullable private List searchAfter; @Nullable private SearchType searchType; @Nullable private Boolean seqNoPrimaryTerm; @Nullable private Integer size; @Nullable private SlicedScroll slice; @Nullable private List sort; @Nullable private List stats; @Nullable private List storedFields; @Nullable private Suggester suggest; @Nullable private Long terminateAfter; @Nullable private String timeout; @Nullable private Boolean trackScores; @Nullable private TrackHits trackTotalHits; @Nullable private Boolean version; @Nullable private Time waitForCompletionTimeout; /** * Indicates which source fields are returned for matching documents. These * fields are returned in the hits._source property of the search response. * * API name: {@code _source} */ public final Builder source(@Nullable SourceConfig value) { this.source = value; return this; } /** * Indicates which source fields are returned for matching documents. These * fields are returned in the hits._source property of the search response. * * API name: {@code _source} */ public final Builder source(Function> fn) { return this.source(fn.apply(new SourceConfig.Builder()).build()); } /** * API name: {@code aggregations} * * Adds all entries of map to aggregations. */ public final Builder aggregations(Map map) { this.aggregations = _mapPutAll(this.aggregations, map); return this; } /** * API name: {@code aggregations} * * Adds an entry to aggregations. */ public final Builder aggregations(String key, Aggregation value) { this.aggregations = _mapPut(this.aggregations, key, value); return this; } /** * API name: {@code aggregations} * * Adds an entry to aggregations using a builder lambda. */ public final Builder aggregations(String key, Function> fn) { return aggregations(key, fn.apply(new Aggregation.Builder()).build()); } /** * Whether to ignore if a wildcard indices expression resolves into no concrete * indices. (This includes _all string or when no indices have been * specified) * * API name: {@code allow_no_indices} */ public final Builder allowNoIndices(@Nullable Boolean value) { this.allowNoIndices = value; return this; } /** * Indicate if an error should be returned if there is a partial search failure * or timeout * * API name: {@code allow_partial_search_results} */ public final Builder allowPartialSearchResults(@Nullable Boolean value) { this.allowPartialSearchResults = value; return this; } /** * Specify whether wildcard and prefix queries should be analyzed (default: * false) * * API name: {@code analyze_wildcard} */ public final Builder analyzeWildcard(@Nullable Boolean value) { this.analyzeWildcard = value; return this; } /** * The analyzer to use for the query string * * API name: {@code analyzer} */ public final Builder analyzer(@Nullable String value) { this.analyzer = value; return this; } /** * The number of shard results that should be reduced at once on the * coordinating node. This value should be used as the granularity at which * progress results will be made available. * * API name: {@code batched_reduce_size} */ public final Builder batchedReduceSize(@Nullable Long value) { this.batchedReduceSize = value; return this; } /** * API name: {@code ccs_minimize_roundtrips} */ public final Builder ccsMinimizeRoundtrips(@Nullable Boolean value) { this.ccsMinimizeRoundtrips = value; return this; } /** * API name: {@code collapse} */ public final Builder collapse(@Nullable FieldCollapse value) { this.collapse = value; return this; } /** * API name: {@code collapse} */ public final Builder collapse(Function> fn) { return this.collapse(fn.apply(new FieldCollapse.Builder()).build()); } /** * The default operator for query string query (AND or OR) * * API name: {@code default_operator} */ public final Builder defaultOperator(@Nullable Operator value) { this.defaultOperator = value; return this; } /** * The field to use as default where no field prefix is given in the query * string * * API name: {@code df} */ public final Builder df(@Nullable String value) { this.df = value; return this; } /** * Array of wildcard (*) patterns. The request returns doc values for field * names matching these patterns in the hits.fields property of the response. * * API name: {@code docvalue_fields} * * Adds all elements of list to docvalueFields. */ public final Builder docvalueFields(List list) { this.docvalueFields = _listAddAll(this.docvalueFields, list); return this; } /** * Array of wildcard (*) patterns. The request returns doc values for field * names matching these patterns in the hits.fields property of the response. * * API name: {@code docvalue_fields} * * Adds one or more values to docvalueFields. */ public final Builder docvalueFields(FieldAndFormat value, FieldAndFormat... values) { this.docvalueFields = _listAdd(this.docvalueFields, value, values); return this; } /** * Array of wildcard (*) patterns. The request returns doc values for field * names matching these patterns in the hits.fields property of the response. * * API name: {@code docvalue_fields} * * Adds a value to docvalueFields using a builder lambda. */ public final Builder docvalueFields(Function> fn) { return docvalueFields(fn.apply(new FieldAndFormat.Builder()).build()); } /** * Whether to expand wildcard expression to concrete indices that are open, * closed or both. * * API name: {@code expand_wildcards} * * Adds all elements of list to expandWildcards. */ public final Builder expandWildcards(List list) { this.expandWildcards = _listAddAll(this.expandWildcards, list); return this; } /** * Whether to expand wildcard expression to concrete indices that are open, * closed or both. * * API name: {@code expand_wildcards} * * Adds one or more values to expandWildcards. */ public final Builder expandWildcards(ExpandWildcard value, ExpandWildcard... values) { this.expandWildcards = _listAdd(this.expandWildcards, value, values); return this; } /** * If true, returns detailed information about score computation as part of a * hit. * * API name: {@code explain} */ public final Builder explain(@Nullable Boolean value) { this.explain = value; return this; } /** * Array of wildcard (*) patterns. The request returns values for field names * matching these patterns in the hits.fields property of the response. * * API name: {@code fields} * * Adds all elements of list to fields. */ public final Builder fields(List list) { this.fields = _listAddAll(this.fields, list); return this; } /** * Array of wildcard (*) patterns. The request returns values for field names * matching these patterns in the hits.fields property of the response. * * API name: {@code fields} * * Adds one or more values to fields. */ public final Builder fields(FieldAndFormat value, FieldAndFormat... values) { this.fields = _listAdd(this.fields, value, values); return this; } /** * Array of wildcard (*) patterns. The request returns values for field names * matching these patterns in the hits.fields property of the response. * * API name: {@code fields} * * Adds a value to fields using a builder lambda. */ public final Builder fields(Function> fn) { return fields(fn.apply(new FieldAndFormat.Builder()).build()); } /** * Starting document offset. By default, you cannot page through more than * 10,000 hits using the from and size parameters. To page through more hits, * use the search_after parameter. * * API name: {@code from} */ public final Builder from(@Nullable Integer value) { this.from = value; return this; } /** * API name: {@code highlight} */ public final Builder highlight(@Nullable Highlight value) { this.highlight = value; return this; } /** * API name: {@code highlight} */ public final Builder highlight(Function> fn) { return this.highlight(fn.apply(new Highlight.Builder()).build()); } /** * Whether specified concrete, expanded or aliased indices should be ignored * when throttled * * API name: {@code ignore_throttled} */ public final Builder ignoreThrottled(@Nullable Boolean value) { this.ignoreThrottled = value; return this; } /** * Whether specified concrete indices should be ignored when unavailable * (missing or closed) * * API name: {@code ignore_unavailable} */ public final Builder ignoreUnavailable(@Nullable Boolean value) { this.ignoreUnavailable = value; return this; } /** * A comma-separated list of index names to search; use _all or * empty string to perform the operation on all indices * * API name: {@code index} * * Adds all elements of list to index. */ public final Builder index(List list) { this.index = _listAddAll(this.index, list); return this; } /** * A comma-separated list of index names to search; use _all or * empty string to perform the operation on all indices * * API name: {@code index} * * Adds one or more values to index. */ public final Builder index(String value, String... values) { this.index = _listAdd(this.index, value, values); return this; } /** * Boosts the _score of documents from specified indices. * * API name: {@code indices_boost} * * Adds all elements of list to indicesBoost. */ public final Builder indicesBoost(List> list) { this.indicesBoost = _listAddAll(this.indicesBoost, list); return this; } /** * Boosts the _score of documents from specified indices. * * API name: {@code indices_boost} * * Adds one or more values to indicesBoost. */ public final Builder indicesBoost(Map value, Map... values) { this.indicesBoost = _listAdd(this.indicesBoost, value, values); return this; } /** * Update the time interval in which the results (partial or final) for this * search will be available * * API name: {@code keep_alive} */ public final Builder keepAlive(@Nullable Time value) { this.keepAlive = value; return this; } /** * Update the time interval in which the results (partial or final) for this * search will be available * * API name: {@code keep_alive} */ public final Builder keepAlive(Function> fn) { return this.keepAlive(fn.apply(new Time.Builder()).build()); } /** * Control whether the response should be stored in the cluster if it completed * within the provided [wait_for_completion] time (default: false) * * API name: {@code keep_on_completion} */ public final Builder keepOnCompletion(@Nullable Boolean value) { this.keepOnCompletion = value; return this; } /** * Specify whether format-based query failures (such as providing text to a * numeric field) should be ignored * * API name: {@code lenient} */ public final Builder lenient(@Nullable Boolean value) { this.lenient = value; return this; } /** * The number of concurrent shard requests per node this search executes * concurrently. This value should be used to limit the impact of the search on * the cluster in order to limit the number of concurrent shard requests * * API name: {@code max_concurrent_shard_requests} */ public final Builder maxConcurrentShardRequests(@Nullable Long value) { this.maxConcurrentShardRequests = value; return this; } /** * API name: {@code min_compatible_shard_node} */ public final Builder minCompatibleShardNode(@Nullable String value) { this.minCompatibleShardNode = value; return this; } /** * Minimum _score for matching documents. Documents with a lower _score are not * included in the search results. * * API name: {@code min_score} */ public final Builder minScore(@Nullable Double value) { this.minScore = value; return this; } /** * Limits the search to a point in time (PIT). If you provide a PIT, you cannot * specify an <index> in the request path. * * API name: {@code pit} */ public final Builder pit(@Nullable PointInTimeReference value) { this.pit = value; return this; } /** * Limits the search to a point in time (PIT). If you provide a PIT, you cannot * specify an <index> in the request path. * * API name: {@code pit} */ public final Builder pit(Function> fn) { return this.pit(fn.apply(new PointInTimeReference.Builder()).build()); } /** * API name: {@code post_filter} */ public final Builder postFilter(@Nullable Query value) { this.postFilter = value; return this; } /** * API name: {@code post_filter} */ public final Builder postFilter(Function> fn) { return this.postFilter(fn.apply(new Query.Builder()).build()); } /** * API name: {@code pre_filter_shard_size} */ public final Builder preFilterShardSize(@Nullable Long value) { this.preFilterShardSize = value; return this; } /** * Specify the node or shard the operation should be performed on (default: * random) * * API name: {@code preference} */ public final Builder preference(@Nullable String value) { this.preference = value; return this; } /** * API name: {@code profile} */ public final Builder profile(@Nullable Boolean value) { this.profile = value; return this; } /** * Query in the Lucene query string syntax * * API name: {@code q} */ public final Builder q(@Nullable String value) { this.q = value; return this; } /** * Defines the search definition using the Query DSL. * * API name: {@code query} */ public final Builder query(@Nullable Query value) { this.query = value; return this; } /** * Defines the search definition using the Query DSL. * * API name: {@code query} */ public final Builder query(Function> fn) { return this.query(fn.apply(new Query.Builder()).build()); } /** * Specify if request cache should be used for this request or not, defaults to * true * * API name: {@code request_cache} */ public final Builder requestCache(@Nullable Boolean value) { this.requestCache = value; return this; } /** * API name: {@code rescore} * * Adds all elements of list to rescore. */ public final Builder rescore(List list) { this.rescore = _listAddAll(this.rescore, list); return this; } /** * API name: {@code rescore} * * Adds one or more values to rescore. */ public final Builder rescore(Rescore value, Rescore... values) { this.rescore = _listAdd(this.rescore, value, values); return this; } /** * API name: {@code rescore} * * Adds a value to rescore using a builder lambda. */ public final Builder rescore(Function> fn) { return rescore(fn.apply(new Rescore.Builder()).build()); } /** * A comma-separated list of specific routing values * * API name: {@code routing} */ public final Builder routing(@Nullable String value) { this.routing = value; return this; } /** * Defines one or more runtime fields in the search request. These fields take * precedence over mapped fields with the same name. * * API name: {@code runtime_mappings} * * Adds all entries of map to runtimeMappings. */ public final Builder runtimeMappings(Map> map) { this.runtimeMappings = _mapPutAll(this.runtimeMappings, map); return this; } /** * Defines one or more runtime fields in the search request. These fields take * precedence over mapped fields with the same name. * * API name: {@code runtime_mappings} * * Adds an entry to runtimeMappings. */ public final Builder runtimeMappings(String key, List value) { this.runtimeMappings = _mapPut(this.runtimeMappings, key, value); return this; } /** * Retrieve a script evaluation (based on different fields) for each hit. * * API name: {@code script_fields} * * Adds all entries of map to scriptFields. */ public final Builder scriptFields(Map map) { this.scriptFields = _mapPutAll(this.scriptFields, map); return this; } /** * Retrieve a script evaluation (based on different fields) for each hit. * * API name: {@code script_fields} * * Adds an entry to scriptFields. */ public final Builder scriptFields(String key, ScriptField value) { this.scriptFields = _mapPut(this.scriptFields, key, value); return this; } /** * Retrieve a script evaluation (based on different fields) for each hit. * * API name: {@code script_fields} * * Adds an entry to scriptFields using a builder lambda. */ public final Builder scriptFields(String key, Function> fn) { return scriptFields(key, fn.apply(new ScriptField.Builder()).build()); } /** * API name: {@code scroll} */ public final Builder scroll(@Nullable Time value) { this.scroll = value; return this; } /** * API name: {@code scroll} */ public final Builder scroll(Function> fn) { return this.scroll(fn.apply(new Time.Builder()).build()); } /** * API name: {@code search_after} * * Adds all elements of list to searchAfter. */ public final Builder searchAfter(List list) { this.searchAfter = _listAddAll(this.searchAfter, list); return this; } /** * API name: {@code search_after} * * Adds one or more values to searchAfter. */ public final Builder searchAfter(String value, String... values) { this.searchAfter = _listAdd(this.searchAfter, value, values); return this; } /** * Search operation type * * API name: {@code search_type} */ public final Builder searchType(@Nullable SearchType value) { this.searchType = value; return this; } /** * If true, returns sequence number and primary term of the last modification of * each hit. See Optimistic concurrency control. * * API name: {@code seq_no_primary_term} */ public final Builder seqNoPrimaryTerm(@Nullable Boolean value) { this.seqNoPrimaryTerm = value; return this; } /** * The number of hits to return. By default, you cannot page through more than * 10,000 hits using the from and size parameters. To page through more hits, * use the search_after parameter. * * API name: {@code size} */ public final Builder size(@Nullable Integer value) { this.size = value; return this; } /** * API name: {@code slice} */ public final Builder slice(@Nullable SlicedScroll value) { this.slice = value; return this; } /** * API name: {@code slice} */ public final Builder slice(Function> fn) { return this.slice(fn.apply(new SlicedScroll.Builder()).build()); } /** * API name: {@code sort} * * Adds all elements of list to sort. */ public final Builder sort(List list) { this.sort = _listAddAll(this.sort, list); return this; } /** * API name: {@code sort} * * Adds one or more values to sort. */ public final Builder sort(SortOptions value, SortOptions... values) { this.sort = _listAdd(this.sort, value, values); return this; } /** * API name: {@code sort} * * Adds a value to sort using a builder lambda. */ public final Builder sort(Function> fn) { return sort(fn.apply(new SortOptions.Builder()).build()); } /** * Stats groups to associate with the search. Each group maintains a statistics * aggregation for its associated searches. You can retrieve these stats using * the indices stats API. * * API name: {@code stats} * * Adds all elements of list to stats. */ public final Builder stats(List list) { this.stats = _listAddAll(this.stats, list); return this; } /** * Stats groups to associate with the search. Each group maintains a statistics * aggregation for its associated searches. You can retrieve these stats using * the indices stats API. * * API name: {@code stats} * * Adds one or more values to stats. */ public final Builder stats(String value, String... values) { this.stats = _listAdd(this.stats, value, values); return this; } /** * List of stored fields to return as part of a hit. If no fields are specified, * no stored fields are included in the response. If this field is specified, * the _source parameter defaults to false. You can pass _source: true to return * both source fields and stored fields in the search response. * * API name: {@code stored_fields} * * Adds all elements of list to storedFields. */ public final Builder storedFields(List list) { this.storedFields = _listAddAll(this.storedFields, list); return this; } /** * List of stored fields to return as part of a hit. If no fields are specified, * no stored fields are included in the response. If this field is specified, * the _source parameter defaults to false. You can pass _source: true to return * both source fields and stored fields in the search response. * * API name: {@code stored_fields} * * Adds one or more values to storedFields. */ public final Builder storedFields(String value, String... values) { this.storedFields = _listAdd(this.storedFields, value, values); return this; } /** * API name: {@code suggest} */ public final Builder suggest(@Nullable Suggester value) { this.suggest = value; return this; } /** * API name: {@code suggest} */ public final Builder suggest(Function> fn) { return this.suggest(fn.apply(new Suggester.Builder()).build()); } /** * Maximum number of documents to collect for each shard. If a query reaches * this limit, Elasticsearch terminates the query early. Elasticsearch collects * documents before sorting. Defaults to 0, which does not terminate query * execution early. * * API name: {@code terminate_after} */ public final Builder terminateAfter(@Nullable Long value) { this.terminateAfter = value; return this; } /** * Specifies the period of time to wait for a response from each shard. If no * response is received before the timeout expires, the request fails and * returns an error. Defaults to no timeout. * * API name: {@code timeout} */ public final Builder timeout(@Nullable String value) { this.timeout = value; return this; } /** * If true, calculate and return document scores, even if the scores are not * used for sorting. * * API name: {@code track_scores} */ public final Builder trackScores(@Nullable Boolean value) { this.trackScores = value; return this; } /** * Number of hits matching the query to count accurately. If true, the exact * number of hits is returned at the cost of some performance. If false, the * response does not include the total number of hits matching the query. * Defaults to 10,000 hits. * * API name: {@code track_total_hits} */ public final Builder trackTotalHits(@Nullable TrackHits value) { this.trackTotalHits = value; return this; } /** * Number of hits matching the query to count accurately. If true, the exact * number of hits is returned at the cost of some performance. If false, the * response does not include the total number of hits matching the query. * Defaults to 10,000 hits. * * API name: {@code track_total_hits} */ public final Builder trackTotalHits(Function> fn) { return this.trackTotalHits(fn.apply(new TrackHits.Builder()).build()); } /** * If true, returns document version as part of a hit. * * API name: {@code version} */ public final Builder version(@Nullable Boolean value) { this.version = value; return this; } /** * Specify the time that the request should block waiting for the final response * * API name: {@code wait_for_completion_timeout} */ public final Builder waitForCompletionTimeout(@Nullable Time value) { this.waitForCompletionTimeout = value; return this; } /** * Specify the time that the request should block waiting for the final response * * API name: {@code wait_for_completion_timeout} */ public final Builder waitForCompletionTimeout(Function> fn) { return this.waitForCompletionTimeout(fn.apply(new Time.Builder()).build()); } @Override protected Builder self() { return this; } /** * Builds a {@link SubmitRequest}. * * @throws NullPointerException * if some of the required fields are null. */ public SubmitRequest build() { _checkSingleUse(); return new SubmitRequest(this); } } // --------------------------------------------------------------------------------------------- /** * Json deserializer for {@link SubmitRequest} */ public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy(Builder::new, SubmitRequest::setupSubmitRequestDeserializer); protected static void setupSubmitRequestDeserializer(ObjectDeserializer op) { op.add(Builder::source, SourceConfig._DESERIALIZER, "_source"); op.add(Builder::aggregations, JsonpDeserializer.stringMapDeserializer(Aggregation._DESERIALIZER), "aggregations", "aggs"); op.add(Builder::collapse, FieldCollapse._DESERIALIZER, "collapse"); op.add(Builder::docvalueFields, JsonpDeserializer.arrayDeserializer(FieldAndFormat._DESERIALIZER), "docvalue_fields"); op.add(Builder::explain, JsonpDeserializer.booleanDeserializer(), "explain"); op.add(Builder::fields, JsonpDeserializer.arrayDeserializer(FieldAndFormat._DESERIALIZER), "fields"); op.add(Builder::from, JsonpDeserializer.integerDeserializer(), "from"); op.add(Builder::highlight, Highlight._DESERIALIZER, "highlight"); op.add(Builder::indicesBoost, JsonpDeserializer.arrayDeserializer( JsonpDeserializer.stringMapDeserializer(JsonpDeserializer.doubleDeserializer())), "indices_boost"); op.add(Builder::minScore, JsonpDeserializer.doubleDeserializer(), "min_score"); op.add(Builder::pit, PointInTimeReference._DESERIALIZER, "pit"); op.add(Builder::postFilter, Query._DESERIALIZER, "post_filter"); op.add(Builder::profile, JsonpDeserializer.booleanDeserializer(), "profile"); op.add(Builder::query, Query._DESERIALIZER, "query"); op.add(Builder::rescore, JsonpDeserializer.arrayDeserializer(Rescore._DESERIALIZER), "rescore"); op.add(Builder::runtimeMappings, JsonpDeserializer.stringMapDeserializer( JsonpDeserializer.arrayDeserializer(RuntimeField._DESERIALIZER)), "runtime_mappings"); op.add(Builder::scriptFields, JsonpDeserializer.stringMapDeserializer(ScriptField._DESERIALIZER), "script_fields"); op.add(Builder::searchAfter, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "search_after"); op.add(Builder::seqNoPrimaryTerm, JsonpDeserializer.booleanDeserializer(), "seq_no_primary_term"); op.add(Builder::size, JsonpDeserializer.integerDeserializer(), "size"); op.add(Builder::slice, SlicedScroll._DESERIALIZER, "slice"); op.add(Builder::sort, JsonpDeserializer.arrayDeserializer(SortOptions._DESERIALIZER), "sort"); op.add(Builder::stats, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "stats"); op.add(Builder::storedFields, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "stored_fields"); op.add(Builder::suggest, Suggester._DESERIALIZER, "suggest"); op.add(Builder::terminateAfter, JsonpDeserializer.longDeserializer(), "terminate_after"); op.add(Builder::timeout, JsonpDeserializer.stringDeserializer(), "timeout"); op.add(Builder::trackScores, JsonpDeserializer.booleanDeserializer(), "track_scores"); op.add(Builder::trackTotalHits, TrackHits._DESERIALIZER, "track_total_hits"); op.add(Builder::version, JsonpDeserializer.booleanDeserializer(), "version"); } // --------------------------------------------------------------------------------------------- /** * Endpoint "{@code async_search.submit}". */ public static final SimpleEndpoint _ENDPOINT = new SimpleEndpoint<>("es/async_search.submit", // Request method request -> { return "POST"; }, // Request path request -> { final int _index = 1 << 0; int propsSet = 0; if (ApiTypeHelper.isDefined(request.index())) propsSet |= _index; if (propsSet == 0) { StringBuilder buf = new StringBuilder(); buf.append("/_async_search"); return buf.toString(); } if (propsSet == (_index)) { StringBuilder buf = new StringBuilder(); buf.append("/"); SimpleEndpoint.pathEncode(request.index.stream().map(v -> v).collect(Collectors.joining(",")), buf); buf.append("/_async_search"); return buf.toString(); } throw SimpleEndpoint.noPathTemplateFound("path"); }, // Request parameters request -> { Map params = new HashMap<>(); params.put("typed_keys", "true"); if (request.df != null) { params.put("df", request.df); } if (request.preFilterShardSize != null) { params.put("pre_filter_shard_size", String.valueOf(request.preFilterShardSize)); } if (request.minCompatibleShardNode != null) { params.put("min_compatible_shard_node", request.minCompatibleShardNode); } if (request.lenient != null) { params.put("lenient", String.valueOf(request.lenient)); } if (request.routing != null) { params.put("routing", request.routing); } if (request.ignoreUnavailable != null) { params.put("ignore_unavailable", String.valueOf(request.ignoreUnavailable)); } if (request.allowNoIndices != null) { params.put("allow_no_indices", String.valueOf(request.allowNoIndices)); } if (request.analyzer != null) { params.put("analyzer", request.analyzer); } if (request.ignoreThrottled != null) { params.put("ignore_throttled", String.valueOf(request.ignoreThrottled)); } if (request.keepOnCompletion != null) { params.put("keep_on_completion", String.valueOf(request.keepOnCompletion)); } if (request.maxConcurrentShardRequests != null) { params.put("max_concurrent_shard_requests", String.valueOf(request.maxConcurrentShardRequests)); } if (request.allowPartialSearchResults != null) { params.put("allow_partial_search_results", String.valueOf(request.allowPartialSearchResults)); } if (ApiTypeHelper.isDefined(request.expandWildcards)) { params.put("expand_wildcards", request.expandWildcards.stream().map(v -> v.jsonValue()).collect(Collectors.joining(","))); } if (request.preference != null) { params.put("preference", request.preference); } if (request.analyzeWildcard != null) { params.put("analyze_wildcard", String.valueOf(request.analyzeWildcard)); } if (request.scroll != null) { params.put("scroll", request.scroll._toJsonString()); } if (request.waitForCompletionTimeout != null) { params.put("wait_for_completion_timeout", request.waitForCompletionTimeout._toJsonString()); } if (request.searchType != null) { params.put("search_type", request.searchType.jsonValue()); } if (request.ccsMinimizeRoundtrips != null) { params.put("ccs_minimize_roundtrips", String.valueOf(request.ccsMinimizeRoundtrips)); } if (request.q != null) { params.put("q", request.q); } if (request.defaultOperator != null) { params.put("default_operator", request.defaultOperator.jsonValue()); } if (request.keepAlive != null) { params.put("keep_alive", request.keepAlive._toJsonString()); } if (request.requestCache != null) { params.put("request_cache", String.valueOf(request.requestCache)); } if (request.batchedReduceSize != null) { params.put("batched_reduce_size", String.valueOf(request.batchedReduceSize)); } return params; }, SimpleEndpoint.emptyMap(), true, SubmitResponse._DESERIALIZER); /** * Create an "{@code async_search.submit}" endpoint. */ public static Endpoint, ErrorResponse> createSubmitEndpoint( JsonpDeserializer tDocumentDeserializer) { return _ENDPOINT .withResponseDeserializer(SubmitResponse.createSubmitResponseDeserializer(tDocumentDeserializer)); } }
* API name: {@code routing} */ @Nullable public final String routing() { return this.routing; } /** * Defines one or more runtime fields in the search request. These fields take * precedence over mapped fields with the same name. *
* API name: {@code runtime_mappings} */ public final Map> runtimeMappings() { return this.runtimeMappings; } /** * Retrieve a script evaluation (based on different fields) for each hit. * * API name: {@code script_fields} */ public final Map scriptFields() { return this.scriptFields; } /** * API name: {@code scroll} */ @Nullable public final Time scroll() { return this.scroll; } /** * API name: {@code search_after} */ public final List searchAfter() { return this.searchAfter; } /** * Search operation type * * API name: {@code search_type} */ @Nullable public final SearchType searchType() { return this.searchType; } /** * If true, returns sequence number and primary term of the last modification of * each hit. See Optimistic concurrency control. * * API name: {@code seq_no_primary_term} */ @Nullable public final Boolean seqNoPrimaryTerm() { return this.seqNoPrimaryTerm; } /** * The number of hits to return. By default, you cannot page through more than * 10,000 hits using the from and size parameters. To page through more hits, * use the search_after parameter. * * API name: {@code size} */ @Nullable public final Integer size() { return this.size; } /** * API name: {@code slice} */ @Nullable public final SlicedScroll slice() { return this.slice; } /** * API name: {@code sort} */ public final List sort() { return this.sort; } /** * Stats groups to associate with the search. Each group maintains a statistics * aggregation for its associated searches. You can retrieve these stats using * the indices stats API. * * API name: {@code stats} */ public final List stats() { return this.stats; } /** * List of stored fields to return as part of a hit. If no fields are specified, * no stored fields are included in the response. If this field is specified, * the _source parameter defaults to false. You can pass _source: true to return * both source fields and stored fields in the search response. * * API name: {@code stored_fields} */ public final List storedFields() { return this.storedFields; } /** * API name: {@code suggest} */ @Nullable public final Suggester suggest() { return this.suggest; } /** * Maximum number of documents to collect for each shard. If a query reaches * this limit, Elasticsearch terminates the query early. Elasticsearch collects * documents before sorting. Defaults to 0, which does not terminate query * execution early. * * API name: {@code terminate_after} */ @Nullable public final Long terminateAfter() { return this.terminateAfter; } /** * Specifies the period of time to wait for a response from each shard. If no * response is received before the timeout expires, the request fails and * returns an error. Defaults to no timeout. * * API name: {@code timeout} */ @Nullable public final String timeout() { return this.timeout; } /** * If true, calculate and return document scores, even if the scores are not * used for sorting. * * API name: {@code track_scores} */ @Nullable public final Boolean trackScores() { return this.trackScores; } /** * Number of hits matching the query to count accurately. If true, the exact * number of hits is returned at the cost of some performance. If false, the * response does not include the total number of hits matching the query. * Defaults to 10,000 hits. * * API name: {@code track_total_hits} */ @Nullable public final TrackHits trackTotalHits() { return this.trackTotalHits; } /** * If true, returns document version as part of a hit. * * API name: {@code version} */ @Nullable public final Boolean version() { return this.version; } /** * Specify the time that the request should block waiting for the final response * * API name: {@code wait_for_completion_timeout} */ @Nullable public final Time waitForCompletionTimeout() { return this.waitForCompletionTimeout; } /** * 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.source != null) { generator.writeKey("_source"); this.source.serialize(generator, mapper); } if (ApiTypeHelper.isDefined(this.aggregations)) { generator.writeKey("aggregations"); generator.writeStartObject(); for (Map.Entry item0 : this.aggregations.entrySet()) { generator.writeKey(item0.getKey()); item0.getValue().serialize(generator, mapper); } generator.writeEnd(); } if (this.collapse != null) { generator.writeKey("collapse"); this.collapse.serialize(generator, mapper); } if (ApiTypeHelper.isDefined(this.docvalueFields)) { generator.writeKey("docvalue_fields"); generator.writeStartArray(); for (FieldAndFormat item0 : this.docvalueFields) { item0.serialize(generator, mapper); } generator.writeEnd(); } if (this.explain != null) { generator.writeKey("explain"); generator.write(this.explain); } if (ApiTypeHelper.isDefined(this.fields)) { generator.writeKey("fields"); generator.writeStartArray(); for (FieldAndFormat item0 : this.fields) { item0.serialize(generator, mapper); } generator.writeEnd(); } if (this.from != null) { generator.writeKey("from"); generator.write(this.from); } if (this.highlight != null) { generator.writeKey("highlight"); this.highlight.serialize(generator, mapper); } if (ApiTypeHelper.isDefined(this.indicesBoost)) { generator.writeKey("indices_boost"); generator.writeStartArray(); for (Map item0 : this.indicesBoost) { generator.writeStartObject(); if (item0 != null) { for (Map.Entry item1 : item0.entrySet()) { generator.writeKey(item1.getKey()); generator.write(item1.getValue()); } } generator.writeEnd(); } generator.writeEnd(); } if (this.minScore != null) { generator.writeKey("min_score"); generator.write(this.minScore); } if (this.pit != null) { generator.writeKey("pit"); this.pit.serialize(generator, mapper); } if (this.postFilter != null) { generator.writeKey("post_filter"); this.postFilter.serialize(generator, mapper); } if (this.profile != null) { generator.writeKey("profile"); generator.write(this.profile); } if (this.query != null) { generator.writeKey("query"); this.query.serialize(generator, mapper); } if (ApiTypeHelper.isDefined(this.rescore)) { generator.writeKey("rescore"); generator.writeStartArray(); for (Rescore item0 : this.rescore) { item0.serialize(generator, mapper); } generator.writeEnd(); } if (ApiTypeHelper.isDefined(this.runtimeMappings)) { generator.writeKey("runtime_mappings"); generator.writeStartObject(); for (Map.Entry> item0 : this.runtimeMappings.entrySet()) { generator.writeKey(item0.getKey()); generator.writeStartArray(); if (item0.getValue() != null) { for (RuntimeField item1 : item0.getValue()) { item1.serialize(generator, mapper); } } generator.writeEnd(); } generator.writeEnd(); } if (ApiTypeHelper.isDefined(this.scriptFields)) { generator.writeKey("script_fields"); generator.writeStartObject(); for (Map.Entry item0 : this.scriptFields.entrySet()) { generator.writeKey(item0.getKey()); item0.getValue().serialize(generator, mapper); } generator.writeEnd(); } if (ApiTypeHelper.isDefined(this.searchAfter)) { generator.writeKey("search_after"); generator.writeStartArray(); for (String item0 : this.searchAfter) { generator.write(item0); } generator.writeEnd(); } if (this.seqNoPrimaryTerm != null) { generator.writeKey("seq_no_primary_term"); generator.write(this.seqNoPrimaryTerm); } if (this.size != null) { generator.writeKey("size"); generator.write(this.size); } if (this.slice != null) { generator.writeKey("slice"); this.slice.serialize(generator, mapper); } if (ApiTypeHelper.isDefined(this.sort)) { generator.writeKey("sort"); generator.writeStartArray(); for (SortOptions item0 : this.sort) { item0.serialize(generator, mapper); } generator.writeEnd(); } if (ApiTypeHelper.isDefined(this.stats)) { generator.writeKey("stats"); generator.writeStartArray(); for (String item0 : this.stats) { generator.write(item0); } generator.writeEnd(); } if (ApiTypeHelper.isDefined(this.storedFields)) { generator.writeKey("stored_fields"); generator.writeStartArray(); for (String item0 : this.storedFields) { generator.write(item0); } generator.writeEnd(); } if (this.suggest != null) { generator.writeKey("suggest"); this.suggest.serialize(generator, mapper); } if (this.terminateAfter != null) { generator.writeKey("terminate_after"); generator.write(this.terminateAfter); } if (this.timeout != null) { generator.writeKey("timeout"); generator.write(this.timeout); } if (this.trackScores != null) { generator.writeKey("track_scores"); generator.write(this.trackScores); } if (this.trackTotalHits != null) { generator.writeKey("track_total_hits"); this.trackTotalHits.serialize(generator, mapper); } if (this.version != null) { generator.writeKey("version"); generator.write(this.version); } } // --------------------------------------------------------------------------------------------- /** * Builder for {@link SubmitRequest}. */ public static class Builder extends WithJsonObjectBuilderBase implements ObjectBuilder { @Nullable private SourceConfig source; @Nullable private Map aggregations; @Nullable private Boolean allowNoIndices; @Nullable private Boolean allowPartialSearchResults; @Nullable private Boolean analyzeWildcard; @Nullable private String analyzer; @Nullable private Long batchedReduceSize; @Nullable private Boolean ccsMinimizeRoundtrips; @Nullable private FieldCollapse collapse; @Nullable private Operator defaultOperator; @Nullable private String df; @Nullable private List docvalueFields; @Nullable private List expandWildcards; @Nullable private Boolean explain; @Nullable private List fields; @Nullable private Integer from; @Nullable private Highlight highlight; @Nullable private Boolean ignoreThrottled; @Nullable private Boolean ignoreUnavailable; @Nullable private List index; @Nullable private List> indicesBoost; @Nullable private Time keepAlive; @Nullable private Boolean keepOnCompletion; @Nullable private Boolean lenient; @Nullable private Long maxConcurrentShardRequests; @Nullable private String minCompatibleShardNode; @Nullable private Double minScore; @Nullable private PointInTimeReference pit; @Nullable private Query postFilter; @Nullable private Long preFilterShardSize; @Nullable private String preference; @Nullable private Boolean profile; @Nullable private String q; @Nullable private Query query; @Nullable private Boolean requestCache; @Nullable private List rescore; @Nullable private String routing; @Nullable private Map> runtimeMappings; @Nullable private Map scriptFields; @Nullable private Time scroll; @Nullable private List searchAfter; @Nullable private SearchType searchType; @Nullable private Boolean seqNoPrimaryTerm; @Nullable private Integer size; @Nullable private SlicedScroll slice; @Nullable private List sort; @Nullable private List stats; @Nullable private List storedFields; @Nullable private Suggester suggest; @Nullable private Long terminateAfter; @Nullable private String timeout; @Nullable private Boolean trackScores; @Nullable private TrackHits trackTotalHits; @Nullable private Boolean version; @Nullable private Time waitForCompletionTimeout; /** * Indicates which source fields are returned for matching documents. These * fields are returned in the hits._source property of the search response. * * API name: {@code _source} */ public final Builder source(@Nullable SourceConfig value) { this.source = value; return this; } /** * Indicates which source fields are returned for matching documents. These * fields are returned in the hits._source property of the search response. * * API name: {@code _source} */ public final Builder source(Function> fn) { return this.source(fn.apply(new SourceConfig.Builder()).build()); } /** * API name: {@code aggregations} * * Adds all entries of map to aggregations. */ public final Builder aggregations(Map map) { this.aggregations = _mapPutAll(this.aggregations, map); return this; } /** * API name: {@code aggregations} * * Adds an entry to aggregations. */ public final Builder aggregations(String key, Aggregation value) { this.aggregations = _mapPut(this.aggregations, key, value); return this; } /** * API name: {@code aggregations} * * Adds an entry to aggregations using a builder lambda. */ public final Builder aggregations(String key, Function> fn) { return aggregations(key, fn.apply(new Aggregation.Builder()).build()); } /** * Whether to ignore if a wildcard indices expression resolves into no concrete * indices. (This includes _all string or when no indices have been * specified) * * API name: {@code allow_no_indices} */ public final Builder allowNoIndices(@Nullable Boolean value) { this.allowNoIndices = value; return this; } /** * Indicate if an error should be returned if there is a partial search failure * or timeout * * API name: {@code allow_partial_search_results} */ public final Builder allowPartialSearchResults(@Nullable Boolean value) { this.allowPartialSearchResults = value; return this; } /** * Specify whether wildcard and prefix queries should be analyzed (default: * false) * * API name: {@code analyze_wildcard} */ public final Builder analyzeWildcard(@Nullable Boolean value) { this.analyzeWildcard = value; return this; } /** * The analyzer to use for the query string * * API name: {@code analyzer} */ public final Builder analyzer(@Nullable String value) { this.analyzer = value; return this; } /** * The number of shard results that should be reduced at once on the * coordinating node. This value should be used as the granularity at which * progress results will be made available. * * API name: {@code batched_reduce_size} */ public final Builder batchedReduceSize(@Nullable Long value) { this.batchedReduceSize = value; return this; } /** * API name: {@code ccs_minimize_roundtrips} */ public final Builder ccsMinimizeRoundtrips(@Nullable Boolean value) { this.ccsMinimizeRoundtrips = value; return this; } /** * API name: {@code collapse} */ public final Builder collapse(@Nullable FieldCollapse value) { this.collapse = value; return this; } /** * API name: {@code collapse} */ public final Builder collapse(Function> fn) { return this.collapse(fn.apply(new FieldCollapse.Builder()).build()); } /** * The default operator for query string query (AND or OR) * * API name: {@code default_operator} */ public final Builder defaultOperator(@Nullable Operator value) { this.defaultOperator = value; return this; } /** * The field to use as default where no field prefix is given in the query * string * * API name: {@code df} */ public final Builder df(@Nullable String value) { this.df = value; return this; } /** * Array of wildcard (*) patterns. The request returns doc values for field * names matching these patterns in the hits.fields property of the response. * * API name: {@code docvalue_fields} * * Adds all elements of list to docvalueFields. */ public final Builder docvalueFields(List list) { this.docvalueFields = _listAddAll(this.docvalueFields, list); return this; } /** * Array of wildcard (*) patterns. The request returns doc values for field * names matching these patterns in the hits.fields property of the response. * * API name: {@code docvalue_fields} * * Adds one or more values to docvalueFields. */ public final Builder docvalueFields(FieldAndFormat value, FieldAndFormat... values) { this.docvalueFields = _listAdd(this.docvalueFields, value, values); return this; } /** * Array of wildcard (*) patterns. The request returns doc values for field * names matching these patterns in the hits.fields property of the response. * * API name: {@code docvalue_fields} * * Adds a value to docvalueFields using a builder lambda. */ public final Builder docvalueFields(Function> fn) { return docvalueFields(fn.apply(new FieldAndFormat.Builder()).build()); } /** * Whether to expand wildcard expression to concrete indices that are open, * closed or both. * * API name: {@code expand_wildcards} * * Adds all elements of list to expandWildcards. */ public final Builder expandWildcards(List list) { this.expandWildcards = _listAddAll(this.expandWildcards, list); return this; } /** * Whether to expand wildcard expression to concrete indices that are open, * closed or both. * * API name: {@code expand_wildcards} * * Adds one or more values to expandWildcards. */ public final Builder expandWildcards(ExpandWildcard value, ExpandWildcard... values) { this.expandWildcards = _listAdd(this.expandWildcards, value, values); return this; } /** * If true, returns detailed information about score computation as part of a * hit. * * API name: {@code explain} */ public final Builder explain(@Nullable Boolean value) { this.explain = value; return this; } /** * Array of wildcard (*) patterns. The request returns values for field names * matching these patterns in the hits.fields property of the response. * * API name: {@code fields} * * Adds all elements of list to fields. */ public final Builder fields(List list) { this.fields = _listAddAll(this.fields, list); return this; } /** * Array of wildcard (*) patterns. The request returns values for field names * matching these patterns in the hits.fields property of the response. * * API name: {@code fields} * * Adds one or more values to fields. */ public final Builder fields(FieldAndFormat value, FieldAndFormat... values) { this.fields = _listAdd(this.fields, value, values); return this; } /** * Array of wildcard (*) patterns. The request returns values for field names * matching these patterns in the hits.fields property of the response. * * API name: {@code fields} * * Adds a value to fields using a builder lambda. */ public final Builder fields(Function> fn) { return fields(fn.apply(new FieldAndFormat.Builder()).build()); } /** * Starting document offset. By default, you cannot page through more than * 10,000 hits using the from and size parameters. To page through more hits, * use the search_after parameter. * * API name: {@code from} */ public final Builder from(@Nullable Integer value) { this.from = value; return this; } /** * API name: {@code highlight} */ public final Builder highlight(@Nullable Highlight value) { this.highlight = value; return this; } /** * API name: {@code highlight} */ public final Builder highlight(Function> fn) { return this.highlight(fn.apply(new Highlight.Builder()).build()); } /** * Whether specified concrete, expanded or aliased indices should be ignored * when throttled * * API name: {@code ignore_throttled} */ public final Builder ignoreThrottled(@Nullable Boolean value) { this.ignoreThrottled = value; return this; } /** * Whether specified concrete indices should be ignored when unavailable * (missing or closed) * * API name: {@code ignore_unavailable} */ public final Builder ignoreUnavailable(@Nullable Boolean value) { this.ignoreUnavailable = value; return this; } /** * A comma-separated list of index names to search; use _all or * empty string to perform the operation on all indices * * API name: {@code index} * * Adds all elements of list to index. */ public final Builder index(List list) { this.index = _listAddAll(this.index, list); return this; } /** * A comma-separated list of index names to search; use _all or * empty string to perform the operation on all indices * * API name: {@code index} * * Adds one or more values to index. */ public final Builder index(String value, String... values) { this.index = _listAdd(this.index, value, values); return this; } /** * Boosts the _score of documents from specified indices. * * API name: {@code indices_boost} * * Adds all elements of list to indicesBoost. */ public final Builder indicesBoost(List> list) { this.indicesBoost = _listAddAll(this.indicesBoost, list); return this; } /** * Boosts the _score of documents from specified indices. * * API name: {@code indices_boost} * * Adds one or more values to indicesBoost. */ public final Builder indicesBoost(Map value, Map... values) { this.indicesBoost = _listAdd(this.indicesBoost, value, values); return this; } /** * Update the time interval in which the results (partial or final) for this * search will be available * * API name: {@code keep_alive} */ public final Builder keepAlive(@Nullable Time value) { this.keepAlive = value; return this; } /** * Update the time interval in which the results (partial or final) for this * search will be available * * API name: {@code keep_alive} */ public final Builder keepAlive(Function> fn) { return this.keepAlive(fn.apply(new Time.Builder()).build()); } /** * Control whether the response should be stored in the cluster if it completed * within the provided [wait_for_completion] time (default: false) * * API name: {@code keep_on_completion} */ public final Builder keepOnCompletion(@Nullable Boolean value) { this.keepOnCompletion = value; return this; } /** * Specify whether format-based query failures (such as providing text to a * numeric field) should be ignored * * API name: {@code lenient} */ public final Builder lenient(@Nullable Boolean value) { this.lenient = value; return this; } /** * The number of concurrent shard requests per node this search executes * concurrently. This value should be used to limit the impact of the search on * the cluster in order to limit the number of concurrent shard requests * * API name: {@code max_concurrent_shard_requests} */ public final Builder maxConcurrentShardRequests(@Nullable Long value) { this.maxConcurrentShardRequests = value; return this; } /** * API name: {@code min_compatible_shard_node} */ public final Builder minCompatibleShardNode(@Nullable String value) { this.minCompatibleShardNode = value; return this; } /** * Minimum _score for matching documents. Documents with a lower _score are not * included in the search results. * * API name: {@code min_score} */ public final Builder minScore(@Nullable Double value) { this.minScore = value; return this; } /** * Limits the search to a point in time (PIT). If you provide a PIT, you cannot * specify an <index> in the request path. * * API name: {@code pit} */ public final Builder pit(@Nullable PointInTimeReference value) { this.pit = value; return this; } /** * Limits the search to a point in time (PIT). If you provide a PIT, you cannot * specify an <index> in the request path. * * API name: {@code pit} */ public final Builder pit(Function> fn) { return this.pit(fn.apply(new PointInTimeReference.Builder()).build()); } /** * API name: {@code post_filter} */ public final Builder postFilter(@Nullable Query value) { this.postFilter = value; return this; } /** * API name: {@code post_filter} */ public final Builder postFilter(Function> fn) { return this.postFilter(fn.apply(new Query.Builder()).build()); } /** * API name: {@code pre_filter_shard_size} */ public final Builder preFilterShardSize(@Nullable Long value) { this.preFilterShardSize = value; return this; } /** * Specify the node or shard the operation should be performed on (default: * random) * * API name: {@code preference} */ public final Builder preference(@Nullable String value) { this.preference = value; return this; } /** * API name: {@code profile} */ public final Builder profile(@Nullable Boolean value) { this.profile = value; return this; } /** * Query in the Lucene query string syntax * * API name: {@code q} */ public final Builder q(@Nullable String value) { this.q = value; return this; } /** * Defines the search definition using the Query DSL. * * API name: {@code query} */ public final Builder query(@Nullable Query value) { this.query = value; return this; } /** * Defines the search definition using the Query DSL. * * API name: {@code query} */ public final Builder query(Function> fn) { return this.query(fn.apply(new Query.Builder()).build()); } /** * Specify if request cache should be used for this request or not, defaults to * true * * API name: {@code request_cache} */ public final Builder requestCache(@Nullable Boolean value) { this.requestCache = value; return this; } /** * API name: {@code rescore} * * Adds all elements of list to rescore. */ public final Builder rescore(List list) { this.rescore = _listAddAll(this.rescore, list); return this; } /** * API name: {@code rescore} * * Adds one or more values to rescore. */ public final Builder rescore(Rescore value, Rescore... values) { this.rescore = _listAdd(this.rescore, value, values); return this; } /** * API name: {@code rescore} * * Adds a value to rescore using a builder lambda. */ public final Builder rescore(Function> fn) { return rescore(fn.apply(new Rescore.Builder()).build()); } /** * A comma-separated list of specific routing values * * API name: {@code routing} */ public final Builder routing(@Nullable String value) { this.routing = value; return this; } /** * Defines one or more runtime fields in the search request. These fields take * precedence over mapped fields with the same name. * * API name: {@code runtime_mappings} * * Adds all entries of map to runtimeMappings. */ public final Builder runtimeMappings(Map> map) { this.runtimeMappings = _mapPutAll(this.runtimeMappings, map); return this; } /** * Defines one or more runtime fields in the search request. These fields take * precedence over mapped fields with the same name. * * API name: {@code runtime_mappings} * * Adds an entry to runtimeMappings. */ public final Builder runtimeMappings(String key, List value) { this.runtimeMappings = _mapPut(this.runtimeMappings, key, value); return this; } /** * Retrieve a script evaluation (based on different fields) for each hit. * * API name: {@code script_fields} * * Adds all entries of map to scriptFields. */ public final Builder scriptFields(Map map) { this.scriptFields = _mapPutAll(this.scriptFields, map); return this; } /** * Retrieve a script evaluation (based on different fields) for each hit. * * API name: {@code script_fields} * * Adds an entry to scriptFields. */ public final Builder scriptFields(String key, ScriptField value) { this.scriptFields = _mapPut(this.scriptFields, key, value); return this; } /** * Retrieve a script evaluation (based on different fields) for each hit. * * API name: {@code script_fields} * * Adds an entry to scriptFields using a builder lambda. */ public final Builder scriptFields(String key, Function> fn) { return scriptFields(key, fn.apply(new ScriptField.Builder()).build()); } /** * API name: {@code scroll} */ public final Builder scroll(@Nullable Time value) { this.scroll = value; return this; } /** * API name: {@code scroll} */ public final Builder scroll(Function> fn) { return this.scroll(fn.apply(new Time.Builder()).build()); } /** * API name: {@code search_after} * * Adds all elements of list to searchAfter. */ public final Builder searchAfter(List list) { this.searchAfter = _listAddAll(this.searchAfter, list); return this; } /** * API name: {@code search_after} * * Adds one or more values to searchAfter. */ public final Builder searchAfter(String value, String... values) { this.searchAfter = _listAdd(this.searchAfter, value, values); return this; } /** * Search operation type * * API name: {@code search_type} */ public final Builder searchType(@Nullable SearchType value) { this.searchType = value; return this; } /** * If true, returns sequence number and primary term of the last modification of * each hit. See Optimistic concurrency control. * * API name: {@code seq_no_primary_term} */ public final Builder seqNoPrimaryTerm(@Nullable Boolean value) { this.seqNoPrimaryTerm = value; return this; } /** * The number of hits to return. By default, you cannot page through more than * 10,000 hits using the from and size parameters. To page through more hits, * use the search_after parameter. * * API name: {@code size} */ public final Builder size(@Nullable Integer value) { this.size = value; return this; } /** * API name: {@code slice} */ public final Builder slice(@Nullable SlicedScroll value) { this.slice = value; return this; } /** * API name: {@code slice} */ public final Builder slice(Function> fn) { return this.slice(fn.apply(new SlicedScroll.Builder()).build()); } /** * API name: {@code sort} * * Adds all elements of list to sort. */ public final Builder sort(List list) { this.sort = _listAddAll(this.sort, list); return this; } /** * API name: {@code sort} * * Adds one or more values to sort. */ public final Builder sort(SortOptions value, SortOptions... values) { this.sort = _listAdd(this.sort, value, values); return this; } /** * API name: {@code sort} * * Adds a value to sort using a builder lambda. */ public final Builder sort(Function> fn) { return sort(fn.apply(new SortOptions.Builder()).build()); } /** * Stats groups to associate with the search. Each group maintains a statistics * aggregation for its associated searches. You can retrieve these stats using * the indices stats API. * * API name: {@code stats} * * Adds all elements of list to stats. */ public final Builder stats(List list) { this.stats = _listAddAll(this.stats, list); return this; } /** * Stats groups to associate with the search. Each group maintains a statistics * aggregation for its associated searches. You can retrieve these stats using * the indices stats API. * * API name: {@code stats} * * Adds one or more values to stats. */ public final Builder stats(String value, String... values) { this.stats = _listAdd(this.stats, value, values); return this; } /** * List of stored fields to return as part of a hit. If no fields are specified, * no stored fields are included in the response. If this field is specified, * the _source parameter defaults to false. You can pass _source: true to return * both source fields and stored fields in the search response. * * API name: {@code stored_fields} * * Adds all elements of list to storedFields. */ public final Builder storedFields(List list) { this.storedFields = _listAddAll(this.storedFields, list); return this; } /** * List of stored fields to return as part of a hit. If no fields are specified, * no stored fields are included in the response. If this field is specified, * the _source parameter defaults to false. You can pass _source: true to return * both source fields and stored fields in the search response. * * API name: {@code stored_fields} * * Adds one or more values to storedFields. */ public final Builder storedFields(String value, String... values) { this.storedFields = _listAdd(this.storedFields, value, values); return this; } /** * API name: {@code suggest} */ public final Builder suggest(@Nullable Suggester value) { this.suggest = value; return this; } /** * API name: {@code suggest} */ public final Builder suggest(Function> fn) { return this.suggest(fn.apply(new Suggester.Builder()).build()); } /** * Maximum number of documents to collect for each shard. If a query reaches * this limit, Elasticsearch terminates the query early. Elasticsearch collects * documents before sorting. Defaults to 0, which does not terminate query * execution early. * * API name: {@code terminate_after} */ public final Builder terminateAfter(@Nullable Long value) { this.terminateAfter = value; return this; } /** * Specifies the period of time to wait for a response from each shard. If no * response is received before the timeout expires, the request fails and * returns an error. Defaults to no timeout. * * API name: {@code timeout} */ public final Builder timeout(@Nullable String value) { this.timeout = value; return this; } /** * If true, calculate and return document scores, even if the scores are not * used for sorting. * * API name: {@code track_scores} */ public final Builder trackScores(@Nullable Boolean value) { this.trackScores = value; return this; } /** * Number of hits matching the query to count accurately. If true, the exact * number of hits is returned at the cost of some performance. If false, the * response does not include the total number of hits matching the query. * Defaults to 10,000 hits. * * API name: {@code track_total_hits} */ public final Builder trackTotalHits(@Nullable TrackHits value) { this.trackTotalHits = value; return this; } /** * Number of hits matching the query to count accurately. If true, the exact * number of hits is returned at the cost of some performance. If false, the * response does not include the total number of hits matching the query. * Defaults to 10,000 hits. * * API name: {@code track_total_hits} */ public final Builder trackTotalHits(Function> fn) { return this.trackTotalHits(fn.apply(new TrackHits.Builder()).build()); } /** * If true, returns document version as part of a hit. * * API name: {@code version} */ public final Builder version(@Nullable Boolean value) { this.version = value; return this; } /** * Specify the time that the request should block waiting for the final response * * API name: {@code wait_for_completion_timeout} */ public final Builder waitForCompletionTimeout(@Nullable Time value) { this.waitForCompletionTimeout = value; return this; } /** * Specify the time that the request should block waiting for the final response * * API name: {@code wait_for_completion_timeout} */ public final Builder waitForCompletionTimeout(Function> fn) { return this.waitForCompletionTimeout(fn.apply(new Time.Builder()).build()); } @Override protected Builder self() { return this; } /** * Builds a {@link SubmitRequest}. * * @throws NullPointerException * if some of the required fields are null. */ public SubmitRequest build() { _checkSingleUse(); return new SubmitRequest(this); } } // --------------------------------------------------------------------------------------------- /** * Json deserializer for {@link SubmitRequest} */ public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy(Builder::new, SubmitRequest::setupSubmitRequestDeserializer); protected static void setupSubmitRequestDeserializer(ObjectDeserializer op) { op.add(Builder::source, SourceConfig._DESERIALIZER, "_source"); op.add(Builder::aggregations, JsonpDeserializer.stringMapDeserializer(Aggregation._DESERIALIZER), "aggregations", "aggs"); op.add(Builder::collapse, FieldCollapse._DESERIALIZER, "collapse"); op.add(Builder::docvalueFields, JsonpDeserializer.arrayDeserializer(FieldAndFormat._DESERIALIZER), "docvalue_fields"); op.add(Builder::explain, JsonpDeserializer.booleanDeserializer(), "explain"); op.add(Builder::fields, JsonpDeserializer.arrayDeserializer(FieldAndFormat._DESERIALIZER), "fields"); op.add(Builder::from, JsonpDeserializer.integerDeserializer(), "from"); op.add(Builder::highlight, Highlight._DESERIALIZER, "highlight"); op.add(Builder::indicesBoost, JsonpDeserializer.arrayDeserializer( JsonpDeserializer.stringMapDeserializer(JsonpDeserializer.doubleDeserializer())), "indices_boost"); op.add(Builder::minScore, JsonpDeserializer.doubleDeserializer(), "min_score"); op.add(Builder::pit, PointInTimeReference._DESERIALIZER, "pit"); op.add(Builder::postFilter, Query._DESERIALIZER, "post_filter"); op.add(Builder::profile, JsonpDeserializer.booleanDeserializer(), "profile"); op.add(Builder::query, Query._DESERIALIZER, "query"); op.add(Builder::rescore, JsonpDeserializer.arrayDeserializer(Rescore._DESERIALIZER), "rescore"); op.add(Builder::runtimeMappings, JsonpDeserializer.stringMapDeserializer( JsonpDeserializer.arrayDeserializer(RuntimeField._DESERIALIZER)), "runtime_mappings"); op.add(Builder::scriptFields, JsonpDeserializer.stringMapDeserializer(ScriptField._DESERIALIZER), "script_fields"); op.add(Builder::searchAfter, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "search_after"); op.add(Builder::seqNoPrimaryTerm, JsonpDeserializer.booleanDeserializer(), "seq_no_primary_term"); op.add(Builder::size, JsonpDeserializer.integerDeserializer(), "size"); op.add(Builder::slice, SlicedScroll._DESERIALIZER, "slice"); op.add(Builder::sort, JsonpDeserializer.arrayDeserializer(SortOptions._DESERIALIZER), "sort"); op.add(Builder::stats, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "stats"); op.add(Builder::storedFields, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "stored_fields"); op.add(Builder::suggest, Suggester._DESERIALIZER, "suggest"); op.add(Builder::terminateAfter, JsonpDeserializer.longDeserializer(), "terminate_after"); op.add(Builder::timeout, JsonpDeserializer.stringDeserializer(), "timeout"); op.add(Builder::trackScores, JsonpDeserializer.booleanDeserializer(), "track_scores"); op.add(Builder::trackTotalHits, TrackHits._DESERIALIZER, "track_total_hits"); op.add(Builder::version, JsonpDeserializer.booleanDeserializer(), "version"); } // --------------------------------------------------------------------------------------------- /** * Endpoint "{@code async_search.submit}". */ public static final SimpleEndpoint _ENDPOINT = new SimpleEndpoint<>("es/async_search.submit", // Request method request -> { return "POST"; }, // Request path request -> { final int _index = 1 << 0; int propsSet = 0; if (ApiTypeHelper.isDefined(request.index())) propsSet |= _index; if (propsSet == 0) { StringBuilder buf = new StringBuilder(); buf.append("/_async_search"); return buf.toString(); } if (propsSet == (_index)) { StringBuilder buf = new StringBuilder(); buf.append("/"); SimpleEndpoint.pathEncode(request.index.stream().map(v -> v).collect(Collectors.joining(",")), buf); buf.append("/_async_search"); return buf.toString(); } throw SimpleEndpoint.noPathTemplateFound("path"); }, // Request parameters request -> { Map params = new HashMap<>(); params.put("typed_keys", "true"); if (request.df != null) { params.put("df", request.df); } if (request.preFilterShardSize != null) { params.put("pre_filter_shard_size", String.valueOf(request.preFilterShardSize)); } if (request.minCompatibleShardNode != null) { params.put("min_compatible_shard_node", request.minCompatibleShardNode); } if (request.lenient != null) { params.put("lenient", String.valueOf(request.lenient)); } if (request.routing != null) { params.put("routing", request.routing); } if (request.ignoreUnavailable != null) { params.put("ignore_unavailable", String.valueOf(request.ignoreUnavailable)); } if (request.allowNoIndices != null) { params.put("allow_no_indices", String.valueOf(request.allowNoIndices)); } if (request.analyzer != null) { params.put("analyzer", request.analyzer); } if (request.ignoreThrottled != null) { params.put("ignore_throttled", String.valueOf(request.ignoreThrottled)); } if (request.keepOnCompletion != null) { params.put("keep_on_completion", String.valueOf(request.keepOnCompletion)); } if (request.maxConcurrentShardRequests != null) { params.put("max_concurrent_shard_requests", String.valueOf(request.maxConcurrentShardRequests)); } if (request.allowPartialSearchResults != null) { params.put("allow_partial_search_results", String.valueOf(request.allowPartialSearchResults)); } if (ApiTypeHelper.isDefined(request.expandWildcards)) { params.put("expand_wildcards", request.expandWildcards.stream().map(v -> v.jsonValue()).collect(Collectors.joining(","))); } if (request.preference != null) { params.put("preference", request.preference); } if (request.analyzeWildcard != null) { params.put("analyze_wildcard", String.valueOf(request.analyzeWildcard)); } if (request.scroll != null) { params.put("scroll", request.scroll._toJsonString()); } if (request.waitForCompletionTimeout != null) { params.put("wait_for_completion_timeout", request.waitForCompletionTimeout._toJsonString()); } if (request.searchType != null) { params.put("search_type", request.searchType.jsonValue()); } if (request.ccsMinimizeRoundtrips != null) { params.put("ccs_minimize_roundtrips", String.valueOf(request.ccsMinimizeRoundtrips)); } if (request.q != null) { params.put("q", request.q); } if (request.defaultOperator != null) { params.put("default_operator", request.defaultOperator.jsonValue()); } if (request.keepAlive != null) { params.put("keep_alive", request.keepAlive._toJsonString()); } if (request.requestCache != null) { params.put("request_cache", String.valueOf(request.requestCache)); } if (request.batchedReduceSize != null) { params.put("batched_reduce_size", String.valueOf(request.batchedReduceSize)); } return params; }, SimpleEndpoint.emptyMap(), true, SubmitResponse._DESERIALIZER); /** * Create an "{@code async_search.submit}" endpoint. */ public static Endpoint, ErrorResponse> createSubmitEndpoint( JsonpDeserializer tDocumentDeserializer) { return _ENDPOINT .withResponseDeserializer(SubmitResponse.createSubmitResponseDeserializer(tDocumentDeserializer)); } }
* API name: {@code script_fields} */ public final Map scriptFields() { return this.scriptFields; } /** * API name: {@code scroll} */ @Nullable public final Time scroll() { return this.scroll; } /** * API name: {@code search_after} */ public final List searchAfter() { return this.searchAfter; } /** * Search operation type * * API name: {@code search_type} */ @Nullable public final SearchType searchType() { return this.searchType; } /** * If true, returns sequence number and primary term of the last modification of * each hit. See Optimistic concurrency control. * * API name: {@code seq_no_primary_term} */ @Nullable public final Boolean seqNoPrimaryTerm() { return this.seqNoPrimaryTerm; } /** * The number of hits to return. By default, you cannot page through more than * 10,000 hits using the from and size parameters. To page through more hits, * use the search_after parameter. * * API name: {@code size} */ @Nullable public final Integer size() { return this.size; } /** * API name: {@code slice} */ @Nullable public final SlicedScroll slice() { return this.slice; } /** * API name: {@code sort} */ public final List sort() { return this.sort; } /** * Stats groups to associate with the search. Each group maintains a statistics * aggregation for its associated searches. You can retrieve these stats using * the indices stats API. * * API name: {@code stats} */ public final List stats() { return this.stats; } /** * List of stored fields to return as part of a hit. If no fields are specified, * no stored fields are included in the response. If this field is specified, * the _source parameter defaults to false. You can pass _source: true to return * both source fields and stored fields in the search response. * * API name: {@code stored_fields} */ public final List storedFields() { return this.storedFields; } /** * API name: {@code suggest} */ @Nullable public final Suggester suggest() { return this.suggest; } /** * Maximum number of documents to collect for each shard. If a query reaches * this limit, Elasticsearch terminates the query early. Elasticsearch collects * documents before sorting. Defaults to 0, which does not terminate query * execution early. * * API name: {@code terminate_after} */ @Nullable public final Long terminateAfter() { return this.terminateAfter; } /** * Specifies the period of time to wait for a response from each shard. If no * response is received before the timeout expires, the request fails and * returns an error. Defaults to no timeout. * * API name: {@code timeout} */ @Nullable public final String timeout() { return this.timeout; } /** * If true, calculate and return document scores, even if the scores are not * used for sorting. * * API name: {@code track_scores} */ @Nullable public final Boolean trackScores() { return this.trackScores; } /** * Number of hits matching the query to count accurately. If true, the exact * number of hits is returned at the cost of some performance. If false, the * response does not include the total number of hits matching the query. * Defaults to 10,000 hits. * * API name: {@code track_total_hits} */ @Nullable public final TrackHits trackTotalHits() { return this.trackTotalHits; } /** * If true, returns document version as part of a hit. * * API name: {@code version} */ @Nullable public final Boolean version() { return this.version; } /** * Specify the time that the request should block waiting for the final response * * API name: {@code wait_for_completion_timeout} */ @Nullable public final Time waitForCompletionTimeout() { return this.waitForCompletionTimeout; } /** * 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.source != null) { generator.writeKey("_source"); this.source.serialize(generator, mapper); } if (ApiTypeHelper.isDefined(this.aggregations)) { generator.writeKey("aggregations"); generator.writeStartObject(); for (Map.Entry item0 : this.aggregations.entrySet()) { generator.writeKey(item0.getKey()); item0.getValue().serialize(generator, mapper); } generator.writeEnd(); } if (this.collapse != null) { generator.writeKey("collapse"); this.collapse.serialize(generator, mapper); } if (ApiTypeHelper.isDefined(this.docvalueFields)) { generator.writeKey("docvalue_fields"); generator.writeStartArray(); for (FieldAndFormat item0 : this.docvalueFields) { item0.serialize(generator, mapper); } generator.writeEnd(); } if (this.explain != null) { generator.writeKey("explain"); generator.write(this.explain); } if (ApiTypeHelper.isDefined(this.fields)) { generator.writeKey("fields"); generator.writeStartArray(); for (FieldAndFormat item0 : this.fields) { item0.serialize(generator, mapper); } generator.writeEnd(); } if (this.from != null) { generator.writeKey("from"); generator.write(this.from); } if (this.highlight != null) { generator.writeKey("highlight"); this.highlight.serialize(generator, mapper); } if (ApiTypeHelper.isDefined(this.indicesBoost)) { generator.writeKey("indices_boost"); generator.writeStartArray(); for (Map item0 : this.indicesBoost) { generator.writeStartObject(); if (item0 != null) { for (Map.Entry item1 : item0.entrySet()) { generator.writeKey(item1.getKey()); generator.write(item1.getValue()); } } generator.writeEnd(); } generator.writeEnd(); } if (this.minScore != null) { generator.writeKey("min_score"); generator.write(this.minScore); } if (this.pit != null) { generator.writeKey("pit"); this.pit.serialize(generator, mapper); } if (this.postFilter != null) { generator.writeKey("post_filter"); this.postFilter.serialize(generator, mapper); } if (this.profile != null) { generator.writeKey("profile"); generator.write(this.profile); } if (this.query != null) { generator.writeKey("query"); this.query.serialize(generator, mapper); } if (ApiTypeHelper.isDefined(this.rescore)) { generator.writeKey("rescore"); generator.writeStartArray(); for (Rescore item0 : this.rescore) { item0.serialize(generator, mapper); } generator.writeEnd(); } if (ApiTypeHelper.isDefined(this.runtimeMappings)) { generator.writeKey("runtime_mappings"); generator.writeStartObject(); for (Map.Entry> item0 : this.runtimeMappings.entrySet()) { generator.writeKey(item0.getKey()); generator.writeStartArray(); if (item0.getValue() != null) { for (RuntimeField item1 : item0.getValue()) { item1.serialize(generator, mapper); } } generator.writeEnd(); } generator.writeEnd(); } if (ApiTypeHelper.isDefined(this.scriptFields)) { generator.writeKey("script_fields"); generator.writeStartObject(); for (Map.Entry item0 : this.scriptFields.entrySet()) { generator.writeKey(item0.getKey()); item0.getValue().serialize(generator, mapper); } generator.writeEnd(); } if (ApiTypeHelper.isDefined(this.searchAfter)) { generator.writeKey("search_after"); generator.writeStartArray(); for (String item0 : this.searchAfter) { generator.write(item0); } generator.writeEnd(); } if (this.seqNoPrimaryTerm != null) { generator.writeKey("seq_no_primary_term"); generator.write(this.seqNoPrimaryTerm); } if (this.size != null) { generator.writeKey("size"); generator.write(this.size); } if (this.slice != null) { generator.writeKey("slice"); this.slice.serialize(generator, mapper); } if (ApiTypeHelper.isDefined(this.sort)) { generator.writeKey("sort"); generator.writeStartArray(); for (SortOptions item0 : this.sort) { item0.serialize(generator, mapper); } generator.writeEnd(); } if (ApiTypeHelper.isDefined(this.stats)) { generator.writeKey("stats"); generator.writeStartArray(); for (String item0 : this.stats) { generator.write(item0); } generator.writeEnd(); } if (ApiTypeHelper.isDefined(this.storedFields)) { generator.writeKey("stored_fields"); generator.writeStartArray(); for (String item0 : this.storedFields) { generator.write(item0); } generator.writeEnd(); } if (this.suggest != null) { generator.writeKey("suggest"); this.suggest.serialize(generator, mapper); } if (this.terminateAfter != null) { generator.writeKey("terminate_after"); generator.write(this.terminateAfter); } if (this.timeout != null) { generator.writeKey("timeout"); generator.write(this.timeout); } if (this.trackScores != null) { generator.writeKey("track_scores"); generator.write(this.trackScores); } if (this.trackTotalHits != null) { generator.writeKey("track_total_hits"); this.trackTotalHits.serialize(generator, mapper); } if (this.version != null) { generator.writeKey("version"); generator.write(this.version); } } // --------------------------------------------------------------------------------------------- /** * Builder for {@link SubmitRequest}. */ public static class Builder extends WithJsonObjectBuilderBase implements ObjectBuilder { @Nullable private SourceConfig source; @Nullable private Map aggregations; @Nullable private Boolean allowNoIndices; @Nullable private Boolean allowPartialSearchResults; @Nullable private Boolean analyzeWildcard; @Nullable private String analyzer; @Nullable private Long batchedReduceSize; @Nullable private Boolean ccsMinimizeRoundtrips; @Nullable private FieldCollapse collapse; @Nullable private Operator defaultOperator; @Nullable private String df; @Nullable private List docvalueFields; @Nullable private List expandWildcards; @Nullable private Boolean explain; @Nullable private List fields; @Nullable private Integer from; @Nullable private Highlight highlight; @Nullable private Boolean ignoreThrottled; @Nullable private Boolean ignoreUnavailable; @Nullable private List index; @Nullable private List> indicesBoost; @Nullable private Time keepAlive; @Nullable private Boolean keepOnCompletion; @Nullable private Boolean lenient; @Nullable private Long maxConcurrentShardRequests; @Nullable private String minCompatibleShardNode; @Nullable private Double minScore; @Nullable private PointInTimeReference pit; @Nullable private Query postFilter; @Nullable private Long preFilterShardSize; @Nullable private String preference; @Nullable private Boolean profile; @Nullable private String q; @Nullable private Query query; @Nullable private Boolean requestCache; @Nullable private List rescore; @Nullable private String routing; @Nullable private Map> runtimeMappings; @Nullable private Map scriptFields; @Nullable private Time scroll; @Nullable private List searchAfter; @Nullable private SearchType searchType; @Nullable private Boolean seqNoPrimaryTerm; @Nullable private Integer size; @Nullable private SlicedScroll slice; @Nullable private List sort; @Nullable private List stats; @Nullable private List storedFields; @Nullable private Suggester suggest; @Nullable private Long terminateAfter; @Nullable private String timeout; @Nullable private Boolean trackScores; @Nullable private TrackHits trackTotalHits; @Nullable private Boolean version; @Nullable private Time waitForCompletionTimeout; /** * Indicates which source fields are returned for matching documents. These * fields are returned in the hits._source property of the search response. * * API name: {@code _source} */ public final Builder source(@Nullable SourceConfig value) { this.source = value; return this; } /** * Indicates which source fields are returned for matching documents. These * fields are returned in the hits._source property of the search response. * * API name: {@code _source} */ public final Builder source(Function> fn) { return this.source(fn.apply(new SourceConfig.Builder()).build()); } /** * API name: {@code aggregations} * * Adds all entries of map to aggregations. */ public final Builder aggregations(Map map) { this.aggregations = _mapPutAll(this.aggregations, map); return this; } /** * API name: {@code aggregations} * * Adds an entry to aggregations. */ public final Builder aggregations(String key, Aggregation value) { this.aggregations = _mapPut(this.aggregations, key, value); return this; } /** * API name: {@code aggregations} * * Adds an entry to aggregations using a builder lambda. */ public final Builder aggregations(String key, Function> fn) { return aggregations(key, fn.apply(new Aggregation.Builder()).build()); } /** * Whether to ignore if a wildcard indices expression resolves into no concrete * indices. (This includes _all string or when no indices have been * specified) * * API name: {@code allow_no_indices} */ public final Builder allowNoIndices(@Nullable Boolean value) { this.allowNoIndices = value; return this; } /** * Indicate if an error should be returned if there is a partial search failure * or timeout * * API name: {@code allow_partial_search_results} */ public final Builder allowPartialSearchResults(@Nullable Boolean value) { this.allowPartialSearchResults = value; return this; } /** * Specify whether wildcard and prefix queries should be analyzed (default: * false) * * API name: {@code analyze_wildcard} */ public final Builder analyzeWildcard(@Nullable Boolean value) { this.analyzeWildcard = value; return this; } /** * The analyzer to use for the query string * * API name: {@code analyzer} */ public final Builder analyzer(@Nullable String value) { this.analyzer = value; return this; } /** * The number of shard results that should be reduced at once on the * coordinating node. This value should be used as the granularity at which * progress results will be made available. * * API name: {@code batched_reduce_size} */ public final Builder batchedReduceSize(@Nullable Long value) { this.batchedReduceSize = value; return this; } /** * API name: {@code ccs_minimize_roundtrips} */ public final Builder ccsMinimizeRoundtrips(@Nullable Boolean value) { this.ccsMinimizeRoundtrips = value; return this; } /** * API name: {@code collapse} */ public final Builder collapse(@Nullable FieldCollapse value) { this.collapse = value; return this; } /** * API name: {@code collapse} */ public final Builder collapse(Function> fn) { return this.collapse(fn.apply(new FieldCollapse.Builder()).build()); } /** * The default operator for query string query (AND or OR) * * API name: {@code default_operator} */ public final Builder defaultOperator(@Nullable Operator value) { this.defaultOperator = value; return this; } /** * The field to use as default where no field prefix is given in the query * string * * API name: {@code df} */ public final Builder df(@Nullable String value) { this.df = value; return this; } /** * Array of wildcard (*) patterns. The request returns doc values for field * names matching these patterns in the hits.fields property of the response. * * API name: {@code docvalue_fields} * * Adds all elements of list to docvalueFields. */ public final Builder docvalueFields(List list) { this.docvalueFields = _listAddAll(this.docvalueFields, list); return this; } /** * Array of wildcard (*) patterns. The request returns doc values for field * names matching these patterns in the hits.fields property of the response. * * API name: {@code docvalue_fields} * * Adds one or more values to docvalueFields. */ public final Builder docvalueFields(FieldAndFormat value, FieldAndFormat... values) { this.docvalueFields = _listAdd(this.docvalueFields, value, values); return this; } /** * Array of wildcard (*) patterns. The request returns doc values for field * names matching these patterns in the hits.fields property of the response. * * API name: {@code docvalue_fields} * * Adds a value to docvalueFields using a builder lambda. */ public final Builder docvalueFields(Function> fn) { return docvalueFields(fn.apply(new FieldAndFormat.Builder()).build()); } /** * Whether to expand wildcard expression to concrete indices that are open, * closed or both. * * API name: {@code expand_wildcards} * * Adds all elements of list to expandWildcards. */ public final Builder expandWildcards(List list) { this.expandWildcards = _listAddAll(this.expandWildcards, list); return this; } /** * Whether to expand wildcard expression to concrete indices that are open, * closed or both. * * API name: {@code expand_wildcards} * * Adds one or more values to expandWildcards. */ public final Builder expandWildcards(ExpandWildcard value, ExpandWildcard... values) { this.expandWildcards = _listAdd(this.expandWildcards, value, values); return this; } /** * If true, returns detailed information about score computation as part of a * hit. * * API name: {@code explain} */ public final Builder explain(@Nullable Boolean value) { this.explain = value; return this; } /** * Array of wildcard (*) patterns. The request returns values for field names * matching these patterns in the hits.fields property of the response. * * API name: {@code fields} * * Adds all elements of list to fields. */ public final Builder fields(List list) { this.fields = _listAddAll(this.fields, list); return this; } /** * Array of wildcard (*) patterns. The request returns values for field names * matching these patterns in the hits.fields property of the response. * * API name: {@code fields} * * Adds one or more values to fields. */ public final Builder fields(FieldAndFormat value, FieldAndFormat... values) { this.fields = _listAdd(this.fields, value, values); return this; } /** * Array of wildcard (*) patterns. The request returns values for field names * matching these patterns in the hits.fields property of the response. * * API name: {@code fields} * * Adds a value to fields using a builder lambda. */ public final Builder fields(Function> fn) { return fields(fn.apply(new FieldAndFormat.Builder()).build()); } /** * Starting document offset. By default, you cannot page through more than * 10,000 hits using the from and size parameters. To page through more hits, * use the search_after parameter. * * API name: {@code from} */ public final Builder from(@Nullable Integer value) { this.from = value; return this; } /** * API name: {@code highlight} */ public final Builder highlight(@Nullable Highlight value) { this.highlight = value; return this; } /** * API name: {@code highlight} */ public final Builder highlight(Function> fn) { return this.highlight(fn.apply(new Highlight.Builder()).build()); } /** * Whether specified concrete, expanded or aliased indices should be ignored * when throttled * * API name: {@code ignore_throttled} */ public final Builder ignoreThrottled(@Nullable Boolean value) { this.ignoreThrottled = value; return this; } /** * Whether specified concrete indices should be ignored when unavailable * (missing or closed) * * API name: {@code ignore_unavailable} */ public final Builder ignoreUnavailable(@Nullable Boolean value) { this.ignoreUnavailable = value; return this; } /** * A comma-separated list of index names to search; use _all or * empty string to perform the operation on all indices * * API name: {@code index} * * Adds all elements of list to index. */ public final Builder index(List list) { this.index = _listAddAll(this.index, list); return this; } /** * A comma-separated list of index names to search; use _all or * empty string to perform the operation on all indices * * API name: {@code index} * * Adds one or more values to index. */ public final Builder index(String value, String... values) { this.index = _listAdd(this.index, value, values); return this; } /** * Boosts the _score of documents from specified indices. * * API name: {@code indices_boost} * * Adds all elements of list to indicesBoost. */ public final Builder indicesBoost(List> list) { this.indicesBoost = _listAddAll(this.indicesBoost, list); return this; } /** * Boosts the _score of documents from specified indices. * * API name: {@code indices_boost} * * Adds one or more values to indicesBoost. */ public final Builder indicesBoost(Map value, Map... values) { this.indicesBoost = _listAdd(this.indicesBoost, value, values); return this; } /** * Update the time interval in which the results (partial or final) for this * search will be available * * API name: {@code keep_alive} */ public final Builder keepAlive(@Nullable Time value) { this.keepAlive = value; return this; } /** * Update the time interval in which the results (partial or final) for this * search will be available * * API name: {@code keep_alive} */ public final Builder keepAlive(Function> fn) { return this.keepAlive(fn.apply(new Time.Builder()).build()); } /** * Control whether the response should be stored in the cluster if it completed * within the provided [wait_for_completion] time (default: false) * * API name: {@code keep_on_completion} */ public final Builder keepOnCompletion(@Nullable Boolean value) { this.keepOnCompletion = value; return this; } /** * Specify whether format-based query failures (such as providing text to a * numeric field) should be ignored * * API name: {@code lenient} */ public final Builder lenient(@Nullable Boolean value) { this.lenient = value; return this; } /** * The number of concurrent shard requests per node this search executes * concurrently. This value should be used to limit the impact of the search on * the cluster in order to limit the number of concurrent shard requests * * API name: {@code max_concurrent_shard_requests} */ public final Builder maxConcurrentShardRequests(@Nullable Long value) { this.maxConcurrentShardRequests = value; return this; } /** * API name: {@code min_compatible_shard_node} */ public final Builder minCompatibleShardNode(@Nullable String value) { this.minCompatibleShardNode = value; return this; } /** * Minimum _score for matching documents. Documents with a lower _score are not * included in the search results. * * API name: {@code min_score} */ public final Builder minScore(@Nullable Double value) { this.minScore = value; return this; } /** * Limits the search to a point in time (PIT). If you provide a PIT, you cannot * specify an <index> in the request path. * * API name: {@code pit} */ public final Builder pit(@Nullable PointInTimeReference value) { this.pit = value; return this; } /** * Limits the search to a point in time (PIT). If you provide a PIT, you cannot * specify an <index> in the request path. * * API name: {@code pit} */ public final Builder pit(Function> fn) { return this.pit(fn.apply(new PointInTimeReference.Builder()).build()); } /** * API name: {@code post_filter} */ public final Builder postFilter(@Nullable Query value) { this.postFilter = value; return this; } /** * API name: {@code post_filter} */ public final Builder postFilter(Function> fn) { return this.postFilter(fn.apply(new Query.Builder()).build()); } /** * API name: {@code pre_filter_shard_size} */ public final Builder preFilterShardSize(@Nullable Long value) { this.preFilterShardSize = value; return this; } /** * Specify the node or shard the operation should be performed on (default: * random) * * API name: {@code preference} */ public final Builder preference(@Nullable String value) { this.preference = value; return this; } /** * API name: {@code profile} */ public final Builder profile(@Nullable Boolean value) { this.profile = value; return this; } /** * Query in the Lucene query string syntax * * API name: {@code q} */ public final Builder q(@Nullable String value) { this.q = value; return this; } /** * Defines the search definition using the Query DSL. * * API name: {@code query} */ public final Builder query(@Nullable Query value) { this.query = value; return this; } /** * Defines the search definition using the Query DSL. * * API name: {@code query} */ public final Builder query(Function> fn) { return this.query(fn.apply(new Query.Builder()).build()); } /** * Specify if request cache should be used for this request or not, defaults to * true * * API name: {@code request_cache} */ public final Builder requestCache(@Nullable Boolean value) { this.requestCache = value; return this; } /** * API name: {@code rescore} * * Adds all elements of list to rescore. */ public final Builder rescore(List list) { this.rescore = _listAddAll(this.rescore, list); return this; } /** * API name: {@code rescore} * * Adds one or more values to rescore. */ public final Builder rescore(Rescore value, Rescore... values) { this.rescore = _listAdd(this.rescore, value, values); return this; } /** * API name: {@code rescore} * * Adds a value to rescore using a builder lambda. */ public final Builder rescore(Function> fn) { return rescore(fn.apply(new Rescore.Builder()).build()); } /** * A comma-separated list of specific routing values * * API name: {@code routing} */ public final Builder routing(@Nullable String value) { this.routing = value; return this; } /** * Defines one or more runtime fields in the search request. These fields take * precedence over mapped fields with the same name. * * API name: {@code runtime_mappings} * * Adds all entries of map to runtimeMappings. */ public final Builder runtimeMappings(Map> map) { this.runtimeMappings = _mapPutAll(this.runtimeMappings, map); return this; } /** * Defines one or more runtime fields in the search request. These fields take * precedence over mapped fields with the same name. * * API name: {@code runtime_mappings} * * Adds an entry to runtimeMappings. */ public final Builder runtimeMappings(String key, List value) { this.runtimeMappings = _mapPut(this.runtimeMappings, key, value); return this; } /** * Retrieve a script evaluation (based on different fields) for each hit. * * API name: {@code script_fields} * * Adds all entries of map to scriptFields. */ public final Builder scriptFields(Map map) { this.scriptFields = _mapPutAll(this.scriptFields, map); return this; } /** * Retrieve a script evaluation (based on different fields) for each hit. * * API name: {@code script_fields} * * Adds an entry to scriptFields. */ public final Builder scriptFields(String key, ScriptField value) { this.scriptFields = _mapPut(this.scriptFields, key, value); return this; } /** * Retrieve a script evaluation (based on different fields) for each hit. * * API name: {@code script_fields} * * Adds an entry to scriptFields using a builder lambda. */ public final Builder scriptFields(String key, Function> fn) { return scriptFields(key, fn.apply(new ScriptField.Builder()).build()); } /** * API name: {@code scroll} */ public final Builder scroll(@Nullable Time value) { this.scroll = value; return this; } /** * API name: {@code scroll} */ public final Builder scroll(Function> fn) { return this.scroll(fn.apply(new Time.Builder()).build()); } /** * API name: {@code search_after} * * Adds all elements of list to searchAfter. */ public final Builder searchAfter(List list) { this.searchAfter = _listAddAll(this.searchAfter, list); return this; } /** * API name: {@code search_after} * * Adds one or more values to searchAfter. */ public final Builder searchAfter(String value, String... values) { this.searchAfter = _listAdd(this.searchAfter, value, values); return this; } /** * Search operation type * * API name: {@code search_type} */ public final Builder searchType(@Nullable SearchType value) { this.searchType = value; return this; } /** * If true, returns sequence number and primary term of the last modification of * each hit. See Optimistic concurrency control. * * API name: {@code seq_no_primary_term} */ public final Builder seqNoPrimaryTerm(@Nullable Boolean value) { this.seqNoPrimaryTerm = value; return this; } /** * The number of hits to return. By default, you cannot page through more than * 10,000 hits using the from and size parameters. To page through more hits, * use the search_after parameter. * * API name: {@code size} */ public final Builder size(@Nullable Integer value) { this.size = value; return this; } /** * API name: {@code slice} */ public final Builder slice(@Nullable SlicedScroll value) { this.slice = value; return this; } /** * API name: {@code slice} */ public final Builder slice(Function> fn) { return this.slice(fn.apply(new SlicedScroll.Builder()).build()); } /** * API name: {@code sort} * * Adds all elements of list to sort. */ public final Builder sort(List list) { this.sort = _listAddAll(this.sort, list); return this; } /** * API name: {@code sort} * * Adds one or more values to sort. */ public final Builder sort(SortOptions value, SortOptions... values) { this.sort = _listAdd(this.sort, value, values); return this; } /** * API name: {@code sort} * * Adds a value to sort using a builder lambda. */ public final Builder sort(Function> fn) { return sort(fn.apply(new SortOptions.Builder()).build()); } /** * Stats groups to associate with the search. Each group maintains a statistics * aggregation for its associated searches. You can retrieve these stats using * the indices stats API. * * API name: {@code stats} * * Adds all elements of list to stats. */ public final Builder stats(List list) { this.stats = _listAddAll(this.stats, list); return this; } /** * Stats groups to associate with the search. Each group maintains a statistics * aggregation for its associated searches. You can retrieve these stats using * the indices stats API. * * API name: {@code stats} * * Adds one or more values to stats. */ public final Builder stats(String value, String... values) { this.stats = _listAdd(this.stats, value, values); return this; } /** * List of stored fields to return as part of a hit. If no fields are specified, * no stored fields are included in the response. If this field is specified, * the _source parameter defaults to false. You can pass _source: true to return * both source fields and stored fields in the search response. * * API name: {@code stored_fields} * * Adds all elements of list to storedFields. */ public final Builder storedFields(List list) { this.storedFields = _listAddAll(this.storedFields, list); return this; } /** * List of stored fields to return as part of a hit. If no fields are specified, * no stored fields are included in the response. If this field is specified, * the _source parameter defaults to false. You can pass _source: true to return * both source fields and stored fields in the search response. * * API name: {@code stored_fields} * * Adds one or more values to storedFields. */ public final Builder storedFields(String value, String... values) { this.storedFields = _listAdd(this.storedFields, value, values); return this; } /** * API name: {@code suggest} */ public final Builder suggest(@Nullable Suggester value) { this.suggest = value; return this; } /** * API name: {@code suggest} */ public final Builder suggest(Function> fn) { return this.suggest(fn.apply(new Suggester.Builder()).build()); } /** * Maximum number of documents to collect for each shard. If a query reaches * this limit, Elasticsearch terminates the query early. Elasticsearch collects * documents before sorting. Defaults to 0, which does not terminate query * execution early. * * API name: {@code terminate_after} */ public final Builder terminateAfter(@Nullable Long value) { this.terminateAfter = value; return this; } /** * Specifies the period of time to wait for a response from each shard. If no * response is received before the timeout expires, the request fails and * returns an error. Defaults to no timeout. * * API name: {@code timeout} */ public final Builder timeout(@Nullable String value) { this.timeout = value; return this; } /** * If true, calculate and return document scores, even if the scores are not * used for sorting. * * API name: {@code track_scores} */ public final Builder trackScores(@Nullable Boolean value) { this.trackScores = value; return this; } /** * Number of hits matching the query to count accurately. If true, the exact * number of hits is returned at the cost of some performance. If false, the * response does not include the total number of hits matching the query. * Defaults to 10,000 hits. * * API name: {@code track_total_hits} */ public final Builder trackTotalHits(@Nullable TrackHits value) { this.trackTotalHits = value; return this; } /** * Number of hits matching the query to count accurately. If true, the exact * number of hits is returned at the cost of some performance. If false, the * response does not include the total number of hits matching the query. * Defaults to 10,000 hits. * * API name: {@code track_total_hits} */ public final Builder trackTotalHits(Function> fn) { return this.trackTotalHits(fn.apply(new TrackHits.Builder()).build()); } /** * If true, returns document version as part of a hit. * * API name: {@code version} */ public final Builder version(@Nullable Boolean value) { this.version = value; return this; } /** * Specify the time that the request should block waiting for the final response * * API name: {@code wait_for_completion_timeout} */ public final Builder waitForCompletionTimeout(@Nullable Time value) { this.waitForCompletionTimeout = value; return this; } /** * Specify the time that the request should block waiting for the final response * * API name: {@code wait_for_completion_timeout} */ public final Builder waitForCompletionTimeout(Function> fn) { return this.waitForCompletionTimeout(fn.apply(new Time.Builder()).build()); } @Override protected Builder self() { return this; } /** * Builds a {@link SubmitRequest}. * * @throws NullPointerException * if some of the required fields are null. */ public SubmitRequest build() { _checkSingleUse(); return new SubmitRequest(this); } } // --------------------------------------------------------------------------------------------- /** * Json deserializer for {@link SubmitRequest} */ public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy(Builder::new, SubmitRequest::setupSubmitRequestDeserializer); protected static void setupSubmitRequestDeserializer(ObjectDeserializer op) { op.add(Builder::source, SourceConfig._DESERIALIZER, "_source"); op.add(Builder::aggregations, JsonpDeserializer.stringMapDeserializer(Aggregation._DESERIALIZER), "aggregations", "aggs"); op.add(Builder::collapse, FieldCollapse._DESERIALIZER, "collapse"); op.add(Builder::docvalueFields, JsonpDeserializer.arrayDeserializer(FieldAndFormat._DESERIALIZER), "docvalue_fields"); op.add(Builder::explain, JsonpDeserializer.booleanDeserializer(), "explain"); op.add(Builder::fields, JsonpDeserializer.arrayDeserializer(FieldAndFormat._DESERIALIZER), "fields"); op.add(Builder::from, JsonpDeserializer.integerDeserializer(), "from"); op.add(Builder::highlight, Highlight._DESERIALIZER, "highlight"); op.add(Builder::indicesBoost, JsonpDeserializer.arrayDeserializer( JsonpDeserializer.stringMapDeserializer(JsonpDeserializer.doubleDeserializer())), "indices_boost"); op.add(Builder::minScore, JsonpDeserializer.doubleDeserializer(), "min_score"); op.add(Builder::pit, PointInTimeReference._DESERIALIZER, "pit"); op.add(Builder::postFilter, Query._DESERIALIZER, "post_filter"); op.add(Builder::profile, JsonpDeserializer.booleanDeserializer(), "profile"); op.add(Builder::query, Query._DESERIALIZER, "query"); op.add(Builder::rescore, JsonpDeserializer.arrayDeserializer(Rescore._DESERIALIZER), "rescore"); op.add(Builder::runtimeMappings, JsonpDeserializer.stringMapDeserializer( JsonpDeserializer.arrayDeserializer(RuntimeField._DESERIALIZER)), "runtime_mappings"); op.add(Builder::scriptFields, JsonpDeserializer.stringMapDeserializer(ScriptField._DESERIALIZER), "script_fields"); op.add(Builder::searchAfter, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "search_after"); op.add(Builder::seqNoPrimaryTerm, JsonpDeserializer.booleanDeserializer(), "seq_no_primary_term"); op.add(Builder::size, JsonpDeserializer.integerDeserializer(), "size"); op.add(Builder::slice, SlicedScroll._DESERIALIZER, "slice"); op.add(Builder::sort, JsonpDeserializer.arrayDeserializer(SortOptions._DESERIALIZER), "sort"); op.add(Builder::stats, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "stats"); op.add(Builder::storedFields, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "stored_fields"); op.add(Builder::suggest, Suggester._DESERIALIZER, "suggest"); op.add(Builder::terminateAfter, JsonpDeserializer.longDeserializer(), "terminate_after"); op.add(Builder::timeout, JsonpDeserializer.stringDeserializer(), "timeout"); op.add(Builder::trackScores, JsonpDeserializer.booleanDeserializer(), "track_scores"); op.add(Builder::trackTotalHits, TrackHits._DESERIALIZER, "track_total_hits"); op.add(Builder::version, JsonpDeserializer.booleanDeserializer(), "version"); } // --------------------------------------------------------------------------------------------- /** * Endpoint "{@code async_search.submit}". */ public static final SimpleEndpoint _ENDPOINT = new SimpleEndpoint<>("es/async_search.submit", // Request method request -> { return "POST"; }, // Request path request -> { final int _index = 1 << 0; int propsSet = 0; if (ApiTypeHelper.isDefined(request.index())) propsSet |= _index; if (propsSet == 0) { StringBuilder buf = new StringBuilder(); buf.append("/_async_search"); return buf.toString(); } if (propsSet == (_index)) { StringBuilder buf = new StringBuilder(); buf.append("/"); SimpleEndpoint.pathEncode(request.index.stream().map(v -> v).collect(Collectors.joining(",")), buf); buf.append("/_async_search"); return buf.toString(); } throw SimpleEndpoint.noPathTemplateFound("path"); }, // Request parameters request -> { Map params = new HashMap<>(); params.put("typed_keys", "true"); if (request.df != null) { params.put("df", request.df); } if (request.preFilterShardSize != null) { params.put("pre_filter_shard_size", String.valueOf(request.preFilterShardSize)); } if (request.minCompatibleShardNode != null) { params.put("min_compatible_shard_node", request.minCompatibleShardNode); } if (request.lenient != null) { params.put("lenient", String.valueOf(request.lenient)); } if (request.routing != null) { params.put("routing", request.routing); } if (request.ignoreUnavailable != null) { params.put("ignore_unavailable", String.valueOf(request.ignoreUnavailable)); } if (request.allowNoIndices != null) { params.put("allow_no_indices", String.valueOf(request.allowNoIndices)); } if (request.analyzer != null) { params.put("analyzer", request.analyzer); } if (request.ignoreThrottled != null) { params.put("ignore_throttled", String.valueOf(request.ignoreThrottled)); } if (request.keepOnCompletion != null) { params.put("keep_on_completion", String.valueOf(request.keepOnCompletion)); } if (request.maxConcurrentShardRequests != null) { params.put("max_concurrent_shard_requests", String.valueOf(request.maxConcurrentShardRequests)); } if (request.allowPartialSearchResults != null) { params.put("allow_partial_search_results", String.valueOf(request.allowPartialSearchResults)); } if (ApiTypeHelper.isDefined(request.expandWildcards)) { params.put("expand_wildcards", request.expandWildcards.stream().map(v -> v.jsonValue()).collect(Collectors.joining(","))); } if (request.preference != null) { params.put("preference", request.preference); } if (request.analyzeWildcard != null) { params.put("analyze_wildcard", String.valueOf(request.analyzeWildcard)); } if (request.scroll != null) { params.put("scroll", request.scroll._toJsonString()); } if (request.waitForCompletionTimeout != null) { params.put("wait_for_completion_timeout", request.waitForCompletionTimeout._toJsonString()); } if (request.searchType != null) { params.put("search_type", request.searchType.jsonValue()); } if (request.ccsMinimizeRoundtrips != null) { params.put("ccs_minimize_roundtrips", String.valueOf(request.ccsMinimizeRoundtrips)); } if (request.q != null) { params.put("q", request.q); } if (request.defaultOperator != null) { params.put("default_operator", request.defaultOperator.jsonValue()); } if (request.keepAlive != null) { params.put("keep_alive", request.keepAlive._toJsonString()); } if (request.requestCache != null) { params.put("request_cache", String.valueOf(request.requestCache)); } if (request.batchedReduceSize != null) { params.put("batched_reduce_size", String.valueOf(request.batchedReduceSize)); } return params; }, SimpleEndpoint.emptyMap(), true, SubmitResponse._DESERIALIZER); /** * Create an "{@code async_search.submit}" endpoint. */ public static Endpoint, ErrorResponse> createSubmitEndpoint( JsonpDeserializer tDocumentDeserializer) { return _ENDPOINT .withResponseDeserializer(SubmitResponse.createSubmitResponseDeserializer(tDocumentDeserializer)); } }
* API name: {@code search_type} */ @Nullable public final SearchType searchType() { return this.searchType; } /** * If true, returns sequence number and primary term of the last modification of * each hit. See Optimistic concurrency control. *
* API name: {@code seq_no_primary_term} */ @Nullable public final Boolean seqNoPrimaryTerm() { return this.seqNoPrimaryTerm; } /** * The number of hits to return. By default, you cannot page through more than * 10,000 hits using the from and size parameters. To page through more hits, * use the search_after parameter. *
* API name: {@code size} */ @Nullable public final Integer size() { return this.size; } /** * API name: {@code slice} */ @Nullable public final SlicedScroll slice() { return this.slice; } /** * API name: {@code sort} */ public final List sort() { return this.sort; } /** * Stats groups to associate with the search. Each group maintains a statistics * aggregation for its associated searches. You can retrieve these stats using * the indices stats API. * * API name: {@code stats} */ public final List stats() { return this.stats; } /** * List of stored fields to return as part of a hit. If no fields are specified, * no stored fields are included in the response. If this field is specified, * the _source parameter defaults to false. You can pass _source: true to return * both source fields and stored fields in the search response. * * API name: {@code stored_fields} */ public final List storedFields() { return this.storedFields; } /** * API name: {@code suggest} */ @Nullable public final Suggester suggest() { return this.suggest; } /** * Maximum number of documents to collect for each shard. If a query reaches * this limit, Elasticsearch terminates the query early. Elasticsearch collects * documents before sorting. Defaults to 0, which does not terminate query * execution early. * * API name: {@code terminate_after} */ @Nullable public final Long terminateAfter() { return this.terminateAfter; } /** * Specifies the period of time to wait for a response from each shard. If no * response is received before the timeout expires, the request fails and * returns an error. Defaults to no timeout. * * API name: {@code timeout} */ @Nullable public final String timeout() { return this.timeout; } /** * If true, calculate and return document scores, even if the scores are not * used for sorting. * * API name: {@code track_scores} */ @Nullable public final Boolean trackScores() { return this.trackScores; } /** * Number of hits matching the query to count accurately. If true, the exact * number of hits is returned at the cost of some performance. If false, the * response does not include the total number of hits matching the query. * Defaults to 10,000 hits. * * API name: {@code track_total_hits} */ @Nullable public final TrackHits trackTotalHits() { return this.trackTotalHits; } /** * If true, returns document version as part of a hit. * * API name: {@code version} */ @Nullable public final Boolean version() { return this.version; } /** * Specify the time that the request should block waiting for the final response * * API name: {@code wait_for_completion_timeout} */ @Nullable public final Time waitForCompletionTimeout() { return this.waitForCompletionTimeout; } /** * 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.source != null) { generator.writeKey("_source"); this.source.serialize(generator, mapper); } if (ApiTypeHelper.isDefined(this.aggregations)) { generator.writeKey("aggregations"); generator.writeStartObject(); for (Map.Entry item0 : this.aggregations.entrySet()) { generator.writeKey(item0.getKey()); item0.getValue().serialize(generator, mapper); } generator.writeEnd(); } if (this.collapse != null) { generator.writeKey("collapse"); this.collapse.serialize(generator, mapper); } if (ApiTypeHelper.isDefined(this.docvalueFields)) { generator.writeKey("docvalue_fields"); generator.writeStartArray(); for (FieldAndFormat item0 : this.docvalueFields) { item0.serialize(generator, mapper); } generator.writeEnd(); } if (this.explain != null) { generator.writeKey("explain"); generator.write(this.explain); } if (ApiTypeHelper.isDefined(this.fields)) { generator.writeKey("fields"); generator.writeStartArray(); for (FieldAndFormat item0 : this.fields) { item0.serialize(generator, mapper); } generator.writeEnd(); } if (this.from != null) { generator.writeKey("from"); generator.write(this.from); } if (this.highlight != null) { generator.writeKey("highlight"); this.highlight.serialize(generator, mapper); } if (ApiTypeHelper.isDefined(this.indicesBoost)) { generator.writeKey("indices_boost"); generator.writeStartArray(); for (Map item0 : this.indicesBoost) { generator.writeStartObject(); if (item0 != null) { for (Map.Entry item1 : item0.entrySet()) { generator.writeKey(item1.getKey()); generator.write(item1.getValue()); } } generator.writeEnd(); } generator.writeEnd(); } if (this.minScore != null) { generator.writeKey("min_score"); generator.write(this.minScore); } if (this.pit != null) { generator.writeKey("pit"); this.pit.serialize(generator, mapper); } if (this.postFilter != null) { generator.writeKey("post_filter"); this.postFilter.serialize(generator, mapper); } if (this.profile != null) { generator.writeKey("profile"); generator.write(this.profile); } if (this.query != null) { generator.writeKey("query"); this.query.serialize(generator, mapper); } if (ApiTypeHelper.isDefined(this.rescore)) { generator.writeKey("rescore"); generator.writeStartArray(); for (Rescore item0 : this.rescore) { item0.serialize(generator, mapper); } generator.writeEnd(); } if (ApiTypeHelper.isDefined(this.runtimeMappings)) { generator.writeKey("runtime_mappings"); generator.writeStartObject(); for (Map.Entry> item0 : this.runtimeMappings.entrySet()) { generator.writeKey(item0.getKey()); generator.writeStartArray(); if (item0.getValue() != null) { for (RuntimeField item1 : item0.getValue()) { item1.serialize(generator, mapper); } } generator.writeEnd(); } generator.writeEnd(); } if (ApiTypeHelper.isDefined(this.scriptFields)) { generator.writeKey("script_fields"); generator.writeStartObject(); for (Map.Entry item0 : this.scriptFields.entrySet()) { generator.writeKey(item0.getKey()); item0.getValue().serialize(generator, mapper); } generator.writeEnd(); } if (ApiTypeHelper.isDefined(this.searchAfter)) { generator.writeKey("search_after"); generator.writeStartArray(); for (String item0 : this.searchAfter) { generator.write(item0); } generator.writeEnd(); } if (this.seqNoPrimaryTerm != null) { generator.writeKey("seq_no_primary_term"); generator.write(this.seqNoPrimaryTerm); } if (this.size != null) { generator.writeKey("size"); generator.write(this.size); } if (this.slice != null) { generator.writeKey("slice"); this.slice.serialize(generator, mapper); } if (ApiTypeHelper.isDefined(this.sort)) { generator.writeKey("sort"); generator.writeStartArray(); for (SortOptions item0 : this.sort) { item0.serialize(generator, mapper); } generator.writeEnd(); } if (ApiTypeHelper.isDefined(this.stats)) { generator.writeKey("stats"); generator.writeStartArray(); for (String item0 : this.stats) { generator.write(item0); } generator.writeEnd(); } if (ApiTypeHelper.isDefined(this.storedFields)) { generator.writeKey("stored_fields"); generator.writeStartArray(); for (String item0 : this.storedFields) { generator.write(item0); } generator.writeEnd(); } if (this.suggest != null) { generator.writeKey("suggest"); this.suggest.serialize(generator, mapper); } if (this.terminateAfter != null) { generator.writeKey("terminate_after"); generator.write(this.terminateAfter); } if (this.timeout != null) { generator.writeKey("timeout"); generator.write(this.timeout); } if (this.trackScores != null) { generator.writeKey("track_scores"); generator.write(this.trackScores); } if (this.trackTotalHits != null) { generator.writeKey("track_total_hits"); this.trackTotalHits.serialize(generator, mapper); } if (this.version != null) { generator.writeKey("version"); generator.write(this.version); } } // --------------------------------------------------------------------------------------------- /** * Builder for {@link SubmitRequest}. */ public static class Builder extends WithJsonObjectBuilderBase implements ObjectBuilder { @Nullable private SourceConfig source; @Nullable private Map aggregations; @Nullable private Boolean allowNoIndices; @Nullable private Boolean allowPartialSearchResults; @Nullable private Boolean analyzeWildcard; @Nullable private String analyzer; @Nullable private Long batchedReduceSize; @Nullable private Boolean ccsMinimizeRoundtrips; @Nullable private FieldCollapse collapse; @Nullable private Operator defaultOperator; @Nullable private String df; @Nullable private List docvalueFields; @Nullable private List expandWildcards; @Nullable private Boolean explain; @Nullable private List fields; @Nullable private Integer from; @Nullable private Highlight highlight; @Nullable private Boolean ignoreThrottled; @Nullable private Boolean ignoreUnavailable; @Nullable private List index; @Nullable private List> indicesBoost; @Nullable private Time keepAlive; @Nullable private Boolean keepOnCompletion; @Nullable private Boolean lenient; @Nullable private Long maxConcurrentShardRequests; @Nullable private String minCompatibleShardNode; @Nullable private Double minScore; @Nullable private PointInTimeReference pit; @Nullable private Query postFilter; @Nullable private Long preFilterShardSize; @Nullable private String preference; @Nullable private Boolean profile; @Nullable private String q; @Nullable private Query query; @Nullable private Boolean requestCache; @Nullable private List rescore; @Nullable private String routing; @Nullable private Map> runtimeMappings; @Nullable private Map scriptFields; @Nullable private Time scroll; @Nullable private List searchAfter; @Nullable private SearchType searchType; @Nullable private Boolean seqNoPrimaryTerm; @Nullable private Integer size; @Nullable private SlicedScroll slice; @Nullable private List sort; @Nullable private List stats; @Nullable private List storedFields; @Nullable private Suggester suggest; @Nullable private Long terminateAfter; @Nullable private String timeout; @Nullable private Boolean trackScores; @Nullable private TrackHits trackTotalHits; @Nullable private Boolean version; @Nullable private Time waitForCompletionTimeout; /** * Indicates which source fields are returned for matching documents. These * fields are returned in the hits._source property of the search response. * * API name: {@code _source} */ public final Builder source(@Nullable SourceConfig value) { this.source = value; return this; } /** * Indicates which source fields are returned for matching documents. These * fields are returned in the hits._source property of the search response. * * API name: {@code _source} */ public final Builder source(Function> fn) { return this.source(fn.apply(new SourceConfig.Builder()).build()); } /** * API name: {@code aggregations} * * Adds all entries of map to aggregations. */ public final Builder aggregations(Map map) { this.aggregations = _mapPutAll(this.aggregations, map); return this; } /** * API name: {@code aggregations} * * Adds an entry to aggregations. */ public final Builder aggregations(String key, Aggregation value) { this.aggregations = _mapPut(this.aggregations, key, value); return this; } /** * API name: {@code aggregations} * * Adds an entry to aggregations using a builder lambda. */ public final Builder aggregations(String key, Function> fn) { return aggregations(key, fn.apply(new Aggregation.Builder()).build()); } /** * Whether to ignore if a wildcard indices expression resolves into no concrete * indices. (This includes _all string or when no indices have been * specified) * * API name: {@code allow_no_indices} */ public final Builder allowNoIndices(@Nullable Boolean value) { this.allowNoIndices = value; return this; } /** * Indicate if an error should be returned if there is a partial search failure * or timeout * * API name: {@code allow_partial_search_results} */ public final Builder allowPartialSearchResults(@Nullable Boolean value) { this.allowPartialSearchResults = value; return this; } /** * Specify whether wildcard and prefix queries should be analyzed (default: * false) * * API name: {@code analyze_wildcard} */ public final Builder analyzeWildcard(@Nullable Boolean value) { this.analyzeWildcard = value; return this; } /** * The analyzer to use for the query string * * API name: {@code analyzer} */ public final Builder analyzer(@Nullable String value) { this.analyzer = value; return this; } /** * The number of shard results that should be reduced at once on the * coordinating node. This value should be used as the granularity at which * progress results will be made available. * * API name: {@code batched_reduce_size} */ public final Builder batchedReduceSize(@Nullable Long value) { this.batchedReduceSize = value; return this; } /** * API name: {@code ccs_minimize_roundtrips} */ public final Builder ccsMinimizeRoundtrips(@Nullable Boolean value) { this.ccsMinimizeRoundtrips = value; return this; } /** * API name: {@code collapse} */ public final Builder collapse(@Nullable FieldCollapse value) { this.collapse = value; return this; } /** * API name: {@code collapse} */ public final Builder collapse(Function> fn) { return this.collapse(fn.apply(new FieldCollapse.Builder()).build()); } /** * The default operator for query string query (AND or OR) * * API name: {@code default_operator} */ public final Builder defaultOperator(@Nullable Operator value) { this.defaultOperator = value; return this; } /** * The field to use as default where no field prefix is given in the query * string * * API name: {@code df} */ public final Builder df(@Nullable String value) { this.df = value; return this; } /** * Array of wildcard (*) patterns. The request returns doc values for field * names matching these patterns in the hits.fields property of the response. * * API name: {@code docvalue_fields} * * Adds all elements of list to docvalueFields. */ public final Builder docvalueFields(List list) { this.docvalueFields = _listAddAll(this.docvalueFields, list); return this; } /** * Array of wildcard (*) patterns. The request returns doc values for field * names matching these patterns in the hits.fields property of the response. * * API name: {@code docvalue_fields} * * Adds one or more values to docvalueFields. */ public final Builder docvalueFields(FieldAndFormat value, FieldAndFormat... values) { this.docvalueFields = _listAdd(this.docvalueFields, value, values); return this; } /** * Array of wildcard (*) patterns. The request returns doc values for field * names matching these patterns in the hits.fields property of the response. * * API name: {@code docvalue_fields} * * Adds a value to docvalueFields using a builder lambda. */ public final Builder docvalueFields(Function> fn) { return docvalueFields(fn.apply(new FieldAndFormat.Builder()).build()); } /** * Whether to expand wildcard expression to concrete indices that are open, * closed or both. * * API name: {@code expand_wildcards} * * Adds all elements of list to expandWildcards. */ public final Builder expandWildcards(List list) { this.expandWildcards = _listAddAll(this.expandWildcards, list); return this; } /** * Whether to expand wildcard expression to concrete indices that are open, * closed or both. * * API name: {@code expand_wildcards} * * Adds one or more values to expandWildcards. */ public final Builder expandWildcards(ExpandWildcard value, ExpandWildcard... values) { this.expandWildcards = _listAdd(this.expandWildcards, value, values); return this; } /** * If true, returns detailed information about score computation as part of a * hit. * * API name: {@code explain} */ public final Builder explain(@Nullable Boolean value) { this.explain = value; return this; } /** * Array of wildcard (*) patterns. The request returns values for field names * matching these patterns in the hits.fields property of the response. * * API name: {@code fields} * * Adds all elements of list to fields. */ public final Builder fields(List list) { this.fields = _listAddAll(this.fields, list); return this; } /** * Array of wildcard (*) patterns. The request returns values for field names * matching these patterns in the hits.fields property of the response. * * API name: {@code fields} * * Adds one or more values to fields. */ public final Builder fields(FieldAndFormat value, FieldAndFormat... values) { this.fields = _listAdd(this.fields, value, values); return this; } /** * Array of wildcard (*) patterns. The request returns values for field names * matching these patterns in the hits.fields property of the response. * * API name: {@code fields} * * Adds a value to fields using a builder lambda. */ public final Builder fields(Function> fn) { return fields(fn.apply(new FieldAndFormat.Builder()).build()); } /** * Starting document offset. By default, you cannot page through more than * 10,000 hits using the from and size parameters. To page through more hits, * use the search_after parameter. * * API name: {@code from} */ public final Builder from(@Nullable Integer value) { this.from = value; return this; } /** * API name: {@code highlight} */ public final Builder highlight(@Nullable Highlight value) { this.highlight = value; return this; } /** * API name: {@code highlight} */ public final Builder highlight(Function> fn) { return this.highlight(fn.apply(new Highlight.Builder()).build()); } /** * Whether specified concrete, expanded or aliased indices should be ignored * when throttled * * API name: {@code ignore_throttled} */ public final Builder ignoreThrottled(@Nullable Boolean value) { this.ignoreThrottled = value; return this; } /** * Whether specified concrete indices should be ignored when unavailable * (missing or closed) * * API name: {@code ignore_unavailable} */ public final Builder ignoreUnavailable(@Nullable Boolean value) { this.ignoreUnavailable = value; return this; } /** * A comma-separated list of index names to search; use _all or * empty string to perform the operation on all indices * * API name: {@code index} * * Adds all elements of list to index. */ public final Builder index(List list) { this.index = _listAddAll(this.index, list); return this; } /** * A comma-separated list of index names to search; use _all or * empty string to perform the operation on all indices * * API name: {@code index} * * Adds one or more values to index. */ public final Builder index(String value, String... values) { this.index = _listAdd(this.index, value, values); return this; } /** * Boosts the _score of documents from specified indices. * * API name: {@code indices_boost} * * Adds all elements of list to indicesBoost. */ public final Builder indicesBoost(List> list) { this.indicesBoost = _listAddAll(this.indicesBoost, list); return this; } /** * Boosts the _score of documents from specified indices. * * API name: {@code indices_boost} * * Adds one or more values to indicesBoost. */ public final Builder indicesBoost(Map value, Map... values) { this.indicesBoost = _listAdd(this.indicesBoost, value, values); return this; } /** * Update the time interval in which the results (partial or final) for this * search will be available * * API name: {@code keep_alive} */ public final Builder keepAlive(@Nullable Time value) { this.keepAlive = value; return this; } /** * Update the time interval in which the results (partial or final) for this * search will be available * * API name: {@code keep_alive} */ public final Builder keepAlive(Function> fn) { return this.keepAlive(fn.apply(new Time.Builder()).build()); } /** * Control whether the response should be stored in the cluster if it completed * within the provided [wait_for_completion] time (default: false) * * API name: {@code keep_on_completion} */ public final Builder keepOnCompletion(@Nullable Boolean value) { this.keepOnCompletion = value; return this; } /** * Specify whether format-based query failures (such as providing text to a * numeric field) should be ignored * * API name: {@code lenient} */ public final Builder lenient(@Nullable Boolean value) { this.lenient = value; return this; } /** * The number of concurrent shard requests per node this search executes * concurrently. This value should be used to limit the impact of the search on * the cluster in order to limit the number of concurrent shard requests * * API name: {@code max_concurrent_shard_requests} */ public final Builder maxConcurrentShardRequests(@Nullable Long value) { this.maxConcurrentShardRequests = value; return this; } /** * API name: {@code min_compatible_shard_node} */ public final Builder minCompatibleShardNode(@Nullable String value) { this.minCompatibleShardNode = value; return this; } /** * Minimum _score for matching documents. Documents with a lower _score are not * included in the search results. * * API name: {@code min_score} */ public final Builder minScore(@Nullable Double value) { this.minScore = value; return this; } /** * Limits the search to a point in time (PIT). If you provide a PIT, you cannot * specify an <index> in the request path. * * API name: {@code pit} */ public final Builder pit(@Nullable PointInTimeReference value) { this.pit = value; return this; } /** * Limits the search to a point in time (PIT). If you provide a PIT, you cannot * specify an <index> in the request path. * * API name: {@code pit} */ public final Builder pit(Function> fn) { return this.pit(fn.apply(new PointInTimeReference.Builder()).build()); } /** * API name: {@code post_filter} */ public final Builder postFilter(@Nullable Query value) { this.postFilter = value; return this; } /** * API name: {@code post_filter} */ public final Builder postFilter(Function> fn) { return this.postFilter(fn.apply(new Query.Builder()).build()); } /** * API name: {@code pre_filter_shard_size} */ public final Builder preFilterShardSize(@Nullable Long value) { this.preFilterShardSize = value; return this; } /** * Specify the node or shard the operation should be performed on (default: * random) * * API name: {@code preference} */ public final Builder preference(@Nullable String value) { this.preference = value; return this; } /** * API name: {@code profile} */ public final Builder profile(@Nullable Boolean value) { this.profile = value; return this; } /** * Query in the Lucene query string syntax * * API name: {@code q} */ public final Builder q(@Nullable String value) { this.q = value; return this; } /** * Defines the search definition using the Query DSL. * * API name: {@code query} */ public final Builder query(@Nullable Query value) { this.query = value; return this; } /** * Defines the search definition using the Query DSL. * * API name: {@code query} */ public final Builder query(Function> fn) { return this.query(fn.apply(new Query.Builder()).build()); } /** * Specify if request cache should be used for this request or not, defaults to * true * * API name: {@code request_cache} */ public final Builder requestCache(@Nullable Boolean value) { this.requestCache = value; return this; } /** * API name: {@code rescore} * * Adds all elements of list to rescore. */ public final Builder rescore(List list) { this.rescore = _listAddAll(this.rescore, list); return this; } /** * API name: {@code rescore} * * Adds one or more values to rescore. */ public final Builder rescore(Rescore value, Rescore... values) { this.rescore = _listAdd(this.rescore, value, values); return this; } /** * API name: {@code rescore} * * Adds a value to rescore using a builder lambda. */ public final Builder rescore(Function> fn) { return rescore(fn.apply(new Rescore.Builder()).build()); } /** * A comma-separated list of specific routing values * * API name: {@code routing} */ public final Builder routing(@Nullable String value) { this.routing = value; return this; } /** * Defines one or more runtime fields in the search request. These fields take * precedence over mapped fields with the same name. * * API name: {@code runtime_mappings} * * Adds all entries of map to runtimeMappings. */ public final Builder runtimeMappings(Map> map) { this.runtimeMappings = _mapPutAll(this.runtimeMappings, map); return this; } /** * Defines one or more runtime fields in the search request. These fields take * precedence over mapped fields with the same name. * * API name: {@code runtime_mappings} * * Adds an entry to runtimeMappings. */ public final Builder runtimeMappings(String key, List value) { this.runtimeMappings = _mapPut(this.runtimeMappings, key, value); return this; } /** * Retrieve a script evaluation (based on different fields) for each hit. * * API name: {@code script_fields} * * Adds all entries of map to scriptFields. */ public final Builder scriptFields(Map map) { this.scriptFields = _mapPutAll(this.scriptFields, map); return this; } /** * Retrieve a script evaluation (based on different fields) for each hit. * * API name: {@code script_fields} * * Adds an entry to scriptFields. */ public final Builder scriptFields(String key, ScriptField value) { this.scriptFields = _mapPut(this.scriptFields, key, value); return this; } /** * Retrieve a script evaluation (based on different fields) for each hit. * * API name: {@code script_fields} * * Adds an entry to scriptFields using a builder lambda. */ public final Builder scriptFields(String key, Function> fn) { return scriptFields(key, fn.apply(new ScriptField.Builder()).build()); } /** * API name: {@code scroll} */ public final Builder scroll(@Nullable Time value) { this.scroll = value; return this; } /** * API name: {@code scroll} */ public final Builder scroll(Function> fn) { return this.scroll(fn.apply(new Time.Builder()).build()); } /** * API name: {@code search_after} * * Adds all elements of list to searchAfter. */ public final Builder searchAfter(List list) { this.searchAfter = _listAddAll(this.searchAfter, list); return this; } /** * API name: {@code search_after} * * Adds one or more values to searchAfter. */ public final Builder searchAfter(String value, String... values) { this.searchAfter = _listAdd(this.searchAfter, value, values); return this; } /** * Search operation type * * API name: {@code search_type} */ public final Builder searchType(@Nullable SearchType value) { this.searchType = value; return this; } /** * If true, returns sequence number and primary term of the last modification of * each hit. See Optimistic concurrency control. * * API name: {@code seq_no_primary_term} */ public final Builder seqNoPrimaryTerm(@Nullable Boolean value) { this.seqNoPrimaryTerm = value; return this; } /** * The number of hits to return. By default, you cannot page through more than * 10,000 hits using the from and size parameters. To page through more hits, * use the search_after parameter. * * API name: {@code size} */ public final Builder size(@Nullable Integer value) { this.size = value; return this; } /** * API name: {@code slice} */ public final Builder slice(@Nullable SlicedScroll value) { this.slice = value; return this; } /** * API name: {@code slice} */ public final Builder slice(Function> fn) { return this.slice(fn.apply(new SlicedScroll.Builder()).build()); } /** * API name: {@code sort} * * Adds all elements of list to sort. */ public final Builder sort(List list) { this.sort = _listAddAll(this.sort, list); return this; } /** * API name: {@code sort} * * Adds one or more values to sort. */ public final Builder sort(SortOptions value, SortOptions... values) { this.sort = _listAdd(this.sort, value, values); return this; } /** * API name: {@code sort} * * Adds a value to sort using a builder lambda. */ public final Builder sort(Function> fn) { return sort(fn.apply(new SortOptions.Builder()).build()); } /** * Stats groups to associate with the search. Each group maintains a statistics * aggregation for its associated searches. You can retrieve these stats using * the indices stats API. * * API name: {@code stats} * * Adds all elements of list to stats. */ public final Builder stats(List list) { this.stats = _listAddAll(this.stats, list); return this; } /** * Stats groups to associate with the search. Each group maintains a statistics * aggregation for its associated searches. You can retrieve these stats using * the indices stats API. * * API name: {@code stats} * * Adds one or more values to stats. */ public final Builder stats(String value, String... values) { this.stats = _listAdd(this.stats, value, values); return this; } /** * List of stored fields to return as part of a hit. If no fields are specified, * no stored fields are included in the response. If this field is specified, * the _source parameter defaults to false. You can pass _source: true to return * both source fields and stored fields in the search response. * * API name: {@code stored_fields} * * Adds all elements of list to storedFields. */ public final Builder storedFields(List list) { this.storedFields = _listAddAll(this.storedFields, list); return this; } /** * List of stored fields to return as part of a hit. If no fields are specified, * no stored fields are included in the response. If this field is specified, * the _source parameter defaults to false. You can pass _source: true to return * both source fields and stored fields in the search response. * * API name: {@code stored_fields} * * Adds one or more values to storedFields. */ public final Builder storedFields(String value, String... values) { this.storedFields = _listAdd(this.storedFields, value, values); return this; } /** * API name: {@code suggest} */ public final Builder suggest(@Nullable Suggester value) { this.suggest = value; return this; } /** * API name: {@code suggest} */ public final Builder suggest(Function> fn) { return this.suggest(fn.apply(new Suggester.Builder()).build()); } /** * Maximum number of documents to collect for each shard. If a query reaches * this limit, Elasticsearch terminates the query early. Elasticsearch collects * documents before sorting. Defaults to 0, which does not terminate query * execution early. * * API name: {@code terminate_after} */ public final Builder terminateAfter(@Nullable Long value) { this.terminateAfter = value; return this; } /** * Specifies the period of time to wait for a response from each shard. If no * response is received before the timeout expires, the request fails and * returns an error. Defaults to no timeout. * * API name: {@code timeout} */ public final Builder timeout(@Nullable String value) { this.timeout = value; return this; } /** * If true, calculate and return document scores, even if the scores are not * used for sorting. * * API name: {@code track_scores} */ public final Builder trackScores(@Nullable Boolean value) { this.trackScores = value; return this; } /** * Number of hits matching the query to count accurately. If true, the exact * number of hits is returned at the cost of some performance. If false, the * response does not include the total number of hits matching the query. * Defaults to 10,000 hits. * * API name: {@code track_total_hits} */ public final Builder trackTotalHits(@Nullable TrackHits value) { this.trackTotalHits = value; return this; } /** * Number of hits matching the query to count accurately. If true, the exact * number of hits is returned at the cost of some performance. If false, the * response does not include the total number of hits matching the query. * Defaults to 10,000 hits. * * API name: {@code track_total_hits} */ public final Builder trackTotalHits(Function> fn) { return this.trackTotalHits(fn.apply(new TrackHits.Builder()).build()); } /** * If true, returns document version as part of a hit. * * API name: {@code version} */ public final Builder version(@Nullable Boolean value) { this.version = value; return this; } /** * Specify the time that the request should block waiting for the final response * * API name: {@code wait_for_completion_timeout} */ public final Builder waitForCompletionTimeout(@Nullable Time value) { this.waitForCompletionTimeout = value; return this; } /** * Specify the time that the request should block waiting for the final response * * API name: {@code wait_for_completion_timeout} */ public final Builder waitForCompletionTimeout(Function> fn) { return this.waitForCompletionTimeout(fn.apply(new Time.Builder()).build()); } @Override protected Builder self() { return this; } /** * Builds a {@link SubmitRequest}. * * @throws NullPointerException * if some of the required fields are null. */ public SubmitRequest build() { _checkSingleUse(); return new SubmitRequest(this); } } // --------------------------------------------------------------------------------------------- /** * Json deserializer for {@link SubmitRequest} */ public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy(Builder::new, SubmitRequest::setupSubmitRequestDeserializer); protected static void setupSubmitRequestDeserializer(ObjectDeserializer op) { op.add(Builder::source, SourceConfig._DESERIALIZER, "_source"); op.add(Builder::aggregations, JsonpDeserializer.stringMapDeserializer(Aggregation._DESERIALIZER), "aggregations", "aggs"); op.add(Builder::collapse, FieldCollapse._DESERIALIZER, "collapse"); op.add(Builder::docvalueFields, JsonpDeserializer.arrayDeserializer(FieldAndFormat._DESERIALIZER), "docvalue_fields"); op.add(Builder::explain, JsonpDeserializer.booleanDeserializer(), "explain"); op.add(Builder::fields, JsonpDeserializer.arrayDeserializer(FieldAndFormat._DESERIALIZER), "fields"); op.add(Builder::from, JsonpDeserializer.integerDeserializer(), "from"); op.add(Builder::highlight, Highlight._DESERIALIZER, "highlight"); op.add(Builder::indicesBoost, JsonpDeserializer.arrayDeserializer( JsonpDeserializer.stringMapDeserializer(JsonpDeserializer.doubleDeserializer())), "indices_boost"); op.add(Builder::minScore, JsonpDeserializer.doubleDeserializer(), "min_score"); op.add(Builder::pit, PointInTimeReference._DESERIALIZER, "pit"); op.add(Builder::postFilter, Query._DESERIALIZER, "post_filter"); op.add(Builder::profile, JsonpDeserializer.booleanDeserializer(), "profile"); op.add(Builder::query, Query._DESERIALIZER, "query"); op.add(Builder::rescore, JsonpDeserializer.arrayDeserializer(Rescore._DESERIALIZER), "rescore"); op.add(Builder::runtimeMappings, JsonpDeserializer.stringMapDeserializer( JsonpDeserializer.arrayDeserializer(RuntimeField._DESERIALIZER)), "runtime_mappings"); op.add(Builder::scriptFields, JsonpDeserializer.stringMapDeserializer(ScriptField._DESERIALIZER), "script_fields"); op.add(Builder::searchAfter, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "search_after"); op.add(Builder::seqNoPrimaryTerm, JsonpDeserializer.booleanDeserializer(), "seq_no_primary_term"); op.add(Builder::size, JsonpDeserializer.integerDeserializer(), "size"); op.add(Builder::slice, SlicedScroll._DESERIALIZER, "slice"); op.add(Builder::sort, JsonpDeserializer.arrayDeserializer(SortOptions._DESERIALIZER), "sort"); op.add(Builder::stats, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "stats"); op.add(Builder::storedFields, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "stored_fields"); op.add(Builder::suggest, Suggester._DESERIALIZER, "suggest"); op.add(Builder::terminateAfter, JsonpDeserializer.longDeserializer(), "terminate_after"); op.add(Builder::timeout, JsonpDeserializer.stringDeserializer(), "timeout"); op.add(Builder::trackScores, JsonpDeserializer.booleanDeserializer(), "track_scores"); op.add(Builder::trackTotalHits, TrackHits._DESERIALIZER, "track_total_hits"); op.add(Builder::version, JsonpDeserializer.booleanDeserializer(), "version"); } // --------------------------------------------------------------------------------------------- /** * Endpoint "{@code async_search.submit}". */ public static final SimpleEndpoint _ENDPOINT = new SimpleEndpoint<>("es/async_search.submit", // Request method request -> { return "POST"; }, // Request path request -> { final int _index = 1 << 0; int propsSet = 0; if (ApiTypeHelper.isDefined(request.index())) propsSet |= _index; if (propsSet == 0) { StringBuilder buf = new StringBuilder(); buf.append("/_async_search"); return buf.toString(); } if (propsSet == (_index)) { StringBuilder buf = new StringBuilder(); buf.append("/"); SimpleEndpoint.pathEncode(request.index.stream().map(v -> v).collect(Collectors.joining(",")), buf); buf.append("/_async_search"); return buf.toString(); } throw SimpleEndpoint.noPathTemplateFound("path"); }, // Request parameters request -> { Map params = new HashMap<>(); params.put("typed_keys", "true"); if (request.df != null) { params.put("df", request.df); } if (request.preFilterShardSize != null) { params.put("pre_filter_shard_size", String.valueOf(request.preFilterShardSize)); } if (request.minCompatibleShardNode != null) { params.put("min_compatible_shard_node", request.minCompatibleShardNode); } if (request.lenient != null) { params.put("lenient", String.valueOf(request.lenient)); } if (request.routing != null) { params.put("routing", request.routing); } if (request.ignoreUnavailable != null) { params.put("ignore_unavailable", String.valueOf(request.ignoreUnavailable)); } if (request.allowNoIndices != null) { params.put("allow_no_indices", String.valueOf(request.allowNoIndices)); } if (request.analyzer != null) { params.put("analyzer", request.analyzer); } if (request.ignoreThrottled != null) { params.put("ignore_throttled", String.valueOf(request.ignoreThrottled)); } if (request.keepOnCompletion != null) { params.put("keep_on_completion", String.valueOf(request.keepOnCompletion)); } if (request.maxConcurrentShardRequests != null) { params.put("max_concurrent_shard_requests", String.valueOf(request.maxConcurrentShardRequests)); } if (request.allowPartialSearchResults != null) { params.put("allow_partial_search_results", String.valueOf(request.allowPartialSearchResults)); } if (ApiTypeHelper.isDefined(request.expandWildcards)) { params.put("expand_wildcards", request.expandWildcards.stream().map(v -> v.jsonValue()).collect(Collectors.joining(","))); } if (request.preference != null) { params.put("preference", request.preference); } if (request.analyzeWildcard != null) { params.put("analyze_wildcard", String.valueOf(request.analyzeWildcard)); } if (request.scroll != null) { params.put("scroll", request.scroll._toJsonString()); } if (request.waitForCompletionTimeout != null) { params.put("wait_for_completion_timeout", request.waitForCompletionTimeout._toJsonString()); } if (request.searchType != null) { params.put("search_type", request.searchType.jsonValue()); } if (request.ccsMinimizeRoundtrips != null) { params.put("ccs_minimize_roundtrips", String.valueOf(request.ccsMinimizeRoundtrips)); } if (request.q != null) { params.put("q", request.q); } if (request.defaultOperator != null) { params.put("default_operator", request.defaultOperator.jsonValue()); } if (request.keepAlive != null) { params.put("keep_alive", request.keepAlive._toJsonString()); } if (request.requestCache != null) { params.put("request_cache", String.valueOf(request.requestCache)); } if (request.batchedReduceSize != null) { params.put("batched_reduce_size", String.valueOf(request.batchedReduceSize)); } return params; }, SimpleEndpoint.emptyMap(), true, SubmitResponse._DESERIALIZER); /** * Create an "{@code async_search.submit}" endpoint. */ public static Endpoint, ErrorResponse> createSubmitEndpoint( JsonpDeserializer tDocumentDeserializer) { return _ENDPOINT .withResponseDeserializer(SubmitResponse.createSubmitResponseDeserializer(tDocumentDeserializer)); } }
* API name: {@code stats} */ public final List stats() { return this.stats; } /** * List of stored fields to return as part of a hit. If no fields are specified, * no stored fields are included in the response. If this field is specified, * the _source parameter defaults to false. You can pass _source: true to return * both source fields and stored fields in the search response. * * API name: {@code stored_fields} */ public final List storedFields() { return this.storedFields; } /** * API name: {@code suggest} */ @Nullable public final Suggester suggest() { return this.suggest; } /** * Maximum number of documents to collect for each shard. If a query reaches * this limit, Elasticsearch terminates the query early. Elasticsearch collects * documents before sorting. Defaults to 0, which does not terminate query * execution early. * * API name: {@code terminate_after} */ @Nullable public final Long terminateAfter() { return this.terminateAfter; } /** * Specifies the period of time to wait for a response from each shard. If no * response is received before the timeout expires, the request fails and * returns an error. Defaults to no timeout. * * API name: {@code timeout} */ @Nullable public final String timeout() { return this.timeout; } /** * If true, calculate and return document scores, even if the scores are not * used for sorting. * * API name: {@code track_scores} */ @Nullable public final Boolean trackScores() { return this.trackScores; } /** * Number of hits matching the query to count accurately. If true, the exact * number of hits is returned at the cost of some performance. If false, the * response does not include the total number of hits matching the query. * Defaults to 10,000 hits. * * API name: {@code track_total_hits} */ @Nullable public final TrackHits trackTotalHits() { return this.trackTotalHits; } /** * If true, returns document version as part of a hit. * * API name: {@code version} */ @Nullable public final Boolean version() { return this.version; } /** * Specify the time that the request should block waiting for the final response * * API name: {@code wait_for_completion_timeout} */ @Nullable public final Time waitForCompletionTimeout() { return this.waitForCompletionTimeout; } /** * 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.source != null) { generator.writeKey("_source"); this.source.serialize(generator, mapper); } if (ApiTypeHelper.isDefined(this.aggregations)) { generator.writeKey("aggregations"); generator.writeStartObject(); for (Map.Entry item0 : this.aggregations.entrySet()) { generator.writeKey(item0.getKey()); item0.getValue().serialize(generator, mapper); } generator.writeEnd(); } if (this.collapse != null) { generator.writeKey("collapse"); this.collapse.serialize(generator, mapper); } if (ApiTypeHelper.isDefined(this.docvalueFields)) { generator.writeKey("docvalue_fields"); generator.writeStartArray(); for (FieldAndFormat item0 : this.docvalueFields) { item0.serialize(generator, mapper); } generator.writeEnd(); } if (this.explain != null) { generator.writeKey("explain"); generator.write(this.explain); } if (ApiTypeHelper.isDefined(this.fields)) { generator.writeKey("fields"); generator.writeStartArray(); for (FieldAndFormat item0 : this.fields) { item0.serialize(generator, mapper); } generator.writeEnd(); } if (this.from != null) { generator.writeKey("from"); generator.write(this.from); } if (this.highlight != null) { generator.writeKey("highlight"); this.highlight.serialize(generator, mapper); } if (ApiTypeHelper.isDefined(this.indicesBoost)) { generator.writeKey("indices_boost"); generator.writeStartArray(); for (Map item0 : this.indicesBoost) { generator.writeStartObject(); if (item0 != null) { for (Map.Entry item1 : item0.entrySet()) { generator.writeKey(item1.getKey()); generator.write(item1.getValue()); } } generator.writeEnd(); } generator.writeEnd(); } if (this.minScore != null) { generator.writeKey("min_score"); generator.write(this.minScore); } if (this.pit != null) { generator.writeKey("pit"); this.pit.serialize(generator, mapper); } if (this.postFilter != null) { generator.writeKey("post_filter"); this.postFilter.serialize(generator, mapper); } if (this.profile != null) { generator.writeKey("profile"); generator.write(this.profile); } if (this.query != null) { generator.writeKey("query"); this.query.serialize(generator, mapper); } if (ApiTypeHelper.isDefined(this.rescore)) { generator.writeKey("rescore"); generator.writeStartArray(); for (Rescore item0 : this.rescore) { item0.serialize(generator, mapper); } generator.writeEnd(); } if (ApiTypeHelper.isDefined(this.runtimeMappings)) { generator.writeKey("runtime_mappings"); generator.writeStartObject(); for (Map.Entry> item0 : this.runtimeMappings.entrySet()) { generator.writeKey(item0.getKey()); generator.writeStartArray(); if (item0.getValue() != null) { for (RuntimeField item1 : item0.getValue()) { item1.serialize(generator, mapper); } } generator.writeEnd(); } generator.writeEnd(); } if (ApiTypeHelper.isDefined(this.scriptFields)) { generator.writeKey("script_fields"); generator.writeStartObject(); for (Map.Entry item0 : this.scriptFields.entrySet()) { generator.writeKey(item0.getKey()); item0.getValue().serialize(generator, mapper); } generator.writeEnd(); } if (ApiTypeHelper.isDefined(this.searchAfter)) { generator.writeKey("search_after"); generator.writeStartArray(); for (String item0 : this.searchAfter) { generator.write(item0); } generator.writeEnd(); } if (this.seqNoPrimaryTerm != null) { generator.writeKey("seq_no_primary_term"); generator.write(this.seqNoPrimaryTerm); } if (this.size != null) { generator.writeKey("size"); generator.write(this.size); } if (this.slice != null) { generator.writeKey("slice"); this.slice.serialize(generator, mapper); } if (ApiTypeHelper.isDefined(this.sort)) { generator.writeKey("sort"); generator.writeStartArray(); for (SortOptions item0 : this.sort) { item0.serialize(generator, mapper); } generator.writeEnd(); } if (ApiTypeHelper.isDefined(this.stats)) { generator.writeKey("stats"); generator.writeStartArray(); for (String item0 : this.stats) { generator.write(item0); } generator.writeEnd(); } if (ApiTypeHelper.isDefined(this.storedFields)) { generator.writeKey("stored_fields"); generator.writeStartArray(); for (String item0 : this.storedFields) { generator.write(item0); } generator.writeEnd(); } if (this.suggest != null) { generator.writeKey("suggest"); this.suggest.serialize(generator, mapper); } if (this.terminateAfter != null) { generator.writeKey("terminate_after"); generator.write(this.terminateAfter); } if (this.timeout != null) { generator.writeKey("timeout"); generator.write(this.timeout); } if (this.trackScores != null) { generator.writeKey("track_scores"); generator.write(this.trackScores); } if (this.trackTotalHits != null) { generator.writeKey("track_total_hits"); this.trackTotalHits.serialize(generator, mapper); } if (this.version != null) { generator.writeKey("version"); generator.write(this.version); } } // --------------------------------------------------------------------------------------------- /** * Builder for {@link SubmitRequest}. */ public static class Builder extends WithJsonObjectBuilderBase implements ObjectBuilder { @Nullable private SourceConfig source; @Nullable private Map aggregations; @Nullable private Boolean allowNoIndices; @Nullable private Boolean allowPartialSearchResults; @Nullable private Boolean analyzeWildcard; @Nullable private String analyzer; @Nullable private Long batchedReduceSize; @Nullable private Boolean ccsMinimizeRoundtrips; @Nullable private FieldCollapse collapse; @Nullable private Operator defaultOperator; @Nullable private String df; @Nullable private List docvalueFields; @Nullable private List expandWildcards; @Nullable private Boolean explain; @Nullable private List fields; @Nullable private Integer from; @Nullable private Highlight highlight; @Nullable private Boolean ignoreThrottled; @Nullable private Boolean ignoreUnavailable; @Nullable private List index; @Nullable private List> indicesBoost; @Nullable private Time keepAlive; @Nullable private Boolean keepOnCompletion; @Nullable private Boolean lenient; @Nullable private Long maxConcurrentShardRequests; @Nullable private String minCompatibleShardNode; @Nullable private Double minScore; @Nullable private PointInTimeReference pit; @Nullable private Query postFilter; @Nullable private Long preFilterShardSize; @Nullable private String preference; @Nullable private Boolean profile; @Nullable private String q; @Nullable private Query query; @Nullable private Boolean requestCache; @Nullable private List rescore; @Nullable private String routing; @Nullable private Map> runtimeMappings; @Nullable private Map scriptFields; @Nullable private Time scroll; @Nullable private List searchAfter; @Nullable private SearchType searchType; @Nullable private Boolean seqNoPrimaryTerm; @Nullable private Integer size; @Nullable private SlicedScroll slice; @Nullable private List sort; @Nullable private List stats; @Nullable private List storedFields; @Nullable private Suggester suggest; @Nullable private Long terminateAfter; @Nullable private String timeout; @Nullable private Boolean trackScores; @Nullable private TrackHits trackTotalHits; @Nullable private Boolean version; @Nullable private Time waitForCompletionTimeout; /** * Indicates which source fields are returned for matching documents. These * fields are returned in the hits._source property of the search response. * * API name: {@code _source} */ public final Builder source(@Nullable SourceConfig value) { this.source = value; return this; } /** * Indicates which source fields are returned for matching documents. These * fields are returned in the hits._source property of the search response. * * API name: {@code _source} */ public final Builder source(Function> fn) { return this.source(fn.apply(new SourceConfig.Builder()).build()); } /** * API name: {@code aggregations} * * Adds all entries of map to aggregations. */ public final Builder aggregations(Map map) { this.aggregations = _mapPutAll(this.aggregations, map); return this; } /** * API name: {@code aggregations} * * Adds an entry to aggregations. */ public final Builder aggregations(String key, Aggregation value) { this.aggregations = _mapPut(this.aggregations, key, value); return this; } /** * API name: {@code aggregations} * * Adds an entry to aggregations using a builder lambda. */ public final Builder aggregations(String key, Function> fn) { return aggregations(key, fn.apply(new Aggregation.Builder()).build()); } /** * Whether to ignore if a wildcard indices expression resolves into no concrete * indices. (This includes _all string or when no indices have been * specified) * * API name: {@code allow_no_indices} */ public final Builder allowNoIndices(@Nullable Boolean value) { this.allowNoIndices = value; return this; } /** * Indicate if an error should be returned if there is a partial search failure * or timeout * * API name: {@code allow_partial_search_results} */ public final Builder allowPartialSearchResults(@Nullable Boolean value) { this.allowPartialSearchResults = value; return this; } /** * Specify whether wildcard and prefix queries should be analyzed (default: * false) * * API name: {@code analyze_wildcard} */ public final Builder analyzeWildcard(@Nullable Boolean value) { this.analyzeWildcard = value; return this; } /** * The analyzer to use for the query string * * API name: {@code analyzer} */ public final Builder analyzer(@Nullable String value) { this.analyzer = value; return this; } /** * The number of shard results that should be reduced at once on the * coordinating node. This value should be used as the granularity at which * progress results will be made available. * * API name: {@code batched_reduce_size} */ public final Builder batchedReduceSize(@Nullable Long value) { this.batchedReduceSize = value; return this; } /** * API name: {@code ccs_minimize_roundtrips} */ public final Builder ccsMinimizeRoundtrips(@Nullable Boolean value) { this.ccsMinimizeRoundtrips = value; return this; } /** * API name: {@code collapse} */ public final Builder collapse(@Nullable FieldCollapse value) { this.collapse = value; return this; } /** * API name: {@code collapse} */ public final Builder collapse(Function> fn) { return this.collapse(fn.apply(new FieldCollapse.Builder()).build()); } /** * The default operator for query string query (AND or OR) * * API name: {@code default_operator} */ public final Builder defaultOperator(@Nullable Operator value) { this.defaultOperator = value; return this; } /** * The field to use as default where no field prefix is given in the query * string * * API name: {@code df} */ public final Builder df(@Nullable String value) { this.df = value; return this; } /** * Array of wildcard (*) patterns. The request returns doc values for field * names matching these patterns in the hits.fields property of the response. * * API name: {@code docvalue_fields} * * Adds all elements of list to docvalueFields. */ public final Builder docvalueFields(List list) { this.docvalueFields = _listAddAll(this.docvalueFields, list); return this; } /** * Array of wildcard (*) patterns. The request returns doc values for field * names matching these patterns in the hits.fields property of the response. * * API name: {@code docvalue_fields} * * Adds one or more values to docvalueFields. */ public final Builder docvalueFields(FieldAndFormat value, FieldAndFormat... values) { this.docvalueFields = _listAdd(this.docvalueFields, value, values); return this; } /** * Array of wildcard (*) patterns. The request returns doc values for field * names matching these patterns in the hits.fields property of the response. * * API name: {@code docvalue_fields} * * Adds a value to docvalueFields using a builder lambda. */ public final Builder docvalueFields(Function> fn) { return docvalueFields(fn.apply(new FieldAndFormat.Builder()).build()); } /** * Whether to expand wildcard expression to concrete indices that are open, * closed or both. * * API name: {@code expand_wildcards} * * Adds all elements of list to expandWildcards. */ public final Builder expandWildcards(List list) { this.expandWildcards = _listAddAll(this.expandWildcards, list); return this; } /** * Whether to expand wildcard expression to concrete indices that are open, * closed or both. * * API name: {@code expand_wildcards} * * Adds one or more values to expandWildcards. */ public final Builder expandWildcards(ExpandWildcard value, ExpandWildcard... values) { this.expandWildcards = _listAdd(this.expandWildcards, value, values); return this; } /** * If true, returns detailed information about score computation as part of a * hit. * * API name: {@code explain} */ public final Builder explain(@Nullable Boolean value) { this.explain = value; return this; } /** * Array of wildcard (*) patterns. The request returns values for field names * matching these patterns in the hits.fields property of the response. * * API name: {@code fields} * * Adds all elements of list to fields. */ public final Builder fields(List list) { this.fields = _listAddAll(this.fields, list); return this; } /** * Array of wildcard (*) patterns. The request returns values for field names * matching these patterns in the hits.fields property of the response. * * API name: {@code fields} * * Adds one or more values to fields. */ public final Builder fields(FieldAndFormat value, FieldAndFormat... values) { this.fields = _listAdd(this.fields, value, values); return this; } /** * Array of wildcard (*) patterns. The request returns values for field names * matching these patterns in the hits.fields property of the response. * * API name: {@code fields} * * Adds a value to fields using a builder lambda. */ public final Builder fields(Function> fn) { return fields(fn.apply(new FieldAndFormat.Builder()).build()); } /** * Starting document offset. By default, you cannot page through more than * 10,000 hits using the from and size parameters. To page through more hits, * use the search_after parameter. * * API name: {@code from} */ public final Builder from(@Nullable Integer value) { this.from = value; return this; } /** * API name: {@code highlight} */ public final Builder highlight(@Nullable Highlight value) { this.highlight = value; return this; } /** * API name: {@code highlight} */ public final Builder highlight(Function> fn) { return this.highlight(fn.apply(new Highlight.Builder()).build()); } /** * Whether specified concrete, expanded or aliased indices should be ignored * when throttled * * API name: {@code ignore_throttled} */ public final Builder ignoreThrottled(@Nullable Boolean value) { this.ignoreThrottled = value; return this; } /** * Whether specified concrete indices should be ignored when unavailable * (missing or closed) * * API name: {@code ignore_unavailable} */ public final Builder ignoreUnavailable(@Nullable Boolean value) { this.ignoreUnavailable = value; return this; } /** * A comma-separated list of index names to search; use _all or * empty string to perform the operation on all indices * * API name: {@code index} * * Adds all elements of list to index. */ public final Builder index(List list) { this.index = _listAddAll(this.index, list); return this; } /** * A comma-separated list of index names to search; use _all or * empty string to perform the operation on all indices * * API name: {@code index} * * Adds one or more values to index. */ public final Builder index(String value, String... values) { this.index = _listAdd(this.index, value, values); return this; } /** * Boosts the _score of documents from specified indices. * * API name: {@code indices_boost} * * Adds all elements of list to indicesBoost. */ public final Builder indicesBoost(List> list) { this.indicesBoost = _listAddAll(this.indicesBoost, list); return this; } /** * Boosts the _score of documents from specified indices. * * API name: {@code indices_boost} * * Adds one or more values to indicesBoost. */ public final Builder indicesBoost(Map value, Map... values) { this.indicesBoost = _listAdd(this.indicesBoost, value, values); return this; } /** * Update the time interval in which the results (partial or final) for this * search will be available * * API name: {@code keep_alive} */ public final Builder keepAlive(@Nullable Time value) { this.keepAlive = value; return this; } /** * Update the time interval in which the results (partial or final) for this * search will be available * * API name: {@code keep_alive} */ public final Builder keepAlive(Function> fn) { return this.keepAlive(fn.apply(new Time.Builder()).build()); } /** * Control whether the response should be stored in the cluster if it completed * within the provided [wait_for_completion] time (default: false) * * API name: {@code keep_on_completion} */ public final Builder keepOnCompletion(@Nullable Boolean value) { this.keepOnCompletion = value; return this; } /** * Specify whether format-based query failures (such as providing text to a * numeric field) should be ignored * * API name: {@code lenient} */ public final Builder lenient(@Nullable Boolean value) { this.lenient = value; return this; } /** * The number of concurrent shard requests per node this search executes * concurrently. This value should be used to limit the impact of the search on * the cluster in order to limit the number of concurrent shard requests * * API name: {@code max_concurrent_shard_requests} */ public final Builder maxConcurrentShardRequests(@Nullable Long value) { this.maxConcurrentShardRequests = value; return this; } /** * API name: {@code min_compatible_shard_node} */ public final Builder minCompatibleShardNode(@Nullable String value) { this.minCompatibleShardNode = value; return this; } /** * Minimum _score for matching documents. Documents with a lower _score are not * included in the search results. * * API name: {@code min_score} */ public final Builder minScore(@Nullable Double value) { this.minScore = value; return this; } /** * Limits the search to a point in time (PIT). If you provide a PIT, you cannot * specify an <index> in the request path. * * API name: {@code pit} */ public final Builder pit(@Nullable PointInTimeReference value) { this.pit = value; return this; } /** * Limits the search to a point in time (PIT). If you provide a PIT, you cannot * specify an <index> in the request path. * * API name: {@code pit} */ public final Builder pit(Function> fn) { return this.pit(fn.apply(new PointInTimeReference.Builder()).build()); } /** * API name: {@code post_filter} */ public final Builder postFilter(@Nullable Query value) { this.postFilter = value; return this; } /** * API name: {@code post_filter} */ public final Builder postFilter(Function> fn) { return this.postFilter(fn.apply(new Query.Builder()).build()); } /** * API name: {@code pre_filter_shard_size} */ public final Builder preFilterShardSize(@Nullable Long value) { this.preFilterShardSize = value; return this; } /** * Specify the node or shard the operation should be performed on (default: * random) * * API name: {@code preference} */ public final Builder preference(@Nullable String value) { this.preference = value; return this; } /** * API name: {@code profile} */ public final Builder profile(@Nullable Boolean value) { this.profile = value; return this; } /** * Query in the Lucene query string syntax * * API name: {@code q} */ public final Builder q(@Nullable String value) { this.q = value; return this; } /** * Defines the search definition using the Query DSL. * * API name: {@code query} */ public final Builder query(@Nullable Query value) { this.query = value; return this; } /** * Defines the search definition using the Query DSL. * * API name: {@code query} */ public final Builder query(Function> fn) { return this.query(fn.apply(new Query.Builder()).build()); } /** * Specify if request cache should be used for this request or not, defaults to * true * * API name: {@code request_cache} */ public final Builder requestCache(@Nullable Boolean value) { this.requestCache = value; return this; } /** * API name: {@code rescore} * * Adds all elements of list to rescore. */ public final Builder rescore(List list) { this.rescore = _listAddAll(this.rescore, list); return this; } /** * API name: {@code rescore} * * Adds one or more values to rescore. */ public final Builder rescore(Rescore value, Rescore... values) { this.rescore = _listAdd(this.rescore, value, values); return this; } /** * API name: {@code rescore} * * Adds a value to rescore using a builder lambda. */ public final Builder rescore(Function> fn) { return rescore(fn.apply(new Rescore.Builder()).build()); } /** * A comma-separated list of specific routing values * * API name: {@code routing} */ public final Builder routing(@Nullable String value) { this.routing = value; return this; } /** * Defines one or more runtime fields in the search request. These fields take * precedence over mapped fields with the same name. * * API name: {@code runtime_mappings} * * Adds all entries of map to runtimeMappings. */ public final Builder runtimeMappings(Map> map) { this.runtimeMappings = _mapPutAll(this.runtimeMappings, map); return this; } /** * Defines one or more runtime fields in the search request. These fields take * precedence over mapped fields with the same name. * * API name: {@code runtime_mappings} * * Adds an entry to runtimeMappings. */ public final Builder runtimeMappings(String key, List value) { this.runtimeMappings = _mapPut(this.runtimeMappings, key, value); return this; } /** * Retrieve a script evaluation (based on different fields) for each hit. * * API name: {@code script_fields} * * Adds all entries of map to scriptFields. */ public final Builder scriptFields(Map map) { this.scriptFields = _mapPutAll(this.scriptFields, map); return this; } /** * Retrieve a script evaluation (based on different fields) for each hit. * * API name: {@code script_fields} * * Adds an entry to scriptFields. */ public final Builder scriptFields(String key, ScriptField value) { this.scriptFields = _mapPut(this.scriptFields, key, value); return this; } /** * Retrieve a script evaluation (based on different fields) for each hit. * * API name: {@code script_fields} * * Adds an entry to scriptFields using a builder lambda. */ public final Builder scriptFields(String key, Function> fn) { return scriptFields(key, fn.apply(new ScriptField.Builder()).build()); } /** * API name: {@code scroll} */ public final Builder scroll(@Nullable Time value) { this.scroll = value; return this; } /** * API name: {@code scroll} */ public final Builder scroll(Function> fn) { return this.scroll(fn.apply(new Time.Builder()).build()); } /** * API name: {@code search_after} * * Adds all elements of list to searchAfter. */ public final Builder searchAfter(List list) { this.searchAfter = _listAddAll(this.searchAfter, list); return this; } /** * API name: {@code search_after} * * Adds one or more values to searchAfter. */ public final Builder searchAfter(String value, String... values) { this.searchAfter = _listAdd(this.searchAfter, value, values); return this; } /** * Search operation type * * API name: {@code search_type} */ public final Builder searchType(@Nullable SearchType value) { this.searchType = value; return this; } /** * If true, returns sequence number and primary term of the last modification of * each hit. See Optimistic concurrency control. * * API name: {@code seq_no_primary_term} */ public final Builder seqNoPrimaryTerm(@Nullable Boolean value) { this.seqNoPrimaryTerm = value; return this; } /** * The number of hits to return. By default, you cannot page through more than * 10,000 hits using the from and size parameters. To page through more hits, * use the search_after parameter. * * API name: {@code size} */ public final Builder size(@Nullable Integer value) { this.size = value; return this; } /** * API name: {@code slice} */ public final Builder slice(@Nullable SlicedScroll value) { this.slice = value; return this; } /** * API name: {@code slice} */ public final Builder slice(Function> fn) { return this.slice(fn.apply(new SlicedScroll.Builder()).build()); } /** * API name: {@code sort} * * Adds all elements of list to sort. */ public final Builder sort(List list) { this.sort = _listAddAll(this.sort, list); return this; } /** * API name: {@code sort} * * Adds one or more values to sort. */ public final Builder sort(SortOptions value, SortOptions... values) { this.sort = _listAdd(this.sort, value, values); return this; } /** * API name: {@code sort} * * Adds a value to sort using a builder lambda. */ public final Builder sort(Function> fn) { return sort(fn.apply(new SortOptions.Builder()).build()); } /** * Stats groups to associate with the search. Each group maintains a statistics * aggregation for its associated searches. You can retrieve these stats using * the indices stats API. * * API name: {@code stats} * * Adds all elements of list to stats. */ public final Builder stats(List list) { this.stats = _listAddAll(this.stats, list); return this; } /** * Stats groups to associate with the search. Each group maintains a statistics * aggregation for its associated searches. You can retrieve these stats using * the indices stats API. * * API name: {@code stats} * * Adds one or more values to stats. */ public final Builder stats(String value, String... values) { this.stats = _listAdd(this.stats, value, values); return this; } /** * List of stored fields to return as part of a hit. If no fields are specified, * no stored fields are included in the response. If this field is specified, * the _source parameter defaults to false. You can pass _source: true to return * both source fields and stored fields in the search response. * * API name: {@code stored_fields} * * Adds all elements of list to storedFields. */ public final Builder storedFields(List list) { this.storedFields = _listAddAll(this.storedFields, list); return this; } /** * List of stored fields to return as part of a hit. If no fields are specified, * no stored fields are included in the response. If this field is specified, * the _source parameter defaults to false. You can pass _source: true to return * both source fields and stored fields in the search response. * * API name: {@code stored_fields} * * Adds one or more values to storedFields. */ public final Builder storedFields(String value, String... values) { this.storedFields = _listAdd(this.storedFields, value, values); return this; } /** * API name: {@code suggest} */ public final Builder suggest(@Nullable Suggester value) { this.suggest = value; return this; } /** * API name: {@code suggest} */ public final Builder suggest(Function> fn) { return this.suggest(fn.apply(new Suggester.Builder()).build()); } /** * Maximum number of documents to collect for each shard. If a query reaches * this limit, Elasticsearch terminates the query early. Elasticsearch collects * documents before sorting. Defaults to 0, which does not terminate query * execution early. * * API name: {@code terminate_after} */ public final Builder terminateAfter(@Nullable Long value) { this.terminateAfter = value; return this; } /** * Specifies the period of time to wait for a response from each shard. If no * response is received before the timeout expires, the request fails and * returns an error. Defaults to no timeout. * * API name: {@code timeout} */ public final Builder timeout(@Nullable String value) { this.timeout = value; return this; } /** * If true, calculate and return document scores, even if the scores are not * used for sorting. * * API name: {@code track_scores} */ public final Builder trackScores(@Nullable Boolean value) { this.trackScores = value; return this; } /** * Number of hits matching the query to count accurately. If true, the exact * number of hits is returned at the cost of some performance. If false, the * response does not include the total number of hits matching the query. * Defaults to 10,000 hits. * * API name: {@code track_total_hits} */ public final Builder trackTotalHits(@Nullable TrackHits value) { this.trackTotalHits = value; return this; } /** * Number of hits matching the query to count accurately. If true, the exact * number of hits is returned at the cost of some performance. If false, the * response does not include the total number of hits matching the query. * Defaults to 10,000 hits. * * API name: {@code track_total_hits} */ public final Builder trackTotalHits(Function> fn) { return this.trackTotalHits(fn.apply(new TrackHits.Builder()).build()); } /** * If true, returns document version as part of a hit. * * API name: {@code version} */ public final Builder version(@Nullable Boolean value) { this.version = value; return this; } /** * Specify the time that the request should block waiting for the final response * * API name: {@code wait_for_completion_timeout} */ public final Builder waitForCompletionTimeout(@Nullable Time value) { this.waitForCompletionTimeout = value; return this; } /** * Specify the time that the request should block waiting for the final response * * API name: {@code wait_for_completion_timeout} */ public final Builder waitForCompletionTimeout(Function> fn) { return this.waitForCompletionTimeout(fn.apply(new Time.Builder()).build()); } @Override protected Builder self() { return this; } /** * Builds a {@link SubmitRequest}. * * @throws NullPointerException * if some of the required fields are null. */ public SubmitRequest build() { _checkSingleUse(); return new SubmitRequest(this); } } // --------------------------------------------------------------------------------------------- /** * Json deserializer for {@link SubmitRequest} */ public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy(Builder::new, SubmitRequest::setupSubmitRequestDeserializer); protected static void setupSubmitRequestDeserializer(ObjectDeserializer op) { op.add(Builder::source, SourceConfig._DESERIALIZER, "_source"); op.add(Builder::aggregations, JsonpDeserializer.stringMapDeserializer(Aggregation._DESERIALIZER), "aggregations", "aggs"); op.add(Builder::collapse, FieldCollapse._DESERIALIZER, "collapse"); op.add(Builder::docvalueFields, JsonpDeserializer.arrayDeserializer(FieldAndFormat._DESERIALIZER), "docvalue_fields"); op.add(Builder::explain, JsonpDeserializer.booleanDeserializer(), "explain"); op.add(Builder::fields, JsonpDeserializer.arrayDeserializer(FieldAndFormat._DESERIALIZER), "fields"); op.add(Builder::from, JsonpDeserializer.integerDeserializer(), "from"); op.add(Builder::highlight, Highlight._DESERIALIZER, "highlight"); op.add(Builder::indicesBoost, JsonpDeserializer.arrayDeserializer( JsonpDeserializer.stringMapDeserializer(JsonpDeserializer.doubleDeserializer())), "indices_boost"); op.add(Builder::minScore, JsonpDeserializer.doubleDeserializer(), "min_score"); op.add(Builder::pit, PointInTimeReference._DESERIALIZER, "pit"); op.add(Builder::postFilter, Query._DESERIALIZER, "post_filter"); op.add(Builder::profile, JsonpDeserializer.booleanDeserializer(), "profile"); op.add(Builder::query, Query._DESERIALIZER, "query"); op.add(Builder::rescore, JsonpDeserializer.arrayDeserializer(Rescore._DESERIALIZER), "rescore"); op.add(Builder::runtimeMappings, JsonpDeserializer.stringMapDeserializer( JsonpDeserializer.arrayDeserializer(RuntimeField._DESERIALIZER)), "runtime_mappings"); op.add(Builder::scriptFields, JsonpDeserializer.stringMapDeserializer(ScriptField._DESERIALIZER), "script_fields"); op.add(Builder::searchAfter, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "search_after"); op.add(Builder::seqNoPrimaryTerm, JsonpDeserializer.booleanDeserializer(), "seq_no_primary_term"); op.add(Builder::size, JsonpDeserializer.integerDeserializer(), "size"); op.add(Builder::slice, SlicedScroll._DESERIALIZER, "slice"); op.add(Builder::sort, JsonpDeserializer.arrayDeserializer(SortOptions._DESERIALIZER), "sort"); op.add(Builder::stats, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "stats"); op.add(Builder::storedFields, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "stored_fields"); op.add(Builder::suggest, Suggester._DESERIALIZER, "suggest"); op.add(Builder::terminateAfter, JsonpDeserializer.longDeserializer(), "terminate_after"); op.add(Builder::timeout, JsonpDeserializer.stringDeserializer(), "timeout"); op.add(Builder::trackScores, JsonpDeserializer.booleanDeserializer(), "track_scores"); op.add(Builder::trackTotalHits, TrackHits._DESERIALIZER, "track_total_hits"); op.add(Builder::version, JsonpDeserializer.booleanDeserializer(), "version"); } // --------------------------------------------------------------------------------------------- /** * Endpoint "{@code async_search.submit}". */ public static final SimpleEndpoint _ENDPOINT = new SimpleEndpoint<>("es/async_search.submit", // Request method request -> { return "POST"; }, // Request path request -> { final int _index = 1 << 0; int propsSet = 0; if (ApiTypeHelper.isDefined(request.index())) propsSet |= _index; if (propsSet == 0) { StringBuilder buf = new StringBuilder(); buf.append("/_async_search"); return buf.toString(); } if (propsSet == (_index)) { StringBuilder buf = new StringBuilder(); buf.append("/"); SimpleEndpoint.pathEncode(request.index.stream().map(v -> v).collect(Collectors.joining(",")), buf); buf.append("/_async_search"); return buf.toString(); } throw SimpleEndpoint.noPathTemplateFound("path"); }, // Request parameters request -> { Map params = new HashMap<>(); params.put("typed_keys", "true"); if (request.df != null) { params.put("df", request.df); } if (request.preFilterShardSize != null) { params.put("pre_filter_shard_size", String.valueOf(request.preFilterShardSize)); } if (request.minCompatibleShardNode != null) { params.put("min_compatible_shard_node", request.minCompatibleShardNode); } if (request.lenient != null) { params.put("lenient", String.valueOf(request.lenient)); } if (request.routing != null) { params.put("routing", request.routing); } if (request.ignoreUnavailable != null) { params.put("ignore_unavailable", String.valueOf(request.ignoreUnavailable)); } if (request.allowNoIndices != null) { params.put("allow_no_indices", String.valueOf(request.allowNoIndices)); } if (request.analyzer != null) { params.put("analyzer", request.analyzer); } if (request.ignoreThrottled != null) { params.put("ignore_throttled", String.valueOf(request.ignoreThrottled)); } if (request.keepOnCompletion != null) { params.put("keep_on_completion", String.valueOf(request.keepOnCompletion)); } if (request.maxConcurrentShardRequests != null) { params.put("max_concurrent_shard_requests", String.valueOf(request.maxConcurrentShardRequests)); } if (request.allowPartialSearchResults != null) { params.put("allow_partial_search_results", String.valueOf(request.allowPartialSearchResults)); } if (ApiTypeHelper.isDefined(request.expandWildcards)) { params.put("expand_wildcards", request.expandWildcards.stream().map(v -> v.jsonValue()).collect(Collectors.joining(","))); } if (request.preference != null) { params.put("preference", request.preference); } if (request.analyzeWildcard != null) { params.put("analyze_wildcard", String.valueOf(request.analyzeWildcard)); } if (request.scroll != null) { params.put("scroll", request.scroll._toJsonString()); } if (request.waitForCompletionTimeout != null) { params.put("wait_for_completion_timeout", request.waitForCompletionTimeout._toJsonString()); } if (request.searchType != null) { params.put("search_type", request.searchType.jsonValue()); } if (request.ccsMinimizeRoundtrips != null) { params.put("ccs_minimize_roundtrips", String.valueOf(request.ccsMinimizeRoundtrips)); } if (request.q != null) { params.put("q", request.q); } if (request.defaultOperator != null) { params.put("default_operator", request.defaultOperator.jsonValue()); } if (request.keepAlive != null) { params.put("keep_alive", request.keepAlive._toJsonString()); } if (request.requestCache != null) { params.put("request_cache", String.valueOf(request.requestCache)); } if (request.batchedReduceSize != null) { params.put("batched_reduce_size", String.valueOf(request.batchedReduceSize)); } return params; }, SimpleEndpoint.emptyMap(), true, SubmitResponse._DESERIALIZER); /** * Create an "{@code async_search.submit}" endpoint. */ public static Endpoint, ErrorResponse> createSubmitEndpoint( JsonpDeserializer tDocumentDeserializer) { return _ENDPOINT .withResponseDeserializer(SubmitResponse.createSubmitResponseDeserializer(tDocumentDeserializer)); } }
* API name: {@code stored_fields} */ public final List storedFields() { return this.storedFields; } /** * API name: {@code suggest} */ @Nullable public final Suggester suggest() { return this.suggest; } /** * Maximum number of documents to collect for each shard. If a query reaches * this limit, Elasticsearch terminates the query early. Elasticsearch collects * documents before sorting. Defaults to 0, which does not terminate query * execution early. * * API name: {@code terminate_after} */ @Nullable public final Long terminateAfter() { return this.terminateAfter; } /** * Specifies the period of time to wait for a response from each shard. If no * response is received before the timeout expires, the request fails and * returns an error. Defaults to no timeout. * * API name: {@code timeout} */ @Nullable public final String timeout() { return this.timeout; } /** * If true, calculate and return document scores, even if the scores are not * used for sorting. * * API name: {@code track_scores} */ @Nullable public final Boolean trackScores() { return this.trackScores; } /** * Number of hits matching the query to count accurately. If true, the exact * number of hits is returned at the cost of some performance. If false, the * response does not include the total number of hits matching the query. * Defaults to 10,000 hits. * * API name: {@code track_total_hits} */ @Nullable public final TrackHits trackTotalHits() { return this.trackTotalHits; } /** * If true, returns document version as part of a hit. * * API name: {@code version} */ @Nullable public final Boolean version() { return this.version; } /** * Specify the time that the request should block waiting for the final response * * API name: {@code wait_for_completion_timeout} */ @Nullable public final Time waitForCompletionTimeout() { return this.waitForCompletionTimeout; } /** * 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.source != null) { generator.writeKey("_source"); this.source.serialize(generator, mapper); } if (ApiTypeHelper.isDefined(this.aggregations)) { generator.writeKey("aggregations"); generator.writeStartObject(); for (Map.Entry item0 : this.aggregations.entrySet()) { generator.writeKey(item0.getKey()); item0.getValue().serialize(generator, mapper); } generator.writeEnd(); } if (this.collapse != null) { generator.writeKey("collapse"); this.collapse.serialize(generator, mapper); } if (ApiTypeHelper.isDefined(this.docvalueFields)) { generator.writeKey("docvalue_fields"); generator.writeStartArray(); for (FieldAndFormat item0 : this.docvalueFields) { item0.serialize(generator, mapper); } generator.writeEnd(); } if (this.explain != null) { generator.writeKey("explain"); generator.write(this.explain); } if (ApiTypeHelper.isDefined(this.fields)) { generator.writeKey("fields"); generator.writeStartArray(); for (FieldAndFormat item0 : this.fields) { item0.serialize(generator, mapper); } generator.writeEnd(); } if (this.from != null) { generator.writeKey("from"); generator.write(this.from); } if (this.highlight != null) { generator.writeKey("highlight"); this.highlight.serialize(generator, mapper); } if (ApiTypeHelper.isDefined(this.indicesBoost)) { generator.writeKey("indices_boost"); generator.writeStartArray(); for (Map item0 : this.indicesBoost) { generator.writeStartObject(); if (item0 != null) { for (Map.Entry item1 : item0.entrySet()) { generator.writeKey(item1.getKey()); generator.write(item1.getValue()); } } generator.writeEnd(); } generator.writeEnd(); } if (this.minScore != null) { generator.writeKey("min_score"); generator.write(this.minScore); } if (this.pit != null) { generator.writeKey("pit"); this.pit.serialize(generator, mapper); } if (this.postFilter != null) { generator.writeKey("post_filter"); this.postFilter.serialize(generator, mapper); } if (this.profile != null) { generator.writeKey("profile"); generator.write(this.profile); } if (this.query != null) { generator.writeKey("query"); this.query.serialize(generator, mapper); } if (ApiTypeHelper.isDefined(this.rescore)) { generator.writeKey("rescore"); generator.writeStartArray(); for (Rescore item0 : this.rescore) { item0.serialize(generator, mapper); } generator.writeEnd(); } if (ApiTypeHelper.isDefined(this.runtimeMappings)) { generator.writeKey("runtime_mappings"); generator.writeStartObject(); for (Map.Entry> item0 : this.runtimeMappings.entrySet()) { generator.writeKey(item0.getKey()); generator.writeStartArray(); if (item0.getValue() != null) { for (RuntimeField item1 : item0.getValue()) { item1.serialize(generator, mapper); } } generator.writeEnd(); } generator.writeEnd(); } if (ApiTypeHelper.isDefined(this.scriptFields)) { generator.writeKey("script_fields"); generator.writeStartObject(); for (Map.Entry item0 : this.scriptFields.entrySet()) { generator.writeKey(item0.getKey()); item0.getValue().serialize(generator, mapper); } generator.writeEnd(); } if (ApiTypeHelper.isDefined(this.searchAfter)) { generator.writeKey("search_after"); generator.writeStartArray(); for (String item0 : this.searchAfter) { generator.write(item0); } generator.writeEnd(); } if (this.seqNoPrimaryTerm != null) { generator.writeKey("seq_no_primary_term"); generator.write(this.seqNoPrimaryTerm); } if (this.size != null) { generator.writeKey("size"); generator.write(this.size); } if (this.slice != null) { generator.writeKey("slice"); this.slice.serialize(generator, mapper); } if (ApiTypeHelper.isDefined(this.sort)) { generator.writeKey("sort"); generator.writeStartArray(); for (SortOptions item0 : this.sort) { item0.serialize(generator, mapper); } generator.writeEnd(); } if (ApiTypeHelper.isDefined(this.stats)) { generator.writeKey("stats"); generator.writeStartArray(); for (String item0 : this.stats) { generator.write(item0); } generator.writeEnd(); } if (ApiTypeHelper.isDefined(this.storedFields)) { generator.writeKey("stored_fields"); generator.writeStartArray(); for (String item0 : this.storedFields) { generator.write(item0); } generator.writeEnd(); } if (this.suggest != null) { generator.writeKey("suggest"); this.suggest.serialize(generator, mapper); } if (this.terminateAfter != null) { generator.writeKey("terminate_after"); generator.write(this.terminateAfter); } if (this.timeout != null) { generator.writeKey("timeout"); generator.write(this.timeout); } if (this.trackScores != null) { generator.writeKey("track_scores"); generator.write(this.trackScores); } if (this.trackTotalHits != null) { generator.writeKey("track_total_hits"); this.trackTotalHits.serialize(generator, mapper); } if (this.version != null) { generator.writeKey("version"); generator.write(this.version); } } // --------------------------------------------------------------------------------------------- /** * Builder for {@link SubmitRequest}. */ public static class Builder extends WithJsonObjectBuilderBase implements ObjectBuilder { @Nullable private SourceConfig source; @Nullable private Map aggregations; @Nullable private Boolean allowNoIndices; @Nullable private Boolean allowPartialSearchResults; @Nullable private Boolean analyzeWildcard; @Nullable private String analyzer; @Nullable private Long batchedReduceSize; @Nullable private Boolean ccsMinimizeRoundtrips; @Nullable private FieldCollapse collapse; @Nullable private Operator defaultOperator; @Nullable private String df; @Nullable private List docvalueFields; @Nullable private List expandWildcards; @Nullable private Boolean explain; @Nullable private List fields; @Nullable private Integer from; @Nullable private Highlight highlight; @Nullable private Boolean ignoreThrottled; @Nullable private Boolean ignoreUnavailable; @Nullable private List index; @Nullable private List> indicesBoost; @Nullable private Time keepAlive; @Nullable private Boolean keepOnCompletion; @Nullable private Boolean lenient; @Nullable private Long maxConcurrentShardRequests; @Nullable private String minCompatibleShardNode; @Nullable private Double minScore; @Nullable private PointInTimeReference pit; @Nullable private Query postFilter; @Nullable private Long preFilterShardSize; @Nullable private String preference; @Nullable private Boolean profile; @Nullable private String q; @Nullable private Query query; @Nullable private Boolean requestCache; @Nullable private List rescore; @Nullable private String routing; @Nullable private Map> runtimeMappings; @Nullable private Map scriptFields; @Nullable private Time scroll; @Nullable private List searchAfter; @Nullable private SearchType searchType; @Nullable private Boolean seqNoPrimaryTerm; @Nullable private Integer size; @Nullable private SlicedScroll slice; @Nullable private List sort; @Nullable private List stats; @Nullable private List storedFields; @Nullable private Suggester suggest; @Nullable private Long terminateAfter; @Nullable private String timeout; @Nullable private Boolean trackScores; @Nullable private TrackHits trackTotalHits; @Nullable private Boolean version; @Nullable private Time waitForCompletionTimeout; /** * Indicates which source fields are returned for matching documents. These * fields are returned in the hits._source property of the search response. * * API name: {@code _source} */ public final Builder source(@Nullable SourceConfig value) { this.source = value; return this; } /** * Indicates which source fields are returned for matching documents. These * fields are returned in the hits._source property of the search response. * * API name: {@code _source} */ public final Builder source(Function> fn) { return this.source(fn.apply(new SourceConfig.Builder()).build()); } /** * API name: {@code aggregations} * * Adds all entries of map to aggregations. */ public final Builder aggregations(Map map) { this.aggregations = _mapPutAll(this.aggregations, map); return this; } /** * API name: {@code aggregations} * * Adds an entry to aggregations. */ public final Builder aggregations(String key, Aggregation value) { this.aggregations = _mapPut(this.aggregations, key, value); return this; } /** * API name: {@code aggregations} * * Adds an entry to aggregations using a builder lambda. */ public final Builder aggregations(String key, Function> fn) { return aggregations(key, fn.apply(new Aggregation.Builder()).build()); } /** * Whether to ignore if a wildcard indices expression resolves into no concrete * indices. (This includes _all string or when no indices have been * specified) * * API name: {@code allow_no_indices} */ public final Builder allowNoIndices(@Nullable Boolean value) { this.allowNoIndices = value; return this; } /** * Indicate if an error should be returned if there is a partial search failure * or timeout * * API name: {@code allow_partial_search_results} */ public final Builder allowPartialSearchResults(@Nullable Boolean value) { this.allowPartialSearchResults = value; return this; } /** * Specify whether wildcard and prefix queries should be analyzed (default: * false) * * API name: {@code analyze_wildcard} */ public final Builder analyzeWildcard(@Nullable Boolean value) { this.analyzeWildcard = value; return this; } /** * The analyzer to use for the query string * * API name: {@code analyzer} */ public final Builder analyzer(@Nullable String value) { this.analyzer = value; return this; } /** * The number of shard results that should be reduced at once on the * coordinating node. This value should be used as the granularity at which * progress results will be made available. * * API name: {@code batched_reduce_size} */ public final Builder batchedReduceSize(@Nullable Long value) { this.batchedReduceSize = value; return this; } /** * API name: {@code ccs_minimize_roundtrips} */ public final Builder ccsMinimizeRoundtrips(@Nullable Boolean value) { this.ccsMinimizeRoundtrips = value; return this; } /** * API name: {@code collapse} */ public final Builder collapse(@Nullable FieldCollapse value) { this.collapse = value; return this; } /** * API name: {@code collapse} */ public final Builder collapse(Function> fn) { return this.collapse(fn.apply(new FieldCollapse.Builder()).build()); } /** * The default operator for query string query (AND or OR) * * API name: {@code default_operator} */ public final Builder defaultOperator(@Nullable Operator value) { this.defaultOperator = value; return this; } /** * The field to use as default where no field prefix is given in the query * string * * API name: {@code df} */ public final Builder df(@Nullable String value) { this.df = value; return this; } /** * Array of wildcard (*) patterns. The request returns doc values for field * names matching these patterns in the hits.fields property of the response. * * API name: {@code docvalue_fields} * * Adds all elements of list to docvalueFields. */ public final Builder docvalueFields(List list) { this.docvalueFields = _listAddAll(this.docvalueFields, list); return this; } /** * Array of wildcard (*) patterns. The request returns doc values for field * names matching these patterns in the hits.fields property of the response. * * API name: {@code docvalue_fields} * * Adds one or more values to docvalueFields. */ public final Builder docvalueFields(FieldAndFormat value, FieldAndFormat... values) { this.docvalueFields = _listAdd(this.docvalueFields, value, values); return this; } /** * Array of wildcard (*) patterns. The request returns doc values for field * names matching these patterns in the hits.fields property of the response. * * API name: {@code docvalue_fields} * * Adds a value to docvalueFields using a builder lambda. */ public final Builder docvalueFields(Function> fn) { return docvalueFields(fn.apply(new FieldAndFormat.Builder()).build()); } /** * Whether to expand wildcard expression to concrete indices that are open, * closed or both. * * API name: {@code expand_wildcards} * * Adds all elements of list to expandWildcards. */ public final Builder expandWildcards(List list) { this.expandWildcards = _listAddAll(this.expandWildcards, list); return this; } /** * Whether to expand wildcard expression to concrete indices that are open, * closed or both. * * API name: {@code expand_wildcards} * * Adds one or more values to expandWildcards. */ public final Builder expandWildcards(ExpandWildcard value, ExpandWildcard... values) { this.expandWildcards = _listAdd(this.expandWildcards, value, values); return this; } /** * If true, returns detailed information about score computation as part of a * hit. * * API name: {@code explain} */ public final Builder explain(@Nullable Boolean value) { this.explain = value; return this; } /** * Array of wildcard (*) patterns. The request returns values for field names * matching these patterns in the hits.fields property of the response. * * API name: {@code fields} * * Adds all elements of list to fields. */ public final Builder fields(List list) { this.fields = _listAddAll(this.fields, list); return this; } /** * Array of wildcard (*) patterns. The request returns values for field names * matching these patterns in the hits.fields property of the response. * * API name: {@code fields} * * Adds one or more values to fields. */ public final Builder fields(FieldAndFormat value, FieldAndFormat... values) { this.fields = _listAdd(this.fields, value, values); return this; } /** * Array of wildcard (*) patterns. The request returns values for field names * matching these patterns in the hits.fields property of the response. * * API name: {@code fields} * * Adds a value to fields using a builder lambda. */ public final Builder fields(Function> fn) { return fields(fn.apply(new FieldAndFormat.Builder()).build()); } /** * Starting document offset. By default, you cannot page through more than * 10,000 hits using the from and size parameters. To page through more hits, * use the search_after parameter. * * API name: {@code from} */ public final Builder from(@Nullable Integer value) { this.from = value; return this; } /** * API name: {@code highlight} */ public final Builder highlight(@Nullable Highlight value) { this.highlight = value; return this; } /** * API name: {@code highlight} */ public final Builder highlight(Function> fn) { return this.highlight(fn.apply(new Highlight.Builder()).build()); } /** * Whether specified concrete, expanded or aliased indices should be ignored * when throttled * * API name: {@code ignore_throttled} */ public final Builder ignoreThrottled(@Nullable Boolean value) { this.ignoreThrottled = value; return this; } /** * Whether specified concrete indices should be ignored when unavailable * (missing or closed) * * API name: {@code ignore_unavailable} */ public final Builder ignoreUnavailable(@Nullable Boolean value) { this.ignoreUnavailable = value; return this; } /** * A comma-separated list of index names to search; use _all or * empty string to perform the operation on all indices * * API name: {@code index} * * Adds all elements of list to index. */ public final Builder index(List list) { this.index = _listAddAll(this.index, list); return this; } /** * A comma-separated list of index names to search; use _all or * empty string to perform the operation on all indices * * API name: {@code index} * * Adds one or more values to index. */ public final Builder index(String value, String... values) { this.index = _listAdd(this.index, value, values); return this; } /** * Boosts the _score of documents from specified indices. * * API name: {@code indices_boost} * * Adds all elements of list to indicesBoost. */ public final Builder indicesBoost(List> list) { this.indicesBoost = _listAddAll(this.indicesBoost, list); return this; } /** * Boosts the _score of documents from specified indices. * * API name: {@code indices_boost} * * Adds one or more values to indicesBoost. */ public final Builder indicesBoost(Map value, Map... values) { this.indicesBoost = _listAdd(this.indicesBoost, value, values); return this; } /** * Update the time interval in which the results (partial or final) for this * search will be available * * API name: {@code keep_alive} */ public final Builder keepAlive(@Nullable Time value) { this.keepAlive = value; return this; } /** * Update the time interval in which the results (partial or final) for this * search will be available * * API name: {@code keep_alive} */ public final Builder keepAlive(Function> fn) { return this.keepAlive(fn.apply(new Time.Builder()).build()); } /** * Control whether the response should be stored in the cluster if it completed * within the provided [wait_for_completion] time (default: false) * * API name: {@code keep_on_completion} */ public final Builder keepOnCompletion(@Nullable Boolean value) { this.keepOnCompletion = value; return this; } /** * Specify whether format-based query failures (such as providing text to a * numeric field) should be ignored * * API name: {@code lenient} */ public final Builder lenient(@Nullable Boolean value) { this.lenient = value; return this; } /** * The number of concurrent shard requests per node this search executes * concurrently. This value should be used to limit the impact of the search on * the cluster in order to limit the number of concurrent shard requests * * API name: {@code max_concurrent_shard_requests} */ public final Builder maxConcurrentShardRequests(@Nullable Long value) { this.maxConcurrentShardRequests = value; return this; } /** * API name: {@code min_compatible_shard_node} */ public final Builder minCompatibleShardNode(@Nullable String value) { this.minCompatibleShardNode = value; return this; } /** * Minimum _score for matching documents. Documents with a lower _score are not * included in the search results. * * API name: {@code min_score} */ public final Builder minScore(@Nullable Double value) { this.minScore = value; return this; } /** * Limits the search to a point in time (PIT). If you provide a PIT, you cannot * specify an <index> in the request path. * * API name: {@code pit} */ public final Builder pit(@Nullable PointInTimeReference value) { this.pit = value; return this; } /** * Limits the search to a point in time (PIT). If you provide a PIT, you cannot * specify an <index> in the request path. * * API name: {@code pit} */ public final Builder pit(Function> fn) { return this.pit(fn.apply(new PointInTimeReference.Builder()).build()); } /** * API name: {@code post_filter} */ public final Builder postFilter(@Nullable Query value) { this.postFilter = value; return this; } /** * API name: {@code post_filter} */ public final Builder postFilter(Function> fn) { return this.postFilter(fn.apply(new Query.Builder()).build()); } /** * API name: {@code pre_filter_shard_size} */ public final Builder preFilterShardSize(@Nullable Long value) { this.preFilterShardSize = value; return this; } /** * Specify the node or shard the operation should be performed on (default: * random) * * API name: {@code preference} */ public final Builder preference(@Nullable String value) { this.preference = value; return this; } /** * API name: {@code profile} */ public final Builder profile(@Nullable Boolean value) { this.profile = value; return this; } /** * Query in the Lucene query string syntax * * API name: {@code q} */ public final Builder q(@Nullable String value) { this.q = value; return this; } /** * Defines the search definition using the Query DSL. * * API name: {@code query} */ public final Builder query(@Nullable Query value) { this.query = value; return this; } /** * Defines the search definition using the Query DSL. * * API name: {@code query} */ public final Builder query(Function> fn) { return this.query(fn.apply(new Query.Builder()).build()); } /** * Specify if request cache should be used for this request or not, defaults to * true * * API name: {@code request_cache} */ public final Builder requestCache(@Nullable Boolean value) { this.requestCache = value; return this; } /** * API name: {@code rescore} * * Adds all elements of list to rescore. */ public final Builder rescore(List list) { this.rescore = _listAddAll(this.rescore, list); return this; } /** * API name: {@code rescore} * * Adds one or more values to rescore. */ public final Builder rescore(Rescore value, Rescore... values) { this.rescore = _listAdd(this.rescore, value, values); return this; } /** * API name: {@code rescore} * * Adds a value to rescore using a builder lambda. */ public final Builder rescore(Function> fn) { return rescore(fn.apply(new Rescore.Builder()).build()); } /** * A comma-separated list of specific routing values * * API name: {@code routing} */ public final Builder routing(@Nullable String value) { this.routing = value; return this; } /** * Defines one or more runtime fields in the search request. These fields take * precedence over mapped fields with the same name. * * API name: {@code runtime_mappings} * * Adds all entries of map to runtimeMappings. */ public final Builder runtimeMappings(Map> map) { this.runtimeMappings = _mapPutAll(this.runtimeMappings, map); return this; } /** * Defines one or more runtime fields in the search request. These fields take * precedence over mapped fields with the same name. * * API name: {@code runtime_mappings} * * Adds an entry to runtimeMappings. */ public final Builder runtimeMappings(String key, List value) { this.runtimeMappings = _mapPut(this.runtimeMappings, key, value); return this; } /** * Retrieve a script evaluation (based on different fields) for each hit. * * API name: {@code script_fields} * * Adds all entries of map to scriptFields. */ public final Builder scriptFields(Map map) { this.scriptFields = _mapPutAll(this.scriptFields, map); return this; } /** * Retrieve a script evaluation (based on different fields) for each hit. * * API name: {@code script_fields} * * Adds an entry to scriptFields. */ public final Builder scriptFields(String key, ScriptField value) { this.scriptFields = _mapPut(this.scriptFields, key, value); return this; } /** * Retrieve a script evaluation (based on different fields) for each hit. * * API name: {@code script_fields} * * Adds an entry to scriptFields using a builder lambda. */ public final Builder scriptFields(String key, Function> fn) { return scriptFields(key, fn.apply(new ScriptField.Builder()).build()); } /** * API name: {@code scroll} */ public final Builder scroll(@Nullable Time value) { this.scroll = value; return this; } /** * API name: {@code scroll} */ public final Builder scroll(Function> fn) { return this.scroll(fn.apply(new Time.Builder()).build()); } /** * API name: {@code search_after} * * Adds all elements of list to searchAfter. */ public final Builder searchAfter(List list) { this.searchAfter = _listAddAll(this.searchAfter, list); return this; } /** * API name: {@code search_after} * * Adds one or more values to searchAfter. */ public final Builder searchAfter(String value, String... values) { this.searchAfter = _listAdd(this.searchAfter, value, values); return this; } /** * Search operation type * * API name: {@code search_type} */ public final Builder searchType(@Nullable SearchType value) { this.searchType = value; return this; } /** * If true, returns sequence number and primary term of the last modification of * each hit. See Optimistic concurrency control. * * API name: {@code seq_no_primary_term} */ public final Builder seqNoPrimaryTerm(@Nullable Boolean value) { this.seqNoPrimaryTerm = value; return this; } /** * The number of hits to return. By default, you cannot page through more than * 10,000 hits using the from and size parameters. To page through more hits, * use the search_after parameter. * * API name: {@code size} */ public final Builder size(@Nullable Integer value) { this.size = value; return this; } /** * API name: {@code slice} */ public final Builder slice(@Nullable SlicedScroll value) { this.slice = value; return this; } /** * API name: {@code slice} */ public final Builder slice(Function> fn) { return this.slice(fn.apply(new SlicedScroll.Builder()).build()); } /** * API name: {@code sort} * * Adds all elements of list to sort. */ public final Builder sort(List list) { this.sort = _listAddAll(this.sort, list); return this; } /** * API name: {@code sort} * * Adds one or more values to sort. */ public final Builder sort(SortOptions value, SortOptions... values) { this.sort = _listAdd(this.sort, value, values); return this; } /** * API name: {@code sort} * * Adds a value to sort using a builder lambda. */ public final Builder sort(Function> fn) { return sort(fn.apply(new SortOptions.Builder()).build()); } /** * Stats groups to associate with the search. Each group maintains a statistics * aggregation for its associated searches. You can retrieve these stats using * the indices stats API. * * API name: {@code stats} * * Adds all elements of list to stats. */ public final Builder stats(List list) { this.stats = _listAddAll(this.stats, list); return this; } /** * Stats groups to associate with the search. Each group maintains a statistics * aggregation for its associated searches. You can retrieve these stats using * the indices stats API. * * API name: {@code stats} * * Adds one or more values to stats. */ public final Builder stats(String value, String... values) { this.stats = _listAdd(this.stats, value, values); return this; } /** * List of stored fields to return as part of a hit. If no fields are specified, * no stored fields are included in the response. If this field is specified, * the _source parameter defaults to false. You can pass _source: true to return * both source fields and stored fields in the search response. * * API name: {@code stored_fields} * * Adds all elements of list to storedFields. */ public final Builder storedFields(List list) { this.storedFields = _listAddAll(this.storedFields, list); return this; } /** * List of stored fields to return as part of a hit. If no fields are specified, * no stored fields are included in the response. If this field is specified, * the _source parameter defaults to false. You can pass _source: true to return * both source fields and stored fields in the search response. * * API name: {@code stored_fields} * * Adds one or more values to storedFields. */ public final Builder storedFields(String value, String... values) { this.storedFields = _listAdd(this.storedFields, value, values); return this; } /** * API name: {@code suggest} */ public final Builder suggest(@Nullable Suggester value) { this.suggest = value; return this; } /** * API name: {@code suggest} */ public final Builder suggest(Function> fn) { return this.suggest(fn.apply(new Suggester.Builder()).build()); } /** * Maximum number of documents to collect for each shard. If a query reaches * this limit, Elasticsearch terminates the query early. Elasticsearch collects * documents before sorting. Defaults to 0, which does not terminate query * execution early. * * API name: {@code terminate_after} */ public final Builder terminateAfter(@Nullable Long value) { this.terminateAfter = value; return this; } /** * Specifies the period of time to wait for a response from each shard. If no * response is received before the timeout expires, the request fails and * returns an error. Defaults to no timeout. * * API name: {@code timeout} */ public final Builder timeout(@Nullable String value) { this.timeout = value; return this; } /** * If true, calculate and return document scores, even if the scores are not * used for sorting. * * API name: {@code track_scores} */ public final Builder trackScores(@Nullable Boolean value) { this.trackScores = value; return this; } /** * Number of hits matching the query to count accurately. If true, the exact * number of hits is returned at the cost of some performance. If false, the * response does not include the total number of hits matching the query. * Defaults to 10,000 hits. * * API name: {@code track_total_hits} */ public final Builder trackTotalHits(@Nullable TrackHits value) { this.trackTotalHits = value; return this; } /** * Number of hits matching the query to count accurately. If true, the exact * number of hits is returned at the cost of some performance. If false, the * response does not include the total number of hits matching the query. * Defaults to 10,000 hits. * * API name: {@code track_total_hits} */ public final Builder trackTotalHits(Function> fn) { return this.trackTotalHits(fn.apply(new TrackHits.Builder()).build()); } /** * If true, returns document version as part of a hit. * * API name: {@code version} */ public final Builder version(@Nullable Boolean value) { this.version = value; return this; } /** * Specify the time that the request should block waiting for the final response * * API name: {@code wait_for_completion_timeout} */ public final Builder waitForCompletionTimeout(@Nullable Time value) { this.waitForCompletionTimeout = value; return this; } /** * Specify the time that the request should block waiting for the final response * * API name: {@code wait_for_completion_timeout} */ public final Builder waitForCompletionTimeout(Function> fn) { return this.waitForCompletionTimeout(fn.apply(new Time.Builder()).build()); } @Override protected Builder self() { return this; } /** * Builds a {@link SubmitRequest}. * * @throws NullPointerException * if some of the required fields are null. */ public SubmitRequest build() { _checkSingleUse(); return new SubmitRequest(this); } } // --------------------------------------------------------------------------------------------- /** * Json deserializer for {@link SubmitRequest} */ public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy(Builder::new, SubmitRequest::setupSubmitRequestDeserializer); protected static void setupSubmitRequestDeserializer(ObjectDeserializer op) { op.add(Builder::source, SourceConfig._DESERIALIZER, "_source"); op.add(Builder::aggregations, JsonpDeserializer.stringMapDeserializer(Aggregation._DESERIALIZER), "aggregations", "aggs"); op.add(Builder::collapse, FieldCollapse._DESERIALIZER, "collapse"); op.add(Builder::docvalueFields, JsonpDeserializer.arrayDeserializer(FieldAndFormat._DESERIALIZER), "docvalue_fields"); op.add(Builder::explain, JsonpDeserializer.booleanDeserializer(), "explain"); op.add(Builder::fields, JsonpDeserializer.arrayDeserializer(FieldAndFormat._DESERIALIZER), "fields"); op.add(Builder::from, JsonpDeserializer.integerDeserializer(), "from"); op.add(Builder::highlight, Highlight._DESERIALIZER, "highlight"); op.add(Builder::indicesBoost, JsonpDeserializer.arrayDeserializer( JsonpDeserializer.stringMapDeserializer(JsonpDeserializer.doubleDeserializer())), "indices_boost"); op.add(Builder::minScore, JsonpDeserializer.doubleDeserializer(), "min_score"); op.add(Builder::pit, PointInTimeReference._DESERIALIZER, "pit"); op.add(Builder::postFilter, Query._DESERIALIZER, "post_filter"); op.add(Builder::profile, JsonpDeserializer.booleanDeserializer(), "profile"); op.add(Builder::query, Query._DESERIALIZER, "query"); op.add(Builder::rescore, JsonpDeserializer.arrayDeserializer(Rescore._DESERIALIZER), "rescore"); op.add(Builder::runtimeMappings, JsonpDeserializer.stringMapDeserializer( JsonpDeserializer.arrayDeserializer(RuntimeField._DESERIALIZER)), "runtime_mappings"); op.add(Builder::scriptFields, JsonpDeserializer.stringMapDeserializer(ScriptField._DESERIALIZER), "script_fields"); op.add(Builder::searchAfter, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "search_after"); op.add(Builder::seqNoPrimaryTerm, JsonpDeserializer.booleanDeserializer(), "seq_no_primary_term"); op.add(Builder::size, JsonpDeserializer.integerDeserializer(), "size"); op.add(Builder::slice, SlicedScroll._DESERIALIZER, "slice"); op.add(Builder::sort, JsonpDeserializer.arrayDeserializer(SortOptions._DESERIALIZER), "sort"); op.add(Builder::stats, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "stats"); op.add(Builder::storedFields, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "stored_fields"); op.add(Builder::suggest, Suggester._DESERIALIZER, "suggest"); op.add(Builder::terminateAfter, JsonpDeserializer.longDeserializer(), "terminate_after"); op.add(Builder::timeout, JsonpDeserializer.stringDeserializer(), "timeout"); op.add(Builder::trackScores, JsonpDeserializer.booleanDeserializer(), "track_scores"); op.add(Builder::trackTotalHits, TrackHits._DESERIALIZER, "track_total_hits"); op.add(Builder::version, JsonpDeserializer.booleanDeserializer(), "version"); } // --------------------------------------------------------------------------------------------- /** * Endpoint "{@code async_search.submit}". */ public static final SimpleEndpoint _ENDPOINT = new SimpleEndpoint<>("es/async_search.submit", // Request method request -> { return "POST"; }, // Request path request -> { final int _index = 1 << 0; int propsSet = 0; if (ApiTypeHelper.isDefined(request.index())) propsSet |= _index; if (propsSet == 0) { StringBuilder buf = new StringBuilder(); buf.append("/_async_search"); return buf.toString(); } if (propsSet == (_index)) { StringBuilder buf = new StringBuilder(); buf.append("/"); SimpleEndpoint.pathEncode(request.index.stream().map(v -> v).collect(Collectors.joining(",")), buf); buf.append("/_async_search"); return buf.toString(); } throw SimpleEndpoint.noPathTemplateFound("path"); }, // Request parameters request -> { Map params = new HashMap<>(); params.put("typed_keys", "true"); if (request.df != null) { params.put("df", request.df); } if (request.preFilterShardSize != null) { params.put("pre_filter_shard_size", String.valueOf(request.preFilterShardSize)); } if (request.minCompatibleShardNode != null) { params.put("min_compatible_shard_node", request.minCompatibleShardNode); } if (request.lenient != null) { params.put("lenient", String.valueOf(request.lenient)); } if (request.routing != null) { params.put("routing", request.routing); } if (request.ignoreUnavailable != null) { params.put("ignore_unavailable", String.valueOf(request.ignoreUnavailable)); } if (request.allowNoIndices != null) { params.put("allow_no_indices", String.valueOf(request.allowNoIndices)); } if (request.analyzer != null) { params.put("analyzer", request.analyzer); } if (request.ignoreThrottled != null) { params.put("ignore_throttled", String.valueOf(request.ignoreThrottled)); } if (request.keepOnCompletion != null) { params.put("keep_on_completion", String.valueOf(request.keepOnCompletion)); } if (request.maxConcurrentShardRequests != null) { params.put("max_concurrent_shard_requests", String.valueOf(request.maxConcurrentShardRequests)); } if (request.allowPartialSearchResults != null) { params.put("allow_partial_search_results", String.valueOf(request.allowPartialSearchResults)); } if (ApiTypeHelper.isDefined(request.expandWildcards)) { params.put("expand_wildcards", request.expandWildcards.stream().map(v -> v.jsonValue()).collect(Collectors.joining(","))); } if (request.preference != null) { params.put("preference", request.preference); } if (request.analyzeWildcard != null) { params.put("analyze_wildcard", String.valueOf(request.analyzeWildcard)); } if (request.scroll != null) { params.put("scroll", request.scroll._toJsonString()); } if (request.waitForCompletionTimeout != null) { params.put("wait_for_completion_timeout", request.waitForCompletionTimeout._toJsonString()); } if (request.searchType != null) { params.put("search_type", request.searchType.jsonValue()); } if (request.ccsMinimizeRoundtrips != null) { params.put("ccs_minimize_roundtrips", String.valueOf(request.ccsMinimizeRoundtrips)); } if (request.q != null) { params.put("q", request.q); } if (request.defaultOperator != null) { params.put("default_operator", request.defaultOperator.jsonValue()); } if (request.keepAlive != null) { params.put("keep_alive", request.keepAlive._toJsonString()); } if (request.requestCache != null) { params.put("request_cache", String.valueOf(request.requestCache)); } if (request.batchedReduceSize != null) { params.put("batched_reduce_size", String.valueOf(request.batchedReduceSize)); } return params; }, SimpleEndpoint.emptyMap(), true, SubmitResponse._DESERIALIZER); /** * Create an "{@code async_search.submit}" endpoint. */ public static Endpoint, ErrorResponse> createSubmitEndpoint( JsonpDeserializer tDocumentDeserializer) { return _ENDPOINT .withResponseDeserializer(SubmitResponse.createSubmitResponseDeserializer(tDocumentDeserializer)); } }
* API name: {@code terminate_after} */ @Nullable public final Long terminateAfter() { return this.terminateAfter; } /** * Specifies the period of time to wait for a response from each shard. If no * response is received before the timeout expires, the request fails and * returns an error. Defaults to no timeout. *
* API name: {@code timeout} */ @Nullable public final String timeout() { return this.timeout; } /** * If true, calculate and return document scores, even if the scores are not * used for sorting. *
* API name: {@code track_scores} */ @Nullable public final Boolean trackScores() { return this.trackScores; } /** * Number of hits matching the query to count accurately. If true, the exact * number of hits is returned at the cost of some performance. If false, the * response does not include the total number of hits matching the query. * Defaults to 10,000 hits. *
* API name: {@code track_total_hits} */ @Nullable public final TrackHits trackTotalHits() { return this.trackTotalHits; } /** * If true, returns document version as part of a hit. *
* API name: {@code version} */ @Nullable public final Boolean version() { return this.version; } /** * Specify the time that the request should block waiting for the final response *
* API name: {@code wait_for_completion_timeout} */ @Nullable public final Time waitForCompletionTimeout() { return this.waitForCompletionTimeout; } /** * 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.source != null) { generator.writeKey("_source"); this.source.serialize(generator, mapper); } if (ApiTypeHelper.isDefined(this.aggregations)) { generator.writeKey("aggregations"); generator.writeStartObject(); for (Map.Entry item0 : this.aggregations.entrySet()) { generator.writeKey(item0.getKey()); item0.getValue().serialize(generator, mapper); } generator.writeEnd(); } if (this.collapse != null) { generator.writeKey("collapse"); this.collapse.serialize(generator, mapper); } if (ApiTypeHelper.isDefined(this.docvalueFields)) { generator.writeKey("docvalue_fields"); generator.writeStartArray(); for (FieldAndFormat item0 : this.docvalueFields) { item0.serialize(generator, mapper); } generator.writeEnd(); } if (this.explain != null) { generator.writeKey("explain"); generator.write(this.explain); } if (ApiTypeHelper.isDefined(this.fields)) { generator.writeKey("fields"); generator.writeStartArray(); for (FieldAndFormat item0 : this.fields) { item0.serialize(generator, mapper); } generator.writeEnd(); } if (this.from != null) { generator.writeKey("from"); generator.write(this.from); } if (this.highlight != null) { generator.writeKey("highlight"); this.highlight.serialize(generator, mapper); } if (ApiTypeHelper.isDefined(this.indicesBoost)) { generator.writeKey("indices_boost"); generator.writeStartArray(); for (Map item0 : this.indicesBoost) { generator.writeStartObject(); if (item0 != null) { for (Map.Entry item1 : item0.entrySet()) { generator.writeKey(item1.getKey()); generator.write(item1.getValue()); } } generator.writeEnd(); } generator.writeEnd(); } if (this.minScore != null) { generator.writeKey("min_score"); generator.write(this.minScore); } if (this.pit != null) { generator.writeKey("pit"); this.pit.serialize(generator, mapper); } if (this.postFilter != null) { generator.writeKey("post_filter"); this.postFilter.serialize(generator, mapper); } if (this.profile != null) { generator.writeKey("profile"); generator.write(this.profile); } if (this.query != null) { generator.writeKey("query"); this.query.serialize(generator, mapper); } if (ApiTypeHelper.isDefined(this.rescore)) { generator.writeKey("rescore"); generator.writeStartArray(); for (Rescore item0 : this.rescore) { item0.serialize(generator, mapper); } generator.writeEnd(); } if (ApiTypeHelper.isDefined(this.runtimeMappings)) { generator.writeKey("runtime_mappings"); generator.writeStartObject(); for (Map.Entry> item0 : this.runtimeMappings.entrySet()) { generator.writeKey(item0.getKey()); generator.writeStartArray(); if (item0.getValue() != null) { for (RuntimeField item1 : item0.getValue()) { item1.serialize(generator, mapper); } } generator.writeEnd(); } generator.writeEnd(); } if (ApiTypeHelper.isDefined(this.scriptFields)) { generator.writeKey("script_fields"); generator.writeStartObject(); for (Map.Entry item0 : this.scriptFields.entrySet()) { generator.writeKey(item0.getKey()); item0.getValue().serialize(generator, mapper); } generator.writeEnd(); } if (ApiTypeHelper.isDefined(this.searchAfter)) { generator.writeKey("search_after"); generator.writeStartArray(); for (String item0 : this.searchAfter) { generator.write(item0); } generator.writeEnd(); } if (this.seqNoPrimaryTerm != null) { generator.writeKey("seq_no_primary_term"); generator.write(this.seqNoPrimaryTerm); } if (this.size != null) { generator.writeKey("size"); generator.write(this.size); } if (this.slice != null) { generator.writeKey("slice"); this.slice.serialize(generator, mapper); } if (ApiTypeHelper.isDefined(this.sort)) { generator.writeKey("sort"); generator.writeStartArray(); for (SortOptions item0 : this.sort) { item0.serialize(generator, mapper); } generator.writeEnd(); } if (ApiTypeHelper.isDefined(this.stats)) { generator.writeKey("stats"); generator.writeStartArray(); for (String item0 : this.stats) { generator.write(item0); } generator.writeEnd(); } if (ApiTypeHelper.isDefined(this.storedFields)) { generator.writeKey("stored_fields"); generator.writeStartArray(); for (String item0 : this.storedFields) { generator.write(item0); } generator.writeEnd(); } if (this.suggest != null) { generator.writeKey("suggest"); this.suggest.serialize(generator, mapper); } if (this.terminateAfter != null) { generator.writeKey("terminate_after"); generator.write(this.terminateAfter); } if (this.timeout != null) { generator.writeKey("timeout"); generator.write(this.timeout); } if (this.trackScores != null) { generator.writeKey("track_scores"); generator.write(this.trackScores); } if (this.trackTotalHits != null) { generator.writeKey("track_total_hits"); this.trackTotalHits.serialize(generator, mapper); } if (this.version != null) { generator.writeKey("version"); generator.write(this.version); } } // --------------------------------------------------------------------------------------------- /** * Builder for {@link SubmitRequest}. */ public static class Builder extends WithJsonObjectBuilderBase implements ObjectBuilder { @Nullable private SourceConfig source; @Nullable private Map aggregations; @Nullable private Boolean allowNoIndices; @Nullable private Boolean allowPartialSearchResults; @Nullable private Boolean analyzeWildcard; @Nullable private String analyzer; @Nullable private Long batchedReduceSize; @Nullable private Boolean ccsMinimizeRoundtrips; @Nullable private FieldCollapse collapse; @Nullable private Operator defaultOperator; @Nullable private String df; @Nullable private List docvalueFields; @Nullable private List expandWildcards; @Nullable private Boolean explain; @Nullable private List fields; @Nullable private Integer from; @Nullable private Highlight highlight; @Nullable private Boolean ignoreThrottled; @Nullable private Boolean ignoreUnavailable; @Nullable private List index; @Nullable private List> indicesBoost; @Nullable private Time keepAlive; @Nullable private Boolean keepOnCompletion; @Nullable private Boolean lenient; @Nullable private Long maxConcurrentShardRequests; @Nullable private String minCompatibleShardNode; @Nullable private Double minScore; @Nullable private PointInTimeReference pit; @Nullable private Query postFilter; @Nullable private Long preFilterShardSize; @Nullable private String preference; @Nullable private Boolean profile; @Nullable private String q; @Nullable private Query query; @Nullable private Boolean requestCache; @Nullable private List rescore; @Nullable private String routing; @Nullable private Map> runtimeMappings; @Nullable private Map scriptFields; @Nullable private Time scroll; @Nullable private List searchAfter; @Nullable private SearchType searchType; @Nullable private Boolean seqNoPrimaryTerm; @Nullable private Integer size; @Nullable private SlicedScroll slice; @Nullable private List sort; @Nullable private List stats; @Nullable private List storedFields; @Nullable private Suggester suggest; @Nullable private Long terminateAfter; @Nullable private String timeout; @Nullable private Boolean trackScores; @Nullable private TrackHits trackTotalHits; @Nullable private Boolean version; @Nullable private Time waitForCompletionTimeout; /** * Indicates which source fields are returned for matching documents. These * fields are returned in the hits._source property of the search response. * * API name: {@code _source} */ public final Builder source(@Nullable SourceConfig value) { this.source = value; return this; } /** * Indicates which source fields are returned for matching documents. These * fields are returned in the hits._source property of the search response. * * API name: {@code _source} */ public final Builder source(Function> fn) { return this.source(fn.apply(new SourceConfig.Builder()).build()); } /** * API name: {@code aggregations} * * Adds all entries of map to aggregations. */ public final Builder aggregations(Map map) { this.aggregations = _mapPutAll(this.aggregations, map); return this; } /** * API name: {@code aggregations} * * Adds an entry to aggregations. */ public final Builder aggregations(String key, Aggregation value) { this.aggregations = _mapPut(this.aggregations, key, value); return this; } /** * API name: {@code aggregations} * * Adds an entry to aggregations using a builder lambda. */ public final Builder aggregations(String key, Function> fn) { return aggregations(key, fn.apply(new Aggregation.Builder()).build()); } /** * Whether to ignore if a wildcard indices expression resolves into no concrete * indices. (This includes _all string or when no indices have been * specified) * * API name: {@code allow_no_indices} */ public final Builder allowNoIndices(@Nullable Boolean value) { this.allowNoIndices = value; return this; } /** * Indicate if an error should be returned if there is a partial search failure * or timeout * * API name: {@code allow_partial_search_results} */ public final Builder allowPartialSearchResults(@Nullable Boolean value) { this.allowPartialSearchResults = value; return this; } /** * Specify whether wildcard and prefix queries should be analyzed (default: * false) * * API name: {@code analyze_wildcard} */ public final Builder analyzeWildcard(@Nullable Boolean value) { this.analyzeWildcard = value; return this; } /** * The analyzer to use for the query string * * API name: {@code analyzer} */ public final Builder analyzer(@Nullable String value) { this.analyzer = value; return this; } /** * The number of shard results that should be reduced at once on the * coordinating node. This value should be used as the granularity at which * progress results will be made available. * * API name: {@code batched_reduce_size} */ public final Builder batchedReduceSize(@Nullable Long value) { this.batchedReduceSize = value; return this; } /** * API name: {@code ccs_minimize_roundtrips} */ public final Builder ccsMinimizeRoundtrips(@Nullable Boolean value) { this.ccsMinimizeRoundtrips = value; return this; } /** * API name: {@code collapse} */ public final Builder collapse(@Nullable FieldCollapse value) { this.collapse = value; return this; } /** * API name: {@code collapse} */ public final Builder collapse(Function> fn) { return this.collapse(fn.apply(new FieldCollapse.Builder()).build()); } /** * The default operator for query string query (AND or OR) * * API name: {@code default_operator} */ public final Builder defaultOperator(@Nullable Operator value) { this.defaultOperator = value; return this; } /** * The field to use as default where no field prefix is given in the query * string * * API name: {@code df} */ public final Builder df(@Nullable String value) { this.df = value; return this; } /** * Array of wildcard (*) patterns. The request returns doc values for field * names matching these patterns in the hits.fields property of the response. * * API name: {@code docvalue_fields} * * Adds all elements of list to docvalueFields. */ public final Builder docvalueFields(List list) { this.docvalueFields = _listAddAll(this.docvalueFields, list); return this; } /** * Array of wildcard (*) patterns. The request returns doc values for field * names matching these patterns in the hits.fields property of the response. * * API name: {@code docvalue_fields} * * Adds one or more values to docvalueFields. */ public final Builder docvalueFields(FieldAndFormat value, FieldAndFormat... values) { this.docvalueFields = _listAdd(this.docvalueFields, value, values); return this; } /** * Array of wildcard (*) patterns. The request returns doc values for field * names matching these patterns in the hits.fields property of the response. * * API name: {@code docvalue_fields} * * Adds a value to docvalueFields using a builder lambda. */ public final Builder docvalueFields(Function> fn) { return docvalueFields(fn.apply(new FieldAndFormat.Builder()).build()); } /** * Whether to expand wildcard expression to concrete indices that are open, * closed or both. * * API name: {@code expand_wildcards} * * Adds all elements of list to expandWildcards. */ public final Builder expandWildcards(List list) { this.expandWildcards = _listAddAll(this.expandWildcards, list); return this; } /** * Whether to expand wildcard expression to concrete indices that are open, * closed or both. * * API name: {@code expand_wildcards} * * Adds one or more values to expandWildcards. */ public final Builder expandWildcards(ExpandWildcard value, ExpandWildcard... values) { this.expandWildcards = _listAdd(this.expandWildcards, value, values); return this; } /** * If true, returns detailed information about score computation as part of a * hit. * * API name: {@code explain} */ public final Builder explain(@Nullable Boolean value) { this.explain = value; return this; } /** * Array of wildcard (*) patterns. The request returns values for field names * matching these patterns in the hits.fields property of the response. * * API name: {@code fields} * * Adds all elements of list to fields. */ public final Builder fields(List list) { this.fields = _listAddAll(this.fields, list); return this; } /** * Array of wildcard (*) patterns. The request returns values for field names * matching these patterns in the hits.fields property of the response. * * API name: {@code fields} * * Adds one or more values to fields. */ public final Builder fields(FieldAndFormat value, FieldAndFormat... values) { this.fields = _listAdd(this.fields, value, values); return this; } /** * Array of wildcard (*) patterns. The request returns values for field names * matching these patterns in the hits.fields property of the response. * * API name: {@code fields} * * Adds a value to fields using a builder lambda. */ public final Builder fields(Function> fn) { return fields(fn.apply(new FieldAndFormat.Builder()).build()); } /** * Starting document offset. By default, you cannot page through more than * 10,000 hits using the from and size parameters. To page through more hits, * use the search_after parameter. * * API name: {@code from} */ public final Builder from(@Nullable Integer value) { this.from = value; return this; } /** * API name: {@code highlight} */ public final Builder highlight(@Nullable Highlight value) { this.highlight = value; return this; } /** * API name: {@code highlight} */ public final Builder highlight(Function> fn) { return this.highlight(fn.apply(new Highlight.Builder()).build()); } /** * Whether specified concrete, expanded or aliased indices should be ignored * when throttled * * API name: {@code ignore_throttled} */ public final Builder ignoreThrottled(@Nullable Boolean value) { this.ignoreThrottled = value; return this; } /** * Whether specified concrete indices should be ignored when unavailable * (missing or closed) * * API name: {@code ignore_unavailable} */ public final Builder ignoreUnavailable(@Nullable Boolean value) { this.ignoreUnavailable = value; return this; } /** * A comma-separated list of index names to search; use _all or * empty string to perform the operation on all indices * * API name: {@code index} * * Adds all elements of list to index. */ public final Builder index(List list) { this.index = _listAddAll(this.index, list); return this; } /** * A comma-separated list of index names to search; use _all or * empty string to perform the operation on all indices * * API name: {@code index} * * Adds one or more values to index. */ public final Builder index(String value, String... values) { this.index = _listAdd(this.index, value, values); return this; } /** * Boosts the _score of documents from specified indices. * * API name: {@code indices_boost} * * Adds all elements of list to indicesBoost. */ public final Builder indicesBoost(List> list) { this.indicesBoost = _listAddAll(this.indicesBoost, list); return this; } /** * Boosts the _score of documents from specified indices. * * API name: {@code indices_boost} * * Adds one or more values to indicesBoost. */ public final Builder indicesBoost(Map value, Map... values) { this.indicesBoost = _listAdd(this.indicesBoost, value, values); return this; } /** * Update the time interval in which the results (partial or final) for this * search will be available * * API name: {@code keep_alive} */ public final Builder keepAlive(@Nullable Time value) { this.keepAlive = value; return this; } /** * Update the time interval in which the results (partial or final) for this * search will be available * * API name: {@code keep_alive} */ public final Builder keepAlive(Function> fn) { return this.keepAlive(fn.apply(new Time.Builder()).build()); } /** * Control whether the response should be stored in the cluster if it completed * within the provided [wait_for_completion] time (default: false) * * API name: {@code keep_on_completion} */ public final Builder keepOnCompletion(@Nullable Boolean value) { this.keepOnCompletion = value; return this; } /** * Specify whether format-based query failures (such as providing text to a * numeric field) should be ignored * * API name: {@code lenient} */ public final Builder lenient(@Nullable Boolean value) { this.lenient = value; return this; } /** * The number of concurrent shard requests per node this search executes * concurrently. This value should be used to limit the impact of the search on * the cluster in order to limit the number of concurrent shard requests * * API name: {@code max_concurrent_shard_requests} */ public final Builder maxConcurrentShardRequests(@Nullable Long value) { this.maxConcurrentShardRequests = value; return this; } /** * API name: {@code min_compatible_shard_node} */ public final Builder minCompatibleShardNode(@Nullable String value) { this.minCompatibleShardNode = value; return this; } /** * Minimum _score for matching documents. Documents with a lower _score are not * included in the search results. * * API name: {@code min_score} */ public final Builder minScore(@Nullable Double value) { this.minScore = value; return this; } /** * Limits the search to a point in time (PIT). If you provide a PIT, you cannot * specify an <index> in the request path. * * API name: {@code pit} */ public final Builder pit(@Nullable PointInTimeReference value) { this.pit = value; return this; } /** * Limits the search to a point in time (PIT). If you provide a PIT, you cannot * specify an <index> in the request path. * * API name: {@code pit} */ public final Builder pit(Function> fn) { return this.pit(fn.apply(new PointInTimeReference.Builder()).build()); } /** * API name: {@code post_filter} */ public final Builder postFilter(@Nullable Query value) { this.postFilter = value; return this; } /** * API name: {@code post_filter} */ public final Builder postFilter(Function> fn) { return this.postFilter(fn.apply(new Query.Builder()).build()); } /** * API name: {@code pre_filter_shard_size} */ public final Builder preFilterShardSize(@Nullable Long value) { this.preFilterShardSize = value; return this; } /** * Specify the node or shard the operation should be performed on (default: * random) * * API name: {@code preference} */ public final Builder preference(@Nullable String value) { this.preference = value; return this; } /** * API name: {@code profile} */ public final Builder profile(@Nullable Boolean value) { this.profile = value; return this; } /** * Query in the Lucene query string syntax * * API name: {@code q} */ public final Builder q(@Nullable String value) { this.q = value; return this; } /** * Defines the search definition using the Query DSL. * * API name: {@code query} */ public final Builder query(@Nullable Query value) { this.query = value; return this; } /** * Defines the search definition using the Query DSL. * * API name: {@code query} */ public final Builder query(Function> fn) { return this.query(fn.apply(new Query.Builder()).build()); } /** * Specify if request cache should be used for this request or not, defaults to * true * * API name: {@code request_cache} */ public final Builder requestCache(@Nullable Boolean value) { this.requestCache = value; return this; } /** * API name: {@code rescore} * * Adds all elements of list to rescore. */ public final Builder rescore(List list) { this.rescore = _listAddAll(this.rescore, list); return this; } /** * API name: {@code rescore} * * Adds one or more values to rescore. */ public final Builder rescore(Rescore value, Rescore... values) { this.rescore = _listAdd(this.rescore, value, values); return this; } /** * API name: {@code rescore} * * Adds a value to rescore using a builder lambda. */ public final Builder rescore(Function> fn) { return rescore(fn.apply(new Rescore.Builder()).build()); } /** * A comma-separated list of specific routing values * * API name: {@code routing} */ public final Builder routing(@Nullable String value) { this.routing = value; return this; } /** * Defines one or more runtime fields in the search request. These fields take * precedence over mapped fields with the same name. * * API name: {@code runtime_mappings} * * Adds all entries of map to runtimeMappings. */ public final Builder runtimeMappings(Map> map) { this.runtimeMappings = _mapPutAll(this.runtimeMappings, map); return this; } /** * Defines one or more runtime fields in the search request. These fields take * precedence over mapped fields with the same name. * * API name: {@code runtime_mappings} * * Adds an entry to runtimeMappings. */ public final Builder runtimeMappings(String key, List value) { this.runtimeMappings = _mapPut(this.runtimeMappings, key, value); return this; } /** * Retrieve a script evaluation (based on different fields) for each hit. * * API name: {@code script_fields} * * Adds all entries of map to scriptFields. */ public final Builder scriptFields(Map map) { this.scriptFields = _mapPutAll(this.scriptFields, map); return this; } /** * Retrieve a script evaluation (based on different fields) for each hit. * * API name: {@code script_fields} * * Adds an entry to scriptFields. */ public final Builder scriptFields(String key, ScriptField value) { this.scriptFields = _mapPut(this.scriptFields, key, value); return this; } /** * Retrieve a script evaluation (based on different fields) for each hit. * * API name: {@code script_fields} * * Adds an entry to scriptFields using a builder lambda. */ public final Builder scriptFields(String key, Function> fn) { return scriptFields(key, fn.apply(new ScriptField.Builder()).build()); } /** * API name: {@code scroll} */ public final Builder scroll(@Nullable Time value) { this.scroll = value; return this; } /** * API name: {@code scroll} */ public final Builder scroll(Function> fn) { return this.scroll(fn.apply(new Time.Builder()).build()); } /** * API name: {@code search_after} * * Adds all elements of list to searchAfter. */ public final Builder searchAfter(List list) { this.searchAfter = _listAddAll(this.searchAfter, list); return this; } /** * API name: {@code search_after} * * Adds one or more values to searchAfter. */ public final Builder searchAfter(String value, String... values) { this.searchAfter = _listAdd(this.searchAfter, value, values); return this; } /** * Search operation type * * API name: {@code search_type} */ public final Builder searchType(@Nullable SearchType value) { this.searchType = value; return this; } /** * If true, returns sequence number and primary term of the last modification of * each hit. See Optimistic concurrency control. * * API name: {@code seq_no_primary_term} */ public final Builder seqNoPrimaryTerm(@Nullable Boolean value) { this.seqNoPrimaryTerm = value; return this; } /** * The number of hits to return. By default, you cannot page through more than * 10,000 hits using the from and size parameters. To page through more hits, * use the search_after parameter. * * API name: {@code size} */ public final Builder size(@Nullable Integer value) { this.size = value; return this; } /** * API name: {@code slice} */ public final Builder slice(@Nullable SlicedScroll value) { this.slice = value; return this; } /** * API name: {@code slice} */ public final Builder slice(Function> fn) { return this.slice(fn.apply(new SlicedScroll.Builder()).build()); } /** * API name: {@code sort} * * Adds all elements of list to sort. */ public final Builder sort(List list) { this.sort = _listAddAll(this.sort, list); return this; } /** * API name: {@code sort} * * Adds one or more values to sort. */ public final Builder sort(SortOptions value, SortOptions... values) { this.sort = _listAdd(this.sort, value, values); return this; } /** * API name: {@code sort} * * Adds a value to sort using a builder lambda. */ public final Builder sort(Function> fn) { return sort(fn.apply(new SortOptions.Builder()).build()); } /** * Stats groups to associate with the search. Each group maintains a statistics * aggregation for its associated searches. You can retrieve these stats using * the indices stats API. * * API name: {@code stats} * * Adds all elements of list to stats. */ public final Builder stats(List list) { this.stats = _listAddAll(this.stats, list); return this; } /** * Stats groups to associate with the search. Each group maintains a statistics * aggregation for its associated searches. You can retrieve these stats using * the indices stats API. * * API name: {@code stats} * * Adds one or more values to stats. */ public final Builder stats(String value, String... values) { this.stats = _listAdd(this.stats, value, values); return this; } /** * List of stored fields to return as part of a hit. If no fields are specified, * no stored fields are included in the response. If this field is specified, * the _source parameter defaults to false. You can pass _source: true to return * both source fields and stored fields in the search response. * * API name: {@code stored_fields} * * Adds all elements of list to storedFields. */ public final Builder storedFields(List list) { this.storedFields = _listAddAll(this.storedFields, list); return this; } /** * List of stored fields to return as part of a hit. If no fields are specified, * no stored fields are included in the response. If this field is specified, * the _source parameter defaults to false. You can pass _source: true to return * both source fields and stored fields in the search response. * * API name: {@code stored_fields} * * Adds one or more values to storedFields. */ public final Builder storedFields(String value, String... values) { this.storedFields = _listAdd(this.storedFields, value, values); return this; } /** * API name: {@code suggest} */ public final Builder suggest(@Nullable Suggester value) { this.suggest = value; return this; } /** * API name: {@code suggest} */ public final Builder suggest(Function> fn) { return this.suggest(fn.apply(new Suggester.Builder()).build()); } /** * Maximum number of documents to collect for each shard. If a query reaches * this limit, Elasticsearch terminates the query early. Elasticsearch collects * documents before sorting. Defaults to 0, which does not terminate query * execution early. * * API name: {@code terminate_after} */ public final Builder terminateAfter(@Nullable Long value) { this.terminateAfter = value; return this; } /** * Specifies the period of time to wait for a response from each shard. If no * response is received before the timeout expires, the request fails and * returns an error. Defaults to no timeout. * * API name: {@code timeout} */ public final Builder timeout(@Nullable String value) { this.timeout = value; return this; } /** * If true, calculate and return document scores, even if the scores are not * used for sorting. * * API name: {@code track_scores} */ public final Builder trackScores(@Nullable Boolean value) { this.trackScores = value; return this; } /** * Number of hits matching the query to count accurately. If true, the exact * number of hits is returned at the cost of some performance. If false, the * response does not include the total number of hits matching the query. * Defaults to 10,000 hits. * * API name: {@code track_total_hits} */ public final Builder trackTotalHits(@Nullable TrackHits value) { this.trackTotalHits = value; return this; } /** * Number of hits matching the query to count accurately. If true, the exact * number of hits is returned at the cost of some performance. If false, the * response does not include the total number of hits matching the query. * Defaults to 10,000 hits. * * API name: {@code track_total_hits} */ public final Builder trackTotalHits(Function> fn) { return this.trackTotalHits(fn.apply(new TrackHits.Builder()).build()); } /** * If true, returns document version as part of a hit. * * API name: {@code version} */ public final Builder version(@Nullable Boolean value) { this.version = value; return this; } /** * Specify the time that the request should block waiting for the final response * * API name: {@code wait_for_completion_timeout} */ public final Builder waitForCompletionTimeout(@Nullable Time value) { this.waitForCompletionTimeout = value; return this; } /** * Specify the time that the request should block waiting for the final response * * API name: {@code wait_for_completion_timeout} */ public final Builder waitForCompletionTimeout(Function> fn) { return this.waitForCompletionTimeout(fn.apply(new Time.Builder()).build()); } @Override protected Builder self() { return this; } /** * Builds a {@link SubmitRequest}. * * @throws NullPointerException * if some of the required fields are null. */ public SubmitRequest build() { _checkSingleUse(); return new SubmitRequest(this); } } // --------------------------------------------------------------------------------------------- /** * Json deserializer for {@link SubmitRequest} */ public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy(Builder::new, SubmitRequest::setupSubmitRequestDeserializer); protected static void setupSubmitRequestDeserializer(ObjectDeserializer op) { op.add(Builder::source, SourceConfig._DESERIALIZER, "_source"); op.add(Builder::aggregations, JsonpDeserializer.stringMapDeserializer(Aggregation._DESERIALIZER), "aggregations", "aggs"); op.add(Builder::collapse, FieldCollapse._DESERIALIZER, "collapse"); op.add(Builder::docvalueFields, JsonpDeserializer.arrayDeserializer(FieldAndFormat._DESERIALIZER), "docvalue_fields"); op.add(Builder::explain, JsonpDeserializer.booleanDeserializer(), "explain"); op.add(Builder::fields, JsonpDeserializer.arrayDeserializer(FieldAndFormat._DESERIALIZER), "fields"); op.add(Builder::from, JsonpDeserializer.integerDeserializer(), "from"); op.add(Builder::highlight, Highlight._DESERIALIZER, "highlight"); op.add(Builder::indicesBoost, JsonpDeserializer.arrayDeserializer( JsonpDeserializer.stringMapDeserializer(JsonpDeserializer.doubleDeserializer())), "indices_boost"); op.add(Builder::minScore, JsonpDeserializer.doubleDeserializer(), "min_score"); op.add(Builder::pit, PointInTimeReference._DESERIALIZER, "pit"); op.add(Builder::postFilter, Query._DESERIALIZER, "post_filter"); op.add(Builder::profile, JsonpDeserializer.booleanDeserializer(), "profile"); op.add(Builder::query, Query._DESERIALIZER, "query"); op.add(Builder::rescore, JsonpDeserializer.arrayDeserializer(Rescore._DESERIALIZER), "rescore"); op.add(Builder::runtimeMappings, JsonpDeserializer.stringMapDeserializer( JsonpDeserializer.arrayDeserializer(RuntimeField._DESERIALIZER)), "runtime_mappings"); op.add(Builder::scriptFields, JsonpDeserializer.stringMapDeserializer(ScriptField._DESERIALIZER), "script_fields"); op.add(Builder::searchAfter, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "search_after"); op.add(Builder::seqNoPrimaryTerm, JsonpDeserializer.booleanDeserializer(), "seq_no_primary_term"); op.add(Builder::size, JsonpDeserializer.integerDeserializer(), "size"); op.add(Builder::slice, SlicedScroll._DESERIALIZER, "slice"); op.add(Builder::sort, JsonpDeserializer.arrayDeserializer(SortOptions._DESERIALIZER), "sort"); op.add(Builder::stats, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "stats"); op.add(Builder::storedFields, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "stored_fields"); op.add(Builder::suggest, Suggester._DESERIALIZER, "suggest"); op.add(Builder::terminateAfter, JsonpDeserializer.longDeserializer(), "terminate_after"); op.add(Builder::timeout, JsonpDeserializer.stringDeserializer(), "timeout"); op.add(Builder::trackScores, JsonpDeserializer.booleanDeserializer(), "track_scores"); op.add(Builder::trackTotalHits, TrackHits._DESERIALIZER, "track_total_hits"); op.add(Builder::version, JsonpDeserializer.booleanDeserializer(), "version"); } // --------------------------------------------------------------------------------------------- /** * Endpoint "{@code async_search.submit}". */ public static final SimpleEndpoint _ENDPOINT = new SimpleEndpoint<>("es/async_search.submit", // Request method request -> { return "POST"; }, // Request path request -> { final int _index = 1 << 0; int propsSet = 0; if (ApiTypeHelper.isDefined(request.index())) propsSet |= _index; if (propsSet == 0) { StringBuilder buf = new StringBuilder(); buf.append("/_async_search"); return buf.toString(); } if (propsSet == (_index)) { StringBuilder buf = new StringBuilder(); buf.append("/"); SimpleEndpoint.pathEncode(request.index.stream().map(v -> v).collect(Collectors.joining(",")), buf); buf.append("/_async_search"); return buf.toString(); } throw SimpleEndpoint.noPathTemplateFound("path"); }, // Request parameters request -> { Map params = new HashMap<>(); params.put("typed_keys", "true"); if (request.df != null) { params.put("df", request.df); } if (request.preFilterShardSize != null) { params.put("pre_filter_shard_size", String.valueOf(request.preFilterShardSize)); } if (request.minCompatibleShardNode != null) { params.put("min_compatible_shard_node", request.minCompatibleShardNode); } if (request.lenient != null) { params.put("lenient", String.valueOf(request.lenient)); } if (request.routing != null) { params.put("routing", request.routing); } if (request.ignoreUnavailable != null) { params.put("ignore_unavailable", String.valueOf(request.ignoreUnavailable)); } if (request.allowNoIndices != null) { params.put("allow_no_indices", String.valueOf(request.allowNoIndices)); } if (request.analyzer != null) { params.put("analyzer", request.analyzer); } if (request.ignoreThrottled != null) { params.put("ignore_throttled", String.valueOf(request.ignoreThrottled)); } if (request.keepOnCompletion != null) { params.put("keep_on_completion", String.valueOf(request.keepOnCompletion)); } if (request.maxConcurrentShardRequests != null) { params.put("max_concurrent_shard_requests", String.valueOf(request.maxConcurrentShardRequests)); } if (request.allowPartialSearchResults != null) { params.put("allow_partial_search_results", String.valueOf(request.allowPartialSearchResults)); } if (ApiTypeHelper.isDefined(request.expandWildcards)) { params.put("expand_wildcards", request.expandWildcards.stream().map(v -> v.jsonValue()).collect(Collectors.joining(","))); } if (request.preference != null) { params.put("preference", request.preference); } if (request.analyzeWildcard != null) { params.put("analyze_wildcard", String.valueOf(request.analyzeWildcard)); } if (request.scroll != null) { params.put("scroll", request.scroll._toJsonString()); } if (request.waitForCompletionTimeout != null) { params.put("wait_for_completion_timeout", request.waitForCompletionTimeout._toJsonString()); } if (request.searchType != null) { params.put("search_type", request.searchType.jsonValue()); } if (request.ccsMinimizeRoundtrips != null) { params.put("ccs_minimize_roundtrips", String.valueOf(request.ccsMinimizeRoundtrips)); } if (request.q != null) { params.put("q", request.q); } if (request.defaultOperator != null) { params.put("default_operator", request.defaultOperator.jsonValue()); } if (request.keepAlive != null) { params.put("keep_alive", request.keepAlive._toJsonString()); } if (request.requestCache != null) { params.put("request_cache", String.valueOf(request.requestCache)); } if (request.batchedReduceSize != null) { params.put("batched_reduce_size", String.valueOf(request.batchedReduceSize)); } return params; }, SimpleEndpoint.emptyMap(), true, SubmitResponse._DESERIALIZER); /** * Create an "{@code async_search.submit}" endpoint. */ public static Endpoint, ErrorResponse> createSubmitEndpoint( JsonpDeserializer tDocumentDeserializer) { return _ENDPOINT .withResponseDeserializer(SubmitResponse.createSubmitResponseDeserializer(tDocumentDeserializer)); } }
* API name: {@code _source} */ public final Builder source(@Nullable SourceConfig value) { this.source = value; return this; } /** * Indicates which source fields are returned for matching documents. These * fields are returned in the hits._source property of the search response. *
* API name: {@code _source} */ public final Builder source(Function> fn) { return this.source(fn.apply(new SourceConfig.Builder()).build()); } /** * API name: {@code aggregations} * * Adds all entries of map to aggregations. */ public final Builder aggregations(Map map) { this.aggregations = _mapPutAll(this.aggregations, map); return this; } /** * API name: {@code aggregations} * * Adds an entry to aggregations. */ public final Builder aggregations(String key, Aggregation value) { this.aggregations = _mapPut(this.aggregations, key, value); return this; } /** * API name: {@code aggregations} * * Adds an entry to aggregations using a builder lambda. */ public final Builder aggregations(String key, Function> fn) { return aggregations(key, fn.apply(new Aggregation.Builder()).build()); } /** * Whether to ignore if a wildcard indices expression resolves into no concrete * indices. (This includes _all string or when no indices have been * specified) * * API name: {@code allow_no_indices} */ public final Builder allowNoIndices(@Nullable Boolean value) { this.allowNoIndices = value; return this; } /** * Indicate if an error should be returned if there is a partial search failure * or timeout * * API name: {@code allow_partial_search_results} */ public final Builder allowPartialSearchResults(@Nullable Boolean value) { this.allowPartialSearchResults = value; return this; } /** * Specify whether wildcard and prefix queries should be analyzed (default: * false) * * API name: {@code analyze_wildcard} */ public final Builder analyzeWildcard(@Nullable Boolean value) { this.analyzeWildcard = value; return this; } /** * The analyzer to use for the query string * * API name: {@code analyzer} */ public final Builder analyzer(@Nullable String value) { this.analyzer = value; return this; } /** * The number of shard results that should be reduced at once on the * coordinating node. This value should be used as the granularity at which * progress results will be made available. * * API name: {@code batched_reduce_size} */ public final Builder batchedReduceSize(@Nullable Long value) { this.batchedReduceSize = value; return this; } /** * API name: {@code ccs_minimize_roundtrips} */ public final Builder ccsMinimizeRoundtrips(@Nullable Boolean value) { this.ccsMinimizeRoundtrips = value; return this; } /** * API name: {@code collapse} */ public final Builder collapse(@Nullable FieldCollapse value) { this.collapse = value; return this; } /** * API name: {@code collapse} */ public final Builder collapse(Function> fn) { return this.collapse(fn.apply(new FieldCollapse.Builder()).build()); } /** * The default operator for query string query (AND or OR) * * API name: {@code default_operator} */ public final Builder defaultOperator(@Nullable Operator value) { this.defaultOperator = value; return this; } /** * The field to use as default where no field prefix is given in the query * string * * API name: {@code df} */ public final Builder df(@Nullable String value) { this.df = value; return this; } /** * Array of wildcard (*) patterns. The request returns doc values for field * names matching these patterns in the hits.fields property of the response. * * API name: {@code docvalue_fields} * * Adds all elements of list to docvalueFields. */ public final Builder docvalueFields(List list) { this.docvalueFields = _listAddAll(this.docvalueFields, list); return this; } /** * Array of wildcard (*) patterns. The request returns doc values for field * names matching these patterns in the hits.fields property of the response. * * API name: {@code docvalue_fields} * * Adds one or more values to docvalueFields. */ public final Builder docvalueFields(FieldAndFormat value, FieldAndFormat... values) { this.docvalueFields = _listAdd(this.docvalueFields, value, values); return this; } /** * Array of wildcard (*) patterns. The request returns doc values for field * names matching these patterns in the hits.fields property of the response. * * API name: {@code docvalue_fields} * * Adds a value to docvalueFields using a builder lambda. */ public final Builder docvalueFields(Function> fn) { return docvalueFields(fn.apply(new FieldAndFormat.Builder()).build()); } /** * Whether to expand wildcard expression to concrete indices that are open, * closed or both. * * API name: {@code expand_wildcards} * * Adds all elements of list to expandWildcards. */ public final Builder expandWildcards(List list) { this.expandWildcards = _listAddAll(this.expandWildcards, list); return this; } /** * Whether to expand wildcard expression to concrete indices that are open, * closed or both. * * API name: {@code expand_wildcards} * * Adds one or more values to expandWildcards. */ public final Builder expandWildcards(ExpandWildcard value, ExpandWildcard... values) { this.expandWildcards = _listAdd(this.expandWildcards, value, values); return this; } /** * If true, returns detailed information about score computation as part of a * hit. * * API name: {@code explain} */ public final Builder explain(@Nullable Boolean value) { this.explain = value; return this; } /** * Array of wildcard (*) patterns. The request returns values for field names * matching these patterns in the hits.fields property of the response. * * API name: {@code fields} * * Adds all elements of list to fields. */ public final Builder fields(List list) { this.fields = _listAddAll(this.fields, list); return this; } /** * Array of wildcard (*) patterns. The request returns values for field names * matching these patterns in the hits.fields property of the response. * * API name: {@code fields} * * Adds one or more values to fields. */ public final Builder fields(FieldAndFormat value, FieldAndFormat... values) { this.fields = _listAdd(this.fields, value, values); return this; } /** * Array of wildcard (*) patterns. The request returns values for field names * matching these patterns in the hits.fields property of the response. * * API name: {@code fields} * * Adds a value to fields using a builder lambda. */ public final Builder fields(Function> fn) { return fields(fn.apply(new FieldAndFormat.Builder()).build()); } /** * Starting document offset. By default, you cannot page through more than * 10,000 hits using the from and size parameters. To page through more hits, * use the search_after parameter. * * API name: {@code from} */ public final Builder from(@Nullable Integer value) { this.from = value; return this; } /** * API name: {@code highlight} */ public final Builder highlight(@Nullable Highlight value) { this.highlight = value; return this; } /** * API name: {@code highlight} */ public final Builder highlight(Function> fn) { return this.highlight(fn.apply(new Highlight.Builder()).build()); } /** * Whether specified concrete, expanded or aliased indices should be ignored * when throttled * * API name: {@code ignore_throttled} */ public final Builder ignoreThrottled(@Nullable Boolean value) { this.ignoreThrottled = value; return this; } /** * Whether specified concrete indices should be ignored when unavailable * (missing or closed) * * API name: {@code ignore_unavailable} */ public final Builder ignoreUnavailable(@Nullable Boolean value) { this.ignoreUnavailable = value; return this; } /** * A comma-separated list of index names to search; use _all or * empty string to perform the operation on all indices * * API name: {@code index} * * Adds all elements of list to index. */ public final Builder index(List list) { this.index = _listAddAll(this.index, list); return this; } /** * A comma-separated list of index names to search; use _all or * empty string to perform the operation on all indices * * API name: {@code index} * * Adds one or more values to index. */ public final Builder index(String value, String... values) { this.index = _listAdd(this.index, value, values); return this; } /** * Boosts the _score of documents from specified indices. * * API name: {@code indices_boost} * * Adds all elements of list to indicesBoost. */ public final Builder indicesBoost(List> list) { this.indicesBoost = _listAddAll(this.indicesBoost, list); return this; } /** * Boosts the _score of documents from specified indices. * * API name: {@code indices_boost} * * Adds one or more values to indicesBoost. */ public final Builder indicesBoost(Map value, Map... values) { this.indicesBoost = _listAdd(this.indicesBoost, value, values); return this; } /** * Update the time interval in which the results (partial or final) for this * search will be available * * API name: {@code keep_alive} */ public final Builder keepAlive(@Nullable Time value) { this.keepAlive = value; return this; } /** * Update the time interval in which the results (partial or final) for this * search will be available * * API name: {@code keep_alive} */ public final Builder keepAlive(Function> fn) { return this.keepAlive(fn.apply(new Time.Builder()).build()); } /** * Control whether the response should be stored in the cluster if it completed * within the provided [wait_for_completion] time (default: false) * * API name: {@code keep_on_completion} */ public final Builder keepOnCompletion(@Nullable Boolean value) { this.keepOnCompletion = value; return this; } /** * Specify whether format-based query failures (such as providing text to a * numeric field) should be ignored * * API name: {@code lenient} */ public final Builder lenient(@Nullable Boolean value) { this.lenient = value; return this; } /** * The number of concurrent shard requests per node this search executes * concurrently. This value should be used to limit the impact of the search on * the cluster in order to limit the number of concurrent shard requests * * API name: {@code max_concurrent_shard_requests} */ public final Builder maxConcurrentShardRequests(@Nullable Long value) { this.maxConcurrentShardRequests = value; return this; } /** * API name: {@code min_compatible_shard_node} */ public final Builder minCompatibleShardNode(@Nullable String value) { this.minCompatibleShardNode = value; return this; } /** * Minimum _score for matching documents. Documents with a lower _score are not * included in the search results. * * API name: {@code min_score} */ public final Builder minScore(@Nullable Double value) { this.minScore = value; return this; } /** * Limits the search to a point in time (PIT). If you provide a PIT, you cannot * specify an <index> in the request path. * * API name: {@code pit} */ public final Builder pit(@Nullable PointInTimeReference value) { this.pit = value; return this; } /** * Limits the search to a point in time (PIT). If you provide a PIT, you cannot * specify an <index> in the request path. * * API name: {@code pit} */ public final Builder pit(Function> fn) { return this.pit(fn.apply(new PointInTimeReference.Builder()).build()); } /** * API name: {@code post_filter} */ public final Builder postFilter(@Nullable Query value) { this.postFilter = value; return this; } /** * API name: {@code post_filter} */ public final Builder postFilter(Function> fn) { return this.postFilter(fn.apply(new Query.Builder()).build()); } /** * API name: {@code pre_filter_shard_size} */ public final Builder preFilterShardSize(@Nullable Long value) { this.preFilterShardSize = value; return this; } /** * Specify the node or shard the operation should be performed on (default: * random) * * API name: {@code preference} */ public final Builder preference(@Nullable String value) { this.preference = value; return this; } /** * API name: {@code profile} */ public final Builder profile(@Nullable Boolean value) { this.profile = value; return this; } /** * Query in the Lucene query string syntax * * API name: {@code q} */ public final Builder q(@Nullable String value) { this.q = value; return this; } /** * Defines the search definition using the Query DSL. * * API name: {@code query} */ public final Builder query(@Nullable Query value) { this.query = value; return this; } /** * Defines the search definition using the Query DSL. * * API name: {@code query} */ public final Builder query(Function> fn) { return this.query(fn.apply(new Query.Builder()).build()); } /** * Specify if request cache should be used for this request or not, defaults to * true * * API name: {@code request_cache} */ public final Builder requestCache(@Nullable Boolean value) { this.requestCache = value; return this; } /** * API name: {@code rescore} * * Adds all elements of list to rescore. */ public final Builder rescore(List list) { this.rescore = _listAddAll(this.rescore, list); return this; } /** * API name: {@code rescore} * * Adds one or more values to rescore. */ public final Builder rescore(Rescore value, Rescore... values) { this.rescore = _listAdd(this.rescore, value, values); return this; } /** * API name: {@code rescore} * * Adds a value to rescore using a builder lambda. */ public final Builder rescore(Function> fn) { return rescore(fn.apply(new Rescore.Builder()).build()); } /** * A comma-separated list of specific routing values * * API name: {@code routing} */ public final Builder routing(@Nullable String value) { this.routing = value; return this; } /** * Defines one or more runtime fields in the search request. These fields take * precedence over mapped fields with the same name. * * API name: {@code runtime_mappings} * * Adds all entries of map to runtimeMappings. */ public final Builder runtimeMappings(Map> map) { this.runtimeMappings = _mapPutAll(this.runtimeMappings, map); return this; } /** * Defines one or more runtime fields in the search request. These fields take * precedence over mapped fields with the same name. * * API name: {@code runtime_mappings} * * Adds an entry to runtimeMappings. */ public final Builder runtimeMappings(String key, List value) { this.runtimeMappings = _mapPut(this.runtimeMappings, key, value); return this; } /** * Retrieve a script evaluation (based on different fields) for each hit. * * API name: {@code script_fields} * * Adds all entries of map to scriptFields. */ public final Builder scriptFields(Map map) { this.scriptFields = _mapPutAll(this.scriptFields, map); return this; } /** * Retrieve a script evaluation (based on different fields) for each hit. * * API name: {@code script_fields} * * Adds an entry to scriptFields. */ public final Builder scriptFields(String key, ScriptField value) { this.scriptFields = _mapPut(this.scriptFields, key, value); return this; } /** * Retrieve a script evaluation (based on different fields) for each hit. * * API name: {@code script_fields} * * Adds an entry to scriptFields using a builder lambda. */ public final Builder scriptFields(String key, Function> fn) { return scriptFields(key, fn.apply(new ScriptField.Builder()).build()); } /** * API name: {@code scroll} */ public final Builder scroll(@Nullable Time value) { this.scroll = value; return this; } /** * API name: {@code scroll} */ public final Builder scroll(Function> fn) { return this.scroll(fn.apply(new Time.Builder()).build()); } /** * API name: {@code search_after} * * Adds all elements of list to searchAfter. */ public final Builder searchAfter(List list) { this.searchAfter = _listAddAll(this.searchAfter, list); return this; } /** * API name: {@code search_after} * * Adds one or more values to searchAfter. */ public final Builder searchAfter(String value, String... values) { this.searchAfter = _listAdd(this.searchAfter, value, values); return this; } /** * Search operation type * * API name: {@code search_type} */ public final Builder searchType(@Nullable SearchType value) { this.searchType = value; return this; } /** * If true, returns sequence number and primary term of the last modification of * each hit. See Optimistic concurrency control. * * API name: {@code seq_no_primary_term} */ public final Builder seqNoPrimaryTerm(@Nullable Boolean value) { this.seqNoPrimaryTerm = value; return this; } /** * The number of hits to return. By default, you cannot page through more than * 10,000 hits using the from and size parameters. To page through more hits, * use the search_after parameter. * * API name: {@code size} */ public final Builder size(@Nullable Integer value) { this.size = value; return this; } /** * API name: {@code slice} */ public final Builder slice(@Nullable SlicedScroll value) { this.slice = value; return this; } /** * API name: {@code slice} */ public final Builder slice(Function> fn) { return this.slice(fn.apply(new SlicedScroll.Builder()).build()); } /** * API name: {@code sort} * * Adds all elements of list to sort. */ public final Builder sort(List list) { this.sort = _listAddAll(this.sort, list); return this; } /** * API name: {@code sort} * * Adds one or more values to sort. */ public final Builder sort(SortOptions value, SortOptions... values) { this.sort = _listAdd(this.sort, value, values); return this; } /** * API name: {@code sort} * * Adds a value to sort using a builder lambda. */ public final Builder sort(Function> fn) { return sort(fn.apply(new SortOptions.Builder()).build()); } /** * Stats groups to associate with the search. Each group maintains a statistics * aggregation for its associated searches. You can retrieve these stats using * the indices stats API. * * API name: {@code stats} * * Adds all elements of list to stats. */ public final Builder stats(List list) { this.stats = _listAddAll(this.stats, list); return this; } /** * Stats groups to associate with the search. Each group maintains a statistics * aggregation for its associated searches. You can retrieve these stats using * the indices stats API. * * API name: {@code stats} * * Adds one or more values to stats. */ public final Builder stats(String value, String... values) { this.stats = _listAdd(this.stats, value, values); return this; } /** * List of stored fields to return as part of a hit. If no fields are specified, * no stored fields are included in the response. If this field is specified, * the _source parameter defaults to false. You can pass _source: true to return * both source fields and stored fields in the search response. * * API name: {@code stored_fields} * * Adds all elements of list to storedFields. */ public final Builder storedFields(List list) { this.storedFields = _listAddAll(this.storedFields, list); return this; } /** * List of stored fields to return as part of a hit. If no fields are specified, * no stored fields are included in the response. If this field is specified, * the _source parameter defaults to false. You can pass _source: true to return * both source fields and stored fields in the search response. * * API name: {@code stored_fields} * * Adds one or more values to storedFields. */ public final Builder storedFields(String value, String... values) { this.storedFields = _listAdd(this.storedFields, value, values); return this; } /** * API name: {@code suggest} */ public final Builder suggest(@Nullable Suggester value) { this.suggest = value; return this; } /** * API name: {@code suggest} */ public final Builder suggest(Function> fn) { return this.suggest(fn.apply(new Suggester.Builder()).build()); } /** * Maximum number of documents to collect for each shard. If a query reaches * this limit, Elasticsearch terminates the query early. Elasticsearch collects * documents before sorting. Defaults to 0, which does not terminate query * execution early. * * API name: {@code terminate_after} */ public final Builder terminateAfter(@Nullable Long value) { this.terminateAfter = value; return this; } /** * Specifies the period of time to wait for a response from each shard. If no * response is received before the timeout expires, the request fails and * returns an error. Defaults to no timeout. * * API name: {@code timeout} */ public final Builder timeout(@Nullable String value) { this.timeout = value; return this; } /** * If true, calculate and return document scores, even if the scores are not * used for sorting. * * API name: {@code track_scores} */ public final Builder trackScores(@Nullable Boolean value) { this.trackScores = value; return this; } /** * Number of hits matching the query to count accurately. If true, the exact * number of hits is returned at the cost of some performance. If false, the * response does not include the total number of hits matching the query. * Defaults to 10,000 hits. * * API name: {@code track_total_hits} */ public final Builder trackTotalHits(@Nullable TrackHits value) { this.trackTotalHits = value; return this; } /** * Number of hits matching the query to count accurately. If true, the exact * number of hits is returned at the cost of some performance. If false, the * response does not include the total number of hits matching the query. * Defaults to 10,000 hits. * * API name: {@code track_total_hits} */ public final Builder trackTotalHits(Function> fn) { return this.trackTotalHits(fn.apply(new TrackHits.Builder()).build()); } /** * If true, returns document version as part of a hit. * * API name: {@code version} */ public final Builder version(@Nullable Boolean value) { this.version = value; return this; } /** * Specify the time that the request should block waiting for the final response * * API name: {@code wait_for_completion_timeout} */ public final Builder waitForCompletionTimeout(@Nullable Time value) { this.waitForCompletionTimeout = value; return this; } /** * Specify the time that the request should block waiting for the final response * * API name: {@code wait_for_completion_timeout} */ public final Builder waitForCompletionTimeout(Function> fn) { return this.waitForCompletionTimeout(fn.apply(new Time.Builder()).build()); } @Override protected Builder self() { return this; } /** * Builds a {@link SubmitRequest}. * * @throws NullPointerException * if some of the required fields are null. */ public SubmitRequest build() { _checkSingleUse(); return new SubmitRequest(this); } } // --------------------------------------------------------------------------------------------- /** * Json deserializer for {@link SubmitRequest} */ public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy(Builder::new, SubmitRequest::setupSubmitRequestDeserializer); protected static void setupSubmitRequestDeserializer(ObjectDeserializer op) { op.add(Builder::source, SourceConfig._DESERIALIZER, "_source"); op.add(Builder::aggregations, JsonpDeserializer.stringMapDeserializer(Aggregation._DESERIALIZER), "aggregations", "aggs"); op.add(Builder::collapse, FieldCollapse._DESERIALIZER, "collapse"); op.add(Builder::docvalueFields, JsonpDeserializer.arrayDeserializer(FieldAndFormat._DESERIALIZER), "docvalue_fields"); op.add(Builder::explain, JsonpDeserializer.booleanDeserializer(), "explain"); op.add(Builder::fields, JsonpDeserializer.arrayDeserializer(FieldAndFormat._DESERIALIZER), "fields"); op.add(Builder::from, JsonpDeserializer.integerDeserializer(), "from"); op.add(Builder::highlight, Highlight._DESERIALIZER, "highlight"); op.add(Builder::indicesBoost, JsonpDeserializer.arrayDeserializer( JsonpDeserializer.stringMapDeserializer(JsonpDeserializer.doubleDeserializer())), "indices_boost"); op.add(Builder::minScore, JsonpDeserializer.doubleDeserializer(), "min_score"); op.add(Builder::pit, PointInTimeReference._DESERIALIZER, "pit"); op.add(Builder::postFilter, Query._DESERIALIZER, "post_filter"); op.add(Builder::profile, JsonpDeserializer.booleanDeserializer(), "profile"); op.add(Builder::query, Query._DESERIALIZER, "query"); op.add(Builder::rescore, JsonpDeserializer.arrayDeserializer(Rescore._DESERIALIZER), "rescore"); op.add(Builder::runtimeMappings, JsonpDeserializer.stringMapDeserializer( JsonpDeserializer.arrayDeserializer(RuntimeField._DESERIALIZER)), "runtime_mappings"); op.add(Builder::scriptFields, JsonpDeserializer.stringMapDeserializer(ScriptField._DESERIALIZER), "script_fields"); op.add(Builder::searchAfter, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "search_after"); op.add(Builder::seqNoPrimaryTerm, JsonpDeserializer.booleanDeserializer(), "seq_no_primary_term"); op.add(Builder::size, JsonpDeserializer.integerDeserializer(), "size"); op.add(Builder::slice, SlicedScroll._DESERIALIZER, "slice"); op.add(Builder::sort, JsonpDeserializer.arrayDeserializer(SortOptions._DESERIALIZER), "sort"); op.add(Builder::stats, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "stats"); op.add(Builder::storedFields, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "stored_fields"); op.add(Builder::suggest, Suggester._DESERIALIZER, "suggest"); op.add(Builder::terminateAfter, JsonpDeserializer.longDeserializer(), "terminate_after"); op.add(Builder::timeout, JsonpDeserializer.stringDeserializer(), "timeout"); op.add(Builder::trackScores, JsonpDeserializer.booleanDeserializer(), "track_scores"); op.add(Builder::trackTotalHits, TrackHits._DESERIALIZER, "track_total_hits"); op.add(Builder::version, JsonpDeserializer.booleanDeserializer(), "version"); } // --------------------------------------------------------------------------------------------- /** * Endpoint "{@code async_search.submit}". */ public static final SimpleEndpoint _ENDPOINT = new SimpleEndpoint<>("es/async_search.submit", // Request method request -> { return "POST"; }, // Request path request -> { final int _index = 1 << 0; int propsSet = 0; if (ApiTypeHelper.isDefined(request.index())) propsSet |= _index; if (propsSet == 0) { StringBuilder buf = new StringBuilder(); buf.append("/_async_search"); return buf.toString(); } if (propsSet == (_index)) { StringBuilder buf = new StringBuilder(); buf.append("/"); SimpleEndpoint.pathEncode(request.index.stream().map(v -> v).collect(Collectors.joining(",")), buf); buf.append("/_async_search"); return buf.toString(); } throw SimpleEndpoint.noPathTemplateFound("path"); }, // Request parameters request -> { Map params = new HashMap<>(); params.put("typed_keys", "true"); if (request.df != null) { params.put("df", request.df); } if (request.preFilterShardSize != null) { params.put("pre_filter_shard_size", String.valueOf(request.preFilterShardSize)); } if (request.minCompatibleShardNode != null) { params.put("min_compatible_shard_node", request.minCompatibleShardNode); } if (request.lenient != null) { params.put("lenient", String.valueOf(request.lenient)); } if (request.routing != null) { params.put("routing", request.routing); } if (request.ignoreUnavailable != null) { params.put("ignore_unavailable", String.valueOf(request.ignoreUnavailable)); } if (request.allowNoIndices != null) { params.put("allow_no_indices", String.valueOf(request.allowNoIndices)); } if (request.analyzer != null) { params.put("analyzer", request.analyzer); } if (request.ignoreThrottled != null) { params.put("ignore_throttled", String.valueOf(request.ignoreThrottled)); } if (request.keepOnCompletion != null) { params.put("keep_on_completion", String.valueOf(request.keepOnCompletion)); } if (request.maxConcurrentShardRequests != null) { params.put("max_concurrent_shard_requests", String.valueOf(request.maxConcurrentShardRequests)); } if (request.allowPartialSearchResults != null) { params.put("allow_partial_search_results", String.valueOf(request.allowPartialSearchResults)); } if (ApiTypeHelper.isDefined(request.expandWildcards)) { params.put("expand_wildcards", request.expandWildcards.stream().map(v -> v.jsonValue()).collect(Collectors.joining(","))); } if (request.preference != null) { params.put("preference", request.preference); } if (request.analyzeWildcard != null) { params.put("analyze_wildcard", String.valueOf(request.analyzeWildcard)); } if (request.scroll != null) { params.put("scroll", request.scroll._toJsonString()); } if (request.waitForCompletionTimeout != null) { params.put("wait_for_completion_timeout", request.waitForCompletionTimeout._toJsonString()); } if (request.searchType != null) { params.put("search_type", request.searchType.jsonValue()); } if (request.ccsMinimizeRoundtrips != null) { params.put("ccs_minimize_roundtrips", String.valueOf(request.ccsMinimizeRoundtrips)); } if (request.q != null) { params.put("q", request.q); } if (request.defaultOperator != null) { params.put("default_operator", request.defaultOperator.jsonValue()); } if (request.keepAlive != null) { params.put("keep_alive", request.keepAlive._toJsonString()); } if (request.requestCache != null) { params.put("request_cache", String.valueOf(request.requestCache)); } if (request.batchedReduceSize != null) { params.put("batched_reduce_size", String.valueOf(request.batchedReduceSize)); } return params; }, SimpleEndpoint.emptyMap(), true, SubmitResponse._DESERIALIZER); /** * Create an "{@code async_search.submit}" endpoint. */ public static Endpoint, ErrorResponse> createSubmitEndpoint( JsonpDeserializer tDocumentDeserializer) { return _ENDPOINT .withResponseDeserializer(SubmitResponse.createSubmitResponseDeserializer(tDocumentDeserializer)); } }
* Adds all entries of map to aggregations. */ public final Builder aggregations(Map map) { this.aggregations = _mapPutAll(this.aggregations, map); return this; } /** * API name: {@code aggregations} * * Adds an entry to aggregations. */ public final Builder aggregations(String key, Aggregation value) { this.aggregations = _mapPut(this.aggregations, key, value); return this; } /** * API name: {@code aggregations} * * Adds an entry to aggregations using a builder lambda. */ public final Builder aggregations(String key, Function> fn) { return aggregations(key, fn.apply(new Aggregation.Builder()).build()); } /** * Whether to ignore if a wildcard indices expression resolves into no concrete * indices. (This includes _all string or when no indices have been * specified) * * API name: {@code allow_no_indices} */ public final Builder allowNoIndices(@Nullable Boolean value) { this.allowNoIndices = value; return this; } /** * Indicate if an error should be returned if there is a partial search failure * or timeout * * API name: {@code allow_partial_search_results} */ public final Builder allowPartialSearchResults(@Nullable Boolean value) { this.allowPartialSearchResults = value; return this; } /** * Specify whether wildcard and prefix queries should be analyzed (default: * false) * * API name: {@code analyze_wildcard} */ public final Builder analyzeWildcard(@Nullable Boolean value) { this.analyzeWildcard = value; return this; } /** * The analyzer to use for the query string * * API name: {@code analyzer} */ public final Builder analyzer(@Nullable String value) { this.analyzer = value; return this; } /** * The number of shard results that should be reduced at once on the * coordinating node. This value should be used as the granularity at which * progress results will be made available. * * API name: {@code batched_reduce_size} */ public final Builder batchedReduceSize(@Nullable Long value) { this.batchedReduceSize = value; return this; } /** * API name: {@code ccs_minimize_roundtrips} */ public final Builder ccsMinimizeRoundtrips(@Nullable Boolean value) { this.ccsMinimizeRoundtrips = value; return this; } /** * API name: {@code collapse} */ public final Builder collapse(@Nullable FieldCollapse value) { this.collapse = value; return this; } /** * API name: {@code collapse} */ public final Builder collapse(Function> fn) { return this.collapse(fn.apply(new FieldCollapse.Builder()).build()); } /** * The default operator for query string query (AND or OR) * * API name: {@code default_operator} */ public final Builder defaultOperator(@Nullable Operator value) { this.defaultOperator = value; return this; } /** * The field to use as default where no field prefix is given in the query * string * * API name: {@code df} */ public final Builder df(@Nullable String value) { this.df = value; return this; } /** * Array of wildcard (*) patterns. The request returns doc values for field * names matching these patterns in the hits.fields property of the response. * * API name: {@code docvalue_fields} * * Adds all elements of list to docvalueFields. */ public final Builder docvalueFields(List list) { this.docvalueFields = _listAddAll(this.docvalueFields, list); return this; } /** * Array of wildcard (*) patterns. The request returns doc values for field * names matching these patterns in the hits.fields property of the response. * * API name: {@code docvalue_fields} * * Adds one or more values to docvalueFields. */ public final Builder docvalueFields(FieldAndFormat value, FieldAndFormat... values) { this.docvalueFields = _listAdd(this.docvalueFields, value, values); return this; } /** * Array of wildcard (*) patterns. The request returns doc values for field * names matching these patterns in the hits.fields property of the response. * * API name: {@code docvalue_fields} * * Adds a value to docvalueFields using a builder lambda. */ public final Builder docvalueFields(Function> fn) { return docvalueFields(fn.apply(new FieldAndFormat.Builder()).build()); } /** * Whether to expand wildcard expression to concrete indices that are open, * closed or both. * * API name: {@code expand_wildcards} * * Adds all elements of list to expandWildcards. */ public final Builder expandWildcards(List list) { this.expandWildcards = _listAddAll(this.expandWildcards, list); return this; } /** * Whether to expand wildcard expression to concrete indices that are open, * closed or both. * * API name: {@code expand_wildcards} * * Adds one or more values to expandWildcards. */ public final Builder expandWildcards(ExpandWildcard value, ExpandWildcard... values) { this.expandWildcards = _listAdd(this.expandWildcards, value, values); return this; } /** * If true, returns detailed information about score computation as part of a * hit. * * API name: {@code explain} */ public final Builder explain(@Nullable Boolean value) { this.explain = value; return this; } /** * Array of wildcard (*) patterns. The request returns values for field names * matching these patterns in the hits.fields property of the response. * * API name: {@code fields} * * Adds all elements of list to fields. */ public final Builder fields(List list) { this.fields = _listAddAll(this.fields, list); return this; } /** * Array of wildcard (*) patterns. The request returns values for field names * matching these patterns in the hits.fields property of the response. * * API name: {@code fields} * * Adds one or more values to fields. */ public final Builder fields(FieldAndFormat value, FieldAndFormat... values) { this.fields = _listAdd(this.fields, value, values); return this; } /** * Array of wildcard (*) patterns. The request returns values for field names * matching these patterns in the hits.fields property of the response. * * API name: {@code fields} * * Adds a value to fields using a builder lambda. */ public final Builder fields(Function> fn) { return fields(fn.apply(new FieldAndFormat.Builder()).build()); } /** * Starting document offset. By default, you cannot page through more than * 10,000 hits using the from and size parameters. To page through more hits, * use the search_after parameter. * * API name: {@code from} */ public final Builder from(@Nullable Integer value) { this.from = value; return this; } /** * API name: {@code highlight} */ public final Builder highlight(@Nullable Highlight value) { this.highlight = value; return this; } /** * API name: {@code highlight} */ public final Builder highlight(Function> fn) { return this.highlight(fn.apply(new Highlight.Builder()).build()); } /** * Whether specified concrete, expanded or aliased indices should be ignored * when throttled * * API name: {@code ignore_throttled} */ public final Builder ignoreThrottled(@Nullable Boolean value) { this.ignoreThrottled = value; return this; } /** * Whether specified concrete indices should be ignored when unavailable * (missing or closed) * * API name: {@code ignore_unavailable} */ public final Builder ignoreUnavailable(@Nullable Boolean value) { this.ignoreUnavailable = value; return this; } /** * A comma-separated list of index names to search; use _all or * empty string to perform the operation on all indices * * API name: {@code index} * * Adds all elements of list to index. */ public final Builder index(List list) { this.index = _listAddAll(this.index, list); return this; } /** * A comma-separated list of index names to search; use _all or * empty string to perform the operation on all indices * * API name: {@code index} * * Adds one or more values to index. */ public final Builder index(String value, String... values) { this.index = _listAdd(this.index, value, values); return this; } /** * Boosts the _score of documents from specified indices. * * API name: {@code indices_boost} * * Adds all elements of list to indicesBoost. */ public final Builder indicesBoost(List> list) { this.indicesBoost = _listAddAll(this.indicesBoost, list); return this; } /** * Boosts the _score of documents from specified indices. * * API name: {@code indices_boost} * * Adds one or more values to indicesBoost. */ public final Builder indicesBoost(Map value, Map... values) { this.indicesBoost = _listAdd(this.indicesBoost, value, values); return this; } /** * Update the time interval in which the results (partial or final) for this * search will be available * * API name: {@code keep_alive} */ public final Builder keepAlive(@Nullable Time value) { this.keepAlive = value; return this; } /** * Update the time interval in which the results (partial or final) for this * search will be available * * API name: {@code keep_alive} */ public final Builder keepAlive(Function> fn) { return this.keepAlive(fn.apply(new Time.Builder()).build()); } /** * Control whether the response should be stored in the cluster if it completed * within the provided [wait_for_completion] time (default: false) * * API name: {@code keep_on_completion} */ public final Builder keepOnCompletion(@Nullable Boolean value) { this.keepOnCompletion = value; return this; } /** * Specify whether format-based query failures (such as providing text to a * numeric field) should be ignored * * API name: {@code lenient} */ public final Builder lenient(@Nullable Boolean value) { this.lenient = value; return this; } /** * The number of concurrent shard requests per node this search executes * concurrently. This value should be used to limit the impact of the search on * the cluster in order to limit the number of concurrent shard requests * * API name: {@code max_concurrent_shard_requests} */ public final Builder maxConcurrentShardRequests(@Nullable Long value) { this.maxConcurrentShardRequests = value; return this; } /** * API name: {@code min_compatible_shard_node} */ public final Builder minCompatibleShardNode(@Nullable String value) { this.minCompatibleShardNode = value; return this; } /** * Minimum _score for matching documents. Documents with a lower _score are not * included in the search results. * * API name: {@code min_score} */ public final Builder minScore(@Nullable Double value) { this.minScore = value; return this; } /** * Limits the search to a point in time (PIT). If you provide a PIT, you cannot * specify an <index> in the request path. * * API name: {@code pit} */ public final Builder pit(@Nullable PointInTimeReference value) { this.pit = value; return this; } /** * Limits the search to a point in time (PIT). If you provide a PIT, you cannot * specify an <index> in the request path. * * API name: {@code pit} */ public final Builder pit(Function> fn) { return this.pit(fn.apply(new PointInTimeReference.Builder()).build()); } /** * API name: {@code post_filter} */ public final Builder postFilter(@Nullable Query value) { this.postFilter = value; return this; } /** * API name: {@code post_filter} */ public final Builder postFilter(Function> fn) { return this.postFilter(fn.apply(new Query.Builder()).build()); } /** * API name: {@code pre_filter_shard_size} */ public final Builder preFilterShardSize(@Nullable Long value) { this.preFilterShardSize = value; return this; } /** * Specify the node or shard the operation should be performed on (default: * random) * * API name: {@code preference} */ public final Builder preference(@Nullable String value) { this.preference = value; return this; } /** * API name: {@code profile} */ public final Builder profile(@Nullable Boolean value) { this.profile = value; return this; } /** * Query in the Lucene query string syntax * * API name: {@code q} */ public final Builder q(@Nullable String value) { this.q = value; return this; } /** * Defines the search definition using the Query DSL. * * API name: {@code query} */ public final Builder query(@Nullable Query value) { this.query = value; return this; } /** * Defines the search definition using the Query DSL. * * API name: {@code query} */ public final Builder query(Function> fn) { return this.query(fn.apply(new Query.Builder()).build()); } /** * Specify if request cache should be used for this request or not, defaults to * true * * API name: {@code request_cache} */ public final Builder requestCache(@Nullable Boolean value) { this.requestCache = value; return this; } /** * API name: {@code rescore} * * Adds all elements of list to rescore. */ public final Builder rescore(List list) { this.rescore = _listAddAll(this.rescore, list); return this; } /** * API name: {@code rescore} * * Adds one or more values to rescore. */ public final Builder rescore(Rescore value, Rescore... values) { this.rescore = _listAdd(this.rescore, value, values); return this; } /** * API name: {@code rescore} * * Adds a value to rescore using a builder lambda. */ public final Builder rescore(Function> fn) { return rescore(fn.apply(new Rescore.Builder()).build()); } /** * A comma-separated list of specific routing values * * API name: {@code routing} */ public final Builder routing(@Nullable String value) { this.routing = value; return this; } /** * Defines one or more runtime fields in the search request. These fields take * precedence over mapped fields with the same name. * * API name: {@code runtime_mappings} * * Adds all entries of map to runtimeMappings. */ public final Builder runtimeMappings(Map> map) { this.runtimeMappings = _mapPutAll(this.runtimeMappings, map); return this; } /** * Defines one or more runtime fields in the search request. These fields take * precedence over mapped fields with the same name. * * API name: {@code runtime_mappings} * * Adds an entry to runtimeMappings. */ public final Builder runtimeMappings(String key, List value) { this.runtimeMappings = _mapPut(this.runtimeMappings, key, value); return this; } /** * Retrieve a script evaluation (based on different fields) for each hit. * * API name: {@code script_fields} * * Adds all entries of map to scriptFields. */ public final Builder scriptFields(Map map) { this.scriptFields = _mapPutAll(this.scriptFields, map); return this; } /** * Retrieve a script evaluation (based on different fields) for each hit. * * API name: {@code script_fields} * * Adds an entry to scriptFields. */ public final Builder scriptFields(String key, ScriptField value) { this.scriptFields = _mapPut(this.scriptFields, key, value); return this; } /** * Retrieve a script evaluation (based on different fields) for each hit. * * API name: {@code script_fields} * * Adds an entry to scriptFields using a builder lambda. */ public final Builder scriptFields(String key, Function> fn) { return scriptFields(key, fn.apply(new ScriptField.Builder()).build()); } /** * API name: {@code scroll} */ public final Builder scroll(@Nullable Time value) { this.scroll = value; return this; } /** * API name: {@code scroll} */ public final Builder scroll(Function> fn) { return this.scroll(fn.apply(new Time.Builder()).build()); } /** * API name: {@code search_after} * * Adds all elements of list to searchAfter. */ public final Builder searchAfter(List list) { this.searchAfter = _listAddAll(this.searchAfter, list); return this; } /** * API name: {@code search_after} * * Adds one or more values to searchAfter. */ public final Builder searchAfter(String value, String... values) { this.searchAfter = _listAdd(this.searchAfter, value, values); return this; } /** * Search operation type * * API name: {@code search_type} */ public final Builder searchType(@Nullable SearchType value) { this.searchType = value; return this; } /** * If true, returns sequence number and primary term of the last modification of * each hit. See Optimistic concurrency control. * * API name: {@code seq_no_primary_term} */ public final Builder seqNoPrimaryTerm(@Nullable Boolean value) { this.seqNoPrimaryTerm = value; return this; } /** * The number of hits to return. By default, you cannot page through more than * 10,000 hits using the from and size parameters. To page through more hits, * use the search_after parameter. * * API name: {@code size} */ public final Builder size(@Nullable Integer value) { this.size = value; return this; } /** * API name: {@code slice} */ public final Builder slice(@Nullable SlicedScroll value) { this.slice = value; return this; } /** * API name: {@code slice} */ public final Builder slice(Function> fn) { return this.slice(fn.apply(new SlicedScroll.Builder()).build()); } /** * API name: {@code sort} * * Adds all elements of list to sort. */ public final Builder sort(List list) { this.sort = _listAddAll(this.sort, list); return this; } /** * API name: {@code sort} * * Adds one or more values to sort. */ public final Builder sort(SortOptions value, SortOptions... values) { this.sort = _listAdd(this.sort, value, values); return this; } /** * API name: {@code sort} * * Adds a value to sort using a builder lambda. */ public final Builder sort(Function> fn) { return sort(fn.apply(new SortOptions.Builder()).build()); } /** * Stats groups to associate with the search. Each group maintains a statistics * aggregation for its associated searches. You can retrieve these stats using * the indices stats API. * * API name: {@code stats} * * Adds all elements of list to stats. */ public final Builder stats(List list) { this.stats = _listAddAll(this.stats, list); return this; } /** * Stats groups to associate with the search. Each group maintains a statistics * aggregation for its associated searches. You can retrieve these stats using * the indices stats API. * * API name: {@code stats} * * Adds one or more values to stats. */ public final Builder stats(String value, String... values) { this.stats = _listAdd(this.stats, value, values); return this; } /** * List of stored fields to return as part of a hit. If no fields are specified, * no stored fields are included in the response. If this field is specified, * the _source parameter defaults to false. You can pass _source: true to return * both source fields and stored fields in the search response. * * API name: {@code stored_fields} * * Adds all elements of list to storedFields. */ public final Builder storedFields(List list) { this.storedFields = _listAddAll(this.storedFields, list); return this; } /** * List of stored fields to return as part of a hit. If no fields are specified, * no stored fields are included in the response. If this field is specified, * the _source parameter defaults to false. You can pass _source: true to return * both source fields and stored fields in the search response. * * API name: {@code stored_fields} * * Adds one or more values to storedFields. */ public final Builder storedFields(String value, String... values) { this.storedFields = _listAdd(this.storedFields, value, values); return this; } /** * API name: {@code suggest} */ public final Builder suggest(@Nullable Suggester value) { this.suggest = value; return this; } /** * API name: {@code suggest} */ public final Builder suggest(Function> fn) { return this.suggest(fn.apply(new Suggester.Builder()).build()); } /** * Maximum number of documents to collect for each shard. If a query reaches * this limit, Elasticsearch terminates the query early. Elasticsearch collects * documents before sorting. Defaults to 0, which does not terminate query * execution early. * * API name: {@code terminate_after} */ public final Builder terminateAfter(@Nullable Long value) { this.terminateAfter = value; return this; } /** * Specifies the period of time to wait for a response from each shard. If no * response is received before the timeout expires, the request fails and * returns an error. Defaults to no timeout. * * API name: {@code timeout} */ public final Builder timeout(@Nullable String value) { this.timeout = value; return this; } /** * If true, calculate and return document scores, even if the scores are not * used for sorting. * * API name: {@code track_scores} */ public final Builder trackScores(@Nullable Boolean value) { this.trackScores = value; return this; } /** * Number of hits matching the query to count accurately. If true, the exact * number of hits is returned at the cost of some performance. If false, the * response does not include the total number of hits matching the query. * Defaults to 10,000 hits. * * API name: {@code track_total_hits} */ public final Builder trackTotalHits(@Nullable TrackHits value) { this.trackTotalHits = value; return this; } /** * Number of hits matching the query to count accurately. If true, the exact * number of hits is returned at the cost of some performance. If false, the * response does not include the total number of hits matching the query. * Defaults to 10,000 hits. * * API name: {@code track_total_hits} */ public final Builder trackTotalHits(Function> fn) { return this.trackTotalHits(fn.apply(new TrackHits.Builder()).build()); } /** * If true, returns document version as part of a hit. * * API name: {@code version} */ public final Builder version(@Nullable Boolean value) { this.version = value; return this; } /** * Specify the time that the request should block waiting for the final response * * API name: {@code wait_for_completion_timeout} */ public final Builder waitForCompletionTimeout(@Nullable Time value) { this.waitForCompletionTimeout = value; return this; } /** * Specify the time that the request should block waiting for the final response * * API name: {@code wait_for_completion_timeout} */ public final Builder waitForCompletionTimeout(Function> fn) { return this.waitForCompletionTimeout(fn.apply(new Time.Builder()).build()); } @Override protected Builder self() { return this; } /** * Builds a {@link SubmitRequest}. * * @throws NullPointerException * if some of the required fields are null. */ public SubmitRequest build() { _checkSingleUse(); return new SubmitRequest(this); } } // --------------------------------------------------------------------------------------------- /** * Json deserializer for {@link SubmitRequest} */ public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy(Builder::new, SubmitRequest::setupSubmitRequestDeserializer); protected static void setupSubmitRequestDeserializer(ObjectDeserializer op) { op.add(Builder::source, SourceConfig._DESERIALIZER, "_source"); op.add(Builder::aggregations, JsonpDeserializer.stringMapDeserializer(Aggregation._DESERIALIZER), "aggregations", "aggs"); op.add(Builder::collapse, FieldCollapse._DESERIALIZER, "collapse"); op.add(Builder::docvalueFields, JsonpDeserializer.arrayDeserializer(FieldAndFormat._DESERIALIZER), "docvalue_fields"); op.add(Builder::explain, JsonpDeserializer.booleanDeserializer(), "explain"); op.add(Builder::fields, JsonpDeserializer.arrayDeserializer(FieldAndFormat._DESERIALIZER), "fields"); op.add(Builder::from, JsonpDeserializer.integerDeserializer(), "from"); op.add(Builder::highlight, Highlight._DESERIALIZER, "highlight"); op.add(Builder::indicesBoost, JsonpDeserializer.arrayDeserializer( JsonpDeserializer.stringMapDeserializer(JsonpDeserializer.doubleDeserializer())), "indices_boost"); op.add(Builder::minScore, JsonpDeserializer.doubleDeserializer(), "min_score"); op.add(Builder::pit, PointInTimeReference._DESERIALIZER, "pit"); op.add(Builder::postFilter, Query._DESERIALIZER, "post_filter"); op.add(Builder::profile, JsonpDeserializer.booleanDeserializer(), "profile"); op.add(Builder::query, Query._DESERIALIZER, "query"); op.add(Builder::rescore, JsonpDeserializer.arrayDeserializer(Rescore._DESERIALIZER), "rescore"); op.add(Builder::runtimeMappings, JsonpDeserializer.stringMapDeserializer( JsonpDeserializer.arrayDeserializer(RuntimeField._DESERIALIZER)), "runtime_mappings"); op.add(Builder::scriptFields, JsonpDeserializer.stringMapDeserializer(ScriptField._DESERIALIZER), "script_fields"); op.add(Builder::searchAfter, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "search_after"); op.add(Builder::seqNoPrimaryTerm, JsonpDeserializer.booleanDeserializer(), "seq_no_primary_term"); op.add(Builder::size, JsonpDeserializer.integerDeserializer(), "size"); op.add(Builder::slice, SlicedScroll._DESERIALIZER, "slice"); op.add(Builder::sort, JsonpDeserializer.arrayDeserializer(SortOptions._DESERIALIZER), "sort"); op.add(Builder::stats, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "stats"); op.add(Builder::storedFields, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "stored_fields"); op.add(Builder::suggest, Suggester._DESERIALIZER, "suggest"); op.add(Builder::terminateAfter, JsonpDeserializer.longDeserializer(), "terminate_after"); op.add(Builder::timeout, JsonpDeserializer.stringDeserializer(), "timeout"); op.add(Builder::trackScores, JsonpDeserializer.booleanDeserializer(), "track_scores"); op.add(Builder::trackTotalHits, TrackHits._DESERIALIZER, "track_total_hits"); op.add(Builder::version, JsonpDeserializer.booleanDeserializer(), "version"); } // --------------------------------------------------------------------------------------------- /** * Endpoint "{@code async_search.submit}". */ public static final SimpleEndpoint _ENDPOINT = new SimpleEndpoint<>("es/async_search.submit", // Request method request -> { return "POST"; }, // Request path request -> { final int _index = 1 << 0; int propsSet = 0; if (ApiTypeHelper.isDefined(request.index())) propsSet |= _index; if (propsSet == 0) { StringBuilder buf = new StringBuilder(); buf.append("/_async_search"); return buf.toString(); } if (propsSet == (_index)) { StringBuilder buf = new StringBuilder(); buf.append("/"); SimpleEndpoint.pathEncode(request.index.stream().map(v -> v).collect(Collectors.joining(",")), buf); buf.append("/_async_search"); return buf.toString(); } throw SimpleEndpoint.noPathTemplateFound("path"); }, // Request parameters request -> { Map params = new HashMap<>(); params.put("typed_keys", "true"); if (request.df != null) { params.put("df", request.df); } if (request.preFilterShardSize != null) { params.put("pre_filter_shard_size", String.valueOf(request.preFilterShardSize)); } if (request.minCompatibleShardNode != null) { params.put("min_compatible_shard_node", request.minCompatibleShardNode); } if (request.lenient != null) { params.put("lenient", String.valueOf(request.lenient)); } if (request.routing != null) { params.put("routing", request.routing); } if (request.ignoreUnavailable != null) { params.put("ignore_unavailable", String.valueOf(request.ignoreUnavailable)); } if (request.allowNoIndices != null) { params.put("allow_no_indices", String.valueOf(request.allowNoIndices)); } if (request.analyzer != null) { params.put("analyzer", request.analyzer); } if (request.ignoreThrottled != null) { params.put("ignore_throttled", String.valueOf(request.ignoreThrottled)); } if (request.keepOnCompletion != null) { params.put("keep_on_completion", String.valueOf(request.keepOnCompletion)); } if (request.maxConcurrentShardRequests != null) { params.put("max_concurrent_shard_requests", String.valueOf(request.maxConcurrentShardRequests)); } if (request.allowPartialSearchResults != null) { params.put("allow_partial_search_results", String.valueOf(request.allowPartialSearchResults)); } if (ApiTypeHelper.isDefined(request.expandWildcards)) { params.put("expand_wildcards", request.expandWildcards.stream().map(v -> v.jsonValue()).collect(Collectors.joining(","))); } if (request.preference != null) { params.put("preference", request.preference); } if (request.analyzeWildcard != null) { params.put("analyze_wildcard", String.valueOf(request.analyzeWildcard)); } if (request.scroll != null) { params.put("scroll", request.scroll._toJsonString()); } if (request.waitForCompletionTimeout != null) { params.put("wait_for_completion_timeout", request.waitForCompletionTimeout._toJsonString()); } if (request.searchType != null) { params.put("search_type", request.searchType.jsonValue()); } if (request.ccsMinimizeRoundtrips != null) { params.put("ccs_minimize_roundtrips", String.valueOf(request.ccsMinimizeRoundtrips)); } if (request.q != null) { params.put("q", request.q); } if (request.defaultOperator != null) { params.put("default_operator", request.defaultOperator.jsonValue()); } if (request.keepAlive != null) { params.put("keep_alive", request.keepAlive._toJsonString()); } if (request.requestCache != null) { params.put("request_cache", String.valueOf(request.requestCache)); } if (request.batchedReduceSize != null) { params.put("batched_reduce_size", String.valueOf(request.batchedReduceSize)); } return params; }, SimpleEndpoint.emptyMap(), true, SubmitResponse._DESERIALIZER); /** * Create an "{@code async_search.submit}" endpoint. */ public static Endpoint, ErrorResponse> createSubmitEndpoint( JsonpDeserializer tDocumentDeserializer) { return _ENDPOINT .withResponseDeserializer(SubmitResponse.createSubmitResponseDeserializer(tDocumentDeserializer)); } }
map
aggregations
* Adds an entry to aggregations. */ public final Builder aggregations(String key, Aggregation value) { this.aggregations = _mapPut(this.aggregations, key, value); return this; } /** * API name: {@code aggregations} *
* Adds an entry to aggregations using a builder lambda. */ public final Builder aggregations(String key, Function> fn) { return aggregations(key, fn.apply(new Aggregation.Builder()).build()); } /** * Whether to ignore if a wildcard indices expression resolves into no concrete * indices. (This includes _all string or when no indices have been * specified) * * API name: {@code allow_no_indices} */ public final Builder allowNoIndices(@Nullable Boolean value) { this.allowNoIndices = value; return this; } /** * Indicate if an error should be returned if there is a partial search failure * or timeout * * API name: {@code allow_partial_search_results} */ public final Builder allowPartialSearchResults(@Nullable Boolean value) { this.allowPartialSearchResults = value; return this; } /** * Specify whether wildcard and prefix queries should be analyzed (default: * false) * * API name: {@code analyze_wildcard} */ public final Builder analyzeWildcard(@Nullable Boolean value) { this.analyzeWildcard = value; return this; } /** * The analyzer to use for the query string * * API name: {@code analyzer} */ public final Builder analyzer(@Nullable String value) { this.analyzer = value; return this; } /** * The number of shard results that should be reduced at once on the * coordinating node. This value should be used as the granularity at which * progress results will be made available. * * API name: {@code batched_reduce_size} */ public final Builder batchedReduceSize(@Nullable Long value) { this.batchedReduceSize = value; return this; } /** * API name: {@code ccs_minimize_roundtrips} */ public final Builder ccsMinimizeRoundtrips(@Nullable Boolean value) { this.ccsMinimizeRoundtrips = value; return this; } /** * API name: {@code collapse} */ public final Builder collapse(@Nullable FieldCollapse value) { this.collapse = value; return this; } /** * API name: {@code collapse} */ public final Builder collapse(Function> fn) { return this.collapse(fn.apply(new FieldCollapse.Builder()).build()); } /** * The default operator for query string query (AND or OR) * * API name: {@code default_operator} */ public final Builder defaultOperator(@Nullable Operator value) { this.defaultOperator = value; return this; } /** * The field to use as default where no field prefix is given in the query * string * * API name: {@code df} */ public final Builder df(@Nullable String value) { this.df = value; return this; } /** * Array of wildcard (*) patterns. The request returns doc values for field * names matching these patterns in the hits.fields property of the response. * * API name: {@code docvalue_fields} * * Adds all elements of list to docvalueFields. */ public final Builder docvalueFields(List list) { this.docvalueFields = _listAddAll(this.docvalueFields, list); return this; } /** * Array of wildcard (*) patterns. The request returns doc values for field * names matching these patterns in the hits.fields property of the response. * * API name: {@code docvalue_fields} * * Adds one or more values to docvalueFields. */ public final Builder docvalueFields(FieldAndFormat value, FieldAndFormat... values) { this.docvalueFields = _listAdd(this.docvalueFields, value, values); return this; } /** * Array of wildcard (*) patterns. The request returns doc values for field * names matching these patterns in the hits.fields property of the response. * * API name: {@code docvalue_fields} * * Adds a value to docvalueFields using a builder lambda. */ public final Builder docvalueFields(Function> fn) { return docvalueFields(fn.apply(new FieldAndFormat.Builder()).build()); } /** * Whether to expand wildcard expression to concrete indices that are open, * closed or both. * * API name: {@code expand_wildcards} * * Adds all elements of list to expandWildcards. */ public final Builder expandWildcards(List list) { this.expandWildcards = _listAddAll(this.expandWildcards, list); return this; } /** * Whether to expand wildcard expression to concrete indices that are open, * closed or both. * * API name: {@code expand_wildcards} * * Adds one or more values to expandWildcards. */ public final Builder expandWildcards(ExpandWildcard value, ExpandWildcard... values) { this.expandWildcards = _listAdd(this.expandWildcards, value, values); return this; } /** * If true, returns detailed information about score computation as part of a * hit. * * API name: {@code explain} */ public final Builder explain(@Nullable Boolean value) { this.explain = value; return this; } /** * Array of wildcard (*) patterns. The request returns values for field names * matching these patterns in the hits.fields property of the response. * * API name: {@code fields} * * Adds all elements of list to fields. */ public final Builder fields(List list) { this.fields = _listAddAll(this.fields, list); return this; } /** * Array of wildcard (*) patterns. The request returns values for field names * matching these patterns in the hits.fields property of the response. * * API name: {@code fields} * * Adds one or more values to fields. */ public final Builder fields(FieldAndFormat value, FieldAndFormat... values) { this.fields = _listAdd(this.fields, value, values); return this; } /** * Array of wildcard (*) patterns. The request returns values for field names * matching these patterns in the hits.fields property of the response. * * API name: {@code fields} * * Adds a value to fields using a builder lambda. */ public final Builder fields(Function> fn) { return fields(fn.apply(new FieldAndFormat.Builder()).build()); } /** * Starting document offset. By default, you cannot page through more than * 10,000 hits using the from and size parameters. To page through more hits, * use the search_after parameter. * * API name: {@code from} */ public final Builder from(@Nullable Integer value) { this.from = value; return this; } /** * API name: {@code highlight} */ public final Builder highlight(@Nullable Highlight value) { this.highlight = value; return this; } /** * API name: {@code highlight} */ public final Builder highlight(Function> fn) { return this.highlight(fn.apply(new Highlight.Builder()).build()); } /** * Whether specified concrete, expanded or aliased indices should be ignored * when throttled * * API name: {@code ignore_throttled} */ public final Builder ignoreThrottled(@Nullable Boolean value) { this.ignoreThrottled = value; return this; } /** * Whether specified concrete indices should be ignored when unavailable * (missing or closed) * * API name: {@code ignore_unavailable} */ public final Builder ignoreUnavailable(@Nullable Boolean value) { this.ignoreUnavailable = value; return this; } /** * A comma-separated list of index names to search; use _all or * empty string to perform the operation on all indices * * API name: {@code index} * * Adds all elements of list to index. */ public final Builder index(List list) { this.index = _listAddAll(this.index, list); return this; } /** * A comma-separated list of index names to search; use _all or * empty string to perform the operation on all indices * * API name: {@code index} * * Adds one or more values to index. */ public final Builder index(String value, String... values) { this.index = _listAdd(this.index, value, values); return this; } /** * Boosts the _score of documents from specified indices. * * API name: {@code indices_boost} * * Adds all elements of list to indicesBoost. */ public final Builder indicesBoost(List> list) { this.indicesBoost = _listAddAll(this.indicesBoost, list); return this; } /** * Boosts the _score of documents from specified indices. * * API name: {@code indices_boost} * * Adds one or more values to indicesBoost. */ public final Builder indicesBoost(Map value, Map... values) { this.indicesBoost = _listAdd(this.indicesBoost, value, values); return this; } /** * Update the time interval in which the results (partial or final) for this * search will be available * * API name: {@code keep_alive} */ public final Builder keepAlive(@Nullable Time value) { this.keepAlive = value; return this; } /** * Update the time interval in which the results (partial or final) for this * search will be available * * API name: {@code keep_alive} */ public final Builder keepAlive(Function> fn) { return this.keepAlive(fn.apply(new Time.Builder()).build()); } /** * Control whether the response should be stored in the cluster if it completed * within the provided [wait_for_completion] time (default: false) * * API name: {@code keep_on_completion} */ public final Builder keepOnCompletion(@Nullable Boolean value) { this.keepOnCompletion = value; return this; } /** * Specify whether format-based query failures (such as providing text to a * numeric field) should be ignored * * API name: {@code lenient} */ public final Builder lenient(@Nullable Boolean value) { this.lenient = value; return this; } /** * The number of concurrent shard requests per node this search executes * concurrently. This value should be used to limit the impact of the search on * the cluster in order to limit the number of concurrent shard requests * * API name: {@code max_concurrent_shard_requests} */ public final Builder maxConcurrentShardRequests(@Nullable Long value) { this.maxConcurrentShardRequests = value; return this; } /** * API name: {@code min_compatible_shard_node} */ public final Builder minCompatibleShardNode(@Nullable String value) { this.minCompatibleShardNode = value; return this; } /** * Minimum _score for matching documents. Documents with a lower _score are not * included in the search results. * * API name: {@code min_score} */ public final Builder minScore(@Nullable Double value) { this.minScore = value; return this; } /** * Limits the search to a point in time (PIT). If you provide a PIT, you cannot * specify an <index> in the request path. * * API name: {@code pit} */ public final Builder pit(@Nullable PointInTimeReference value) { this.pit = value; return this; } /** * Limits the search to a point in time (PIT). If you provide a PIT, you cannot * specify an <index> in the request path. * * API name: {@code pit} */ public final Builder pit(Function> fn) { return this.pit(fn.apply(new PointInTimeReference.Builder()).build()); } /** * API name: {@code post_filter} */ public final Builder postFilter(@Nullable Query value) { this.postFilter = value; return this; } /** * API name: {@code post_filter} */ public final Builder postFilter(Function> fn) { return this.postFilter(fn.apply(new Query.Builder()).build()); } /** * API name: {@code pre_filter_shard_size} */ public final Builder preFilterShardSize(@Nullable Long value) { this.preFilterShardSize = value; return this; } /** * Specify the node or shard the operation should be performed on (default: * random) * * API name: {@code preference} */ public final Builder preference(@Nullable String value) { this.preference = value; return this; } /** * API name: {@code profile} */ public final Builder profile(@Nullable Boolean value) { this.profile = value; return this; } /** * Query in the Lucene query string syntax * * API name: {@code q} */ public final Builder q(@Nullable String value) { this.q = value; return this; } /** * Defines the search definition using the Query DSL. * * API name: {@code query} */ public final Builder query(@Nullable Query value) { this.query = value; return this; } /** * Defines the search definition using the Query DSL. * * API name: {@code query} */ public final Builder query(Function> fn) { return this.query(fn.apply(new Query.Builder()).build()); } /** * Specify if request cache should be used for this request or not, defaults to * true * * API name: {@code request_cache} */ public final Builder requestCache(@Nullable Boolean value) { this.requestCache = value; return this; } /** * API name: {@code rescore} * * Adds all elements of list to rescore. */ public final Builder rescore(List list) { this.rescore = _listAddAll(this.rescore, list); return this; } /** * API name: {@code rescore} * * Adds one or more values to rescore. */ public final Builder rescore(Rescore value, Rescore... values) { this.rescore = _listAdd(this.rescore, value, values); return this; } /** * API name: {@code rescore} * * Adds a value to rescore using a builder lambda. */ public final Builder rescore(Function> fn) { return rescore(fn.apply(new Rescore.Builder()).build()); } /** * A comma-separated list of specific routing values * * API name: {@code routing} */ public final Builder routing(@Nullable String value) { this.routing = value; return this; } /** * Defines one or more runtime fields in the search request. These fields take * precedence over mapped fields with the same name. * * API name: {@code runtime_mappings} * * Adds all entries of map to runtimeMappings. */ public final Builder runtimeMappings(Map> map) { this.runtimeMappings = _mapPutAll(this.runtimeMappings, map); return this; } /** * Defines one or more runtime fields in the search request. These fields take * precedence over mapped fields with the same name. * * API name: {@code runtime_mappings} * * Adds an entry to runtimeMappings. */ public final Builder runtimeMappings(String key, List value) { this.runtimeMappings = _mapPut(this.runtimeMappings, key, value); return this; } /** * Retrieve a script evaluation (based on different fields) for each hit. * * API name: {@code script_fields} * * Adds all entries of map to scriptFields. */ public final Builder scriptFields(Map map) { this.scriptFields = _mapPutAll(this.scriptFields, map); return this; } /** * Retrieve a script evaluation (based on different fields) for each hit. * * API name: {@code script_fields} * * Adds an entry to scriptFields. */ public final Builder scriptFields(String key, ScriptField value) { this.scriptFields = _mapPut(this.scriptFields, key, value); return this; } /** * Retrieve a script evaluation (based on different fields) for each hit. * * API name: {@code script_fields} * * Adds an entry to scriptFields using a builder lambda. */ public final Builder scriptFields(String key, Function> fn) { return scriptFields(key, fn.apply(new ScriptField.Builder()).build()); } /** * API name: {@code scroll} */ public final Builder scroll(@Nullable Time value) { this.scroll = value; return this; } /** * API name: {@code scroll} */ public final Builder scroll(Function> fn) { return this.scroll(fn.apply(new Time.Builder()).build()); } /** * API name: {@code search_after} * * Adds all elements of list to searchAfter. */ public final Builder searchAfter(List list) { this.searchAfter = _listAddAll(this.searchAfter, list); return this; } /** * API name: {@code search_after} * * Adds one or more values to searchAfter. */ public final Builder searchAfter(String value, String... values) { this.searchAfter = _listAdd(this.searchAfter, value, values); return this; } /** * Search operation type * * API name: {@code search_type} */ public final Builder searchType(@Nullable SearchType value) { this.searchType = value; return this; } /** * If true, returns sequence number and primary term of the last modification of * each hit. See Optimistic concurrency control. * * API name: {@code seq_no_primary_term} */ public final Builder seqNoPrimaryTerm(@Nullable Boolean value) { this.seqNoPrimaryTerm = value; return this; } /** * The number of hits to return. By default, you cannot page through more than * 10,000 hits using the from and size parameters. To page through more hits, * use the search_after parameter. * * API name: {@code size} */ public final Builder size(@Nullable Integer value) { this.size = value; return this; } /** * API name: {@code slice} */ public final Builder slice(@Nullable SlicedScroll value) { this.slice = value; return this; } /** * API name: {@code slice} */ public final Builder slice(Function> fn) { return this.slice(fn.apply(new SlicedScroll.Builder()).build()); } /** * API name: {@code sort} * * Adds all elements of list to sort. */ public final Builder sort(List list) { this.sort = _listAddAll(this.sort, list); return this; } /** * API name: {@code sort} * * Adds one or more values to sort. */ public final Builder sort(SortOptions value, SortOptions... values) { this.sort = _listAdd(this.sort, value, values); return this; } /** * API name: {@code sort} * * Adds a value to sort using a builder lambda. */ public final Builder sort(Function> fn) { return sort(fn.apply(new SortOptions.Builder()).build()); } /** * Stats groups to associate with the search. Each group maintains a statistics * aggregation for its associated searches. You can retrieve these stats using * the indices stats API. * * API name: {@code stats} * * Adds all elements of list to stats. */ public final Builder stats(List list) { this.stats = _listAddAll(this.stats, list); return this; } /** * Stats groups to associate with the search. Each group maintains a statistics * aggregation for its associated searches. You can retrieve these stats using * the indices stats API. * * API name: {@code stats} * * Adds one or more values to stats. */ public final Builder stats(String value, String... values) { this.stats = _listAdd(this.stats, value, values); return this; } /** * List of stored fields to return as part of a hit. If no fields are specified, * no stored fields are included in the response. If this field is specified, * the _source parameter defaults to false. You can pass _source: true to return * both source fields and stored fields in the search response. * * API name: {@code stored_fields} * * Adds all elements of list to storedFields. */ public final Builder storedFields(List list) { this.storedFields = _listAddAll(this.storedFields, list); return this; } /** * List of stored fields to return as part of a hit. If no fields are specified, * no stored fields are included in the response. If this field is specified, * the _source parameter defaults to false. You can pass _source: true to return * both source fields and stored fields in the search response. * * API name: {@code stored_fields} * * Adds one or more values to storedFields. */ public final Builder storedFields(String value, String... values) { this.storedFields = _listAdd(this.storedFields, value, values); return this; } /** * API name: {@code suggest} */ public final Builder suggest(@Nullable Suggester value) { this.suggest = value; return this; } /** * API name: {@code suggest} */ public final Builder suggest(Function> fn) { return this.suggest(fn.apply(new Suggester.Builder()).build()); } /** * Maximum number of documents to collect for each shard. If a query reaches * this limit, Elasticsearch terminates the query early. Elasticsearch collects * documents before sorting. Defaults to 0, which does not terminate query * execution early. * * API name: {@code terminate_after} */ public final Builder terminateAfter(@Nullable Long value) { this.terminateAfter = value; return this; } /** * Specifies the period of time to wait for a response from each shard. If no * response is received before the timeout expires, the request fails and * returns an error. Defaults to no timeout. * * API name: {@code timeout} */ public final Builder timeout(@Nullable String value) { this.timeout = value; return this; } /** * If true, calculate and return document scores, even if the scores are not * used for sorting. * * API name: {@code track_scores} */ public final Builder trackScores(@Nullable Boolean value) { this.trackScores = value; return this; } /** * Number of hits matching the query to count accurately. If true, the exact * number of hits is returned at the cost of some performance. If false, the * response does not include the total number of hits matching the query. * Defaults to 10,000 hits. * * API name: {@code track_total_hits} */ public final Builder trackTotalHits(@Nullable TrackHits value) { this.trackTotalHits = value; return this; } /** * Number of hits matching the query to count accurately. If true, the exact * number of hits is returned at the cost of some performance. If false, the * response does not include the total number of hits matching the query. * Defaults to 10,000 hits. * * API name: {@code track_total_hits} */ public final Builder trackTotalHits(Function> fn) { return this.trackTotalHits(fn.apply(new TrackHits.Builder()).build()); } /** * If true, returns document version as part of a hit. * * API name: {@code version} */ public final Builder version(@Nullable Boolean value) { this.version = value; return this; } /** * Specify the time that the request should block waiting for the final response * * API name: {@code wait_for_completion_timeout} */ public final Builder waitForCompletionTimeout(@Nullable Time value) { this.waitForCompletionTimeout = value; return this; } /** * Specify the time that the request should block waiting for the final response * * API name: {@code wait_for_completion_timeout} */ public final Builder waitForCompletionTimeout(Function> fn) { return this.waitForCompletionTimeout(fn.apply(new Time.Builder()).build()); } @Override protected Builder self() { return this; } /** * Builds a {@link SubmitRequest}. * * @throws NullPointerException * if some of the required fields are null. */ public SubmitRequest build() { _checkSingleUse(); return new SubmitRequest(this); } } // --------------------------------------------------------------------------------------------- /** * Json deserializer for {@link SubmitRequest} */ public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy(Builder::new, SubmitRequest::setupSubmitRequestDeserializer); protected static void setupSubmitRequestDeserializer(ObjectDeserializer op) { op.add(Builder::source, SourceConfig._DESERIALIZER, "_source"); op.add(Builder::aggregations, JsonpDeserializer.stringMapDeserializer(Aggregation._DESERIALIZER), "aggregations", "aggs"); op.add(Builder::collapse, FieldCollapse._DESERIALIZER, "collapse"); op.add(Builder::docvalueFields, JsonpDeserializer.arrayDeserializer(FieldAndFormat._DESERIALIZER), "docvalue_fields"); op.add(Builder::explain, JsonpDeserializer.booleanDeserializer(), "explain"); op.add(Builder::fields, JsonpDeserializer.arrayDeserializer(FieldAndFormat._DESERIALIZER), "fields"); op.add(Builder::from, JsonpDeserializer.integerDeserializer(), "from"); op.add(Builder::highlight, Highlight._DESERIALIZER, "highlight"); op.add(Builder::indicesBoost, JsonpDeserializer.arrayDeserializer( JsonpDeserializer.stringMapDeserializer(JsonpDeserializer.doubleDeserializer())), "indices_boost"); op.add(Builder::minScore, JsonpDeserializer.doubleDeserializer(), "min_score"); op.add(Builder::pit, PointInTimeReference._DESERIALIZER, "pit"); op.add(Builder::postFilter, Query._DESERIALIZER, "post_filter"); op.add(Builder::profile, JsonpDeserializer.booleanDeserializer(), "profile"); op.add(Builder::query, Query._DESERIALIZER, "query"); op.add(Builder::rescore, JsonpDeserializer.arrayDeserializer(Rescore._DESERIALIZER), "rescore"); op.add(Builder::runtimeMappings, JsonpDeserializer.stringMapDeserializer( JsonpDeserializer.arrayDeserializer(RuntimeField._DESERIALIZER)), "runtime_mappings"); op.add(Builder::scriptFields, JsonpDeserializer.stringMapDeserializer(ScriptField._DESERIALIZER), "script_fields"); op.add(Builder::searchAfter, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "search_after"); op.add(Builder::seqNoPrimaryTerm, JsonpDeserializer.booleanDeserializer(), "seq_no_primary_term"); op.add(Builder::size, JsonpDeserializer.integerDeserializer(), "size"); op.add(Builder::slice, SlicedScroll._DESERIALIZER, "slice"); op.add(Builder::sort, JsonpDeserializer.arrayDeserializer(SortOptions._DESERIALIZER), "sort"); op.add(Builder::stats, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "stats"); op.add(Builder::storedFields, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "stored_fields"); op.add(Builder::suggest, Suggester._DESERIALIZER, "suggest"); op.add(Builder::terminateAfter, JsonpDeserializer.longDeserializer(), "terminate_after"); op.add(Builder::timeout, JsonpDeserializer.stringDeserializer(), "timeout"); op.add(Builder::trackScores, JsonpDeserializer.booleanDeserializer(), "track_scores"); op.add(Builder::trackTotalHits, TrackHits._DESERIALIZER, "track_total_hits"); op.add(Builder::version, JsonpDeserializer.booleanDeserializer(), "version"); } // --------------------------------------------------------------------------------------------- /** * Endpoint "{@code async_search.submit}". */ public static final SimpleEndpoint _ENDPOINT = new SimpleEndpoint<>("es/async_search.submit", // Request method request -> { return "POST"; }, // Request path request -> { final int _index = 1 << 0; int propsSet = 0; if (ApiTypeHelper.isDefined(request.index())) propsSet |= _index; if (propsSet == 0) { StringBuilder buf = new StringBuilder(); buf.append("/_async_search"); return buf.toString(); } if (propsSet == (_index)) { StringBuilder buf = new StringBuilder(); buf.append("/"); SimpleEndpoint.pathEncode(request.index.stream().map(v -> v).collect(Collectors.joining(",")), buf); buf.append("/_async_search"); return buf.toString(); } throw SimpleEndpoint.noPathTemplateFound("path"); }, // Request parameters request -> { Map params = new HashMap<>(); params.put("typed_keys", "true"); if (request.df != null) { params.put("df", request.df); } if (request.preFilterShardSize != null) { params.put("pre_filter_shard_size", String.valueOf(request.preFilterShardSize)); } if (request.minCompatibleShardNode != null) { params.put("min_compatible_shard_node", request.minCompatibleShardNode); } if (request.lenient != null) { params.put("lenient", String.valueOf(request.lenient)); } if (request.routing != null) { params.put("routing", request.routing); } if (request.ignoreUnavailable != null) { params.put("ignore_unavailable", String.valueOf(request.ignoreUnavailable)); } if (request.allowNoIndices != null) { params.put("allow_no_indices", String.valueOf(request.allowNoIndices)); } if (request.analyzer != null) { params.put("analyzer", request.analyzer); } if (request.ignoreThrottled != null) { params.put("ignore_throttled", String.valueOf(request.ignoreThrottled)); } if (request.keepOnCompletion != null) { params.put("keep_on_completion", String.valueOf(request.keepOnCompletion)); } if (request.maxConcurrentShardRequests != null) { params.put("max_concurrent_shard_requests", String.valueOf(request.maxConcurrentShardRequests)); } if (request.allowPartialSearchResults != null) { params.put("allow_partial_search_results", String.valueOf(request.allowPartialSearchResults)); } if (ApiTypeHelper.isDefined(request.expandWildcards)) { params.put("expand_wildcards", request.expandWildcards.stream().map(v -> v.jsonValue()).collect(Collectors.joining(","))); } if (request.preference != null) { params.put("preference", request.preference); } if (request.analyzeWildcard != null) { params.put("analyze_wildcard", String.valueOf(request.analyzeWildcard)); } if (request.scroll != null) { params.put("scroll", request.scroll._toJsonString()); } if (request.waitForCompletionTimeout != null) { params.put("wait_for_completion_timeout", request.waitForCompletionTimeout._toJsonString()); } if (request.searchType != null) { params.put("search_type", request.searchType.jsonValue()); } if (request.ccsMinimizeRoundtrips != null) { params.put("ccs_minimize_roundtrips", String.valueOf(request.ccsMinimizeRoundtrips)); } if (request.q != null) { params.put("q", request.q); } if (request.defaultOperator != null) { params.put("default_operator", request.defaultOperator.jsonValue()); } if (request.keepAlive != null) { params.put("keep_alive", request.keepAlive._toJsonString()); } if (request.requestCache != null) { params.put("request_cache", String.valueOf(request.requestCache)); } if (request.batchedReduceSize != null) { params.put("batched_reduce_size", String.valueOf(request.batchedReduceSize)); } return params; }, SimpleEndpoint.emptyMap(), true, SubmitResponse._DESERIALIZER); /** * Create an "{@code async_search.submit}" endpoint. */ public static Endpoint, ErrorResponse> createSubmitEndpoint( JsonpDeserializer tDocumentDeserializer) { return _ENDPOINT .withResponseDeserializer(SubmitResponse.createSubmitResponseDeserializer(tDocumentDeserializer)); } }
* API name: {@code allow_no_indices} */ public final Builder allowNoIndices(@Nullable Boolean value) { this.allowNoIndices = value; return this; } /** * Indicate if an error should be returned if there is a partial search failure * or timeout *
* API name: {@code allow_partial_search_results} */ public final Builder allowPartialSearchResults(@Nullable Boolean value) { this.allowPartialSearchResults = value; return this; } /** * Specify whether wildcard and prefix queries should be analyzed (default: * false) *
* API name: {@code analyze_wildcard} */ public final Builder analyzeWildcard(@Nullable Boolean value) { this.analyzeWildcard = value; return this; } /** * The analyzer to use for the query string *
* API name: {@code analyzer} */ public final Builder analyzer(@Nullable String value) { this.analyzer = value; return this; } /** * The number of shard results that should be reduced at once on the * coordinating node. This value should be used as the granularity at which * progress results will be made available. *
* API name: {@code batched_reduce_size} */ public final Builder batchedReduceSize(@Nullable Long value) { this.batchedReduceSize = value; return this; } /** * API name: {@code ccs_minimize_roundtrips} */ public final Builder ccsMinimizeRoundtrips(@Nullable Boolean value) { this.ccsMinimizeRoundtrips = value; return this; } /** * API name: {@code collapse} */ public final Builder collapse(@Nullable FieldCollapse value) { this.collapse = value; return this; } /** * API name: {@code collapse} */ public final Builder collapse(Function> fn) { return this.collapse(fn.apply(new FieldCollapse.Builder()).build()); } /** * The default operator for query string query (AND or OR) * * API name: {@code default_operator} */ public final Builder defaultOperator(@Nullable Operator value) { this.defaultOperator = value; return this; } /** * The field to use as default where no field prefix is given in the query * string * * API name: {@code df} */ public final Builder df(@Nullable String value) { this.df = value; return this; } /** * Array of wildcard (*) patterns. The request returns doc values for field * names matching these patterns in the hits.fields property of the response. * * API name: {@code docvalue_fields} * * Adds all elements of list to docvalueFields. */ public final Builder docvalueFields(List list) { this.docvalueFields = _listAddAll(this.docvalueFields, list); return this; } /** * Array of wildcard (*) patterns. The request returns doc values for field * names matching these patterns in the hits.fields property of the response. * * API name: {@code docvalue_fields} * * Adds one or more values to docvalueFields. */ public final Builder docvalueFields(FieldAndFormat value, FieldAndFormat... values) { this.docvalueFields = _listAdd(this.docvalueFields, value, values); return this; } /** * Array of wildcard (*) patterns. The request returns doc values for field * names matching these patterns in the hits.fields property of the response. * * API name: {@code docvalue_fields} * * Adds a value to docvalueFields using a builder lambda. */ public final Builder docvalueFields(Function> fn) { return docvalueFields(fn.apply(new FieldAndFormat.Builder()).build()); } /** * Whether to expand wildcard expression to concrete indices that are open, * closed or both. * * API name: {@code expand_wildcards} * * Adds all elements of list to expandWildcards. */ public final Builder expandWildcards(List list) { this.expandWildcards = _listAddAll(this.expandWildcards, list); return this; } /** * Whether to expand wildcard expression to concrete indices that are open, * closed or both. * * API name: {@code expand_wildcards} * * Adds one or more values to expandWildcards. */ public final Builder expandWildcards(ExpandWildcard value, ExpandWildcard... values) { this.expandWildcards = _listAdd(this.expandWildcards, value, values); return this; } /** * If true, returns detailed information about score computation as part of a * hit. * * API name: {@code explain} */ public final Builder explain(@Nullable Boolean value) { this.explain = value; return this; } /** * Array of wildcard (*) patterns. The request returns values for field names * matching these patterns in the hits.fields property of the response. * * API name: {@code fields} * * Adds all elements of list to fields. */ public final Builder fields(List list) { this.fields = _listAddAll(this.fields, list); return this; } /** * Array of wildcard (*) patterns. The request returns values for field names * matching these patterns in the hits.fields property of the response. * * API name: {@code fields} * * Adds one or more values to fields. */ public final Builder fields(FieldAndFormat value, FieldAndFormat... values) { this.fields = _listAdd(this.fields, value, values); return this; } /** * Array of wildcard (*) patterns. The request returns values for field names * matching these patterns in the hits.fields property of the response. * * API name: {@code fields} * * Adds a value to fields using a builder lambda. */ public final Builder fields(Function> fn) { return fields(fn.apply(new FieldAndFormat.Builder()).build()); } /** * Starting document offset. By default, you cannot page through more than * 10,000 hits using the from and size parameters. To page through more hits, * use the search_after parameter. * * API name: {@code from} */ public final Builder from(@Nullable Integer value) { this.from = value; return this; } /** * API name: {@code highlight} */ public final Builder highlight(@Nullable Highlight value) { this.highlight = value; return this; } /** * API name: {@code highlight} */ public final Builder highlight(Function> fn) { return this.highlight(fn.apply(new Highlight.Builder()).build()); } /** * Whether specified concrete, expanded or aliased indices should be ignored * when throttled * * API name: {@code ignore_throttled} */ public final Builder ignoreThrottled(@Nullable Boolean value) { this.ignoreThrottled = value; return this; } /** * Whether specified concrete indices should be ignored when unavailable * (missing or closed) * * API name: {@code ignore_unavailable} */ public final Builder ignoreUnavailable(@Nullable Boolean value) { this.ignoreUnavailable = value; return this; } /** * A comma-separated list of index names to search; use _all or * empty string to perform the operation on all indices * * API name: {@code index} * * Adds all elements of list to index. */ public final Builder index(List list) { this.index = _listAddAll(this.index, list); return this; } /** * A comma-separated list of index names to search; use _all or * empty string to perform the operation on all indices * * API name: {@code index} * * Adds one or more values to index. */ public final Builder index(String value, String... values) { this.index = _listAdd(this.index, value, values); return this; } /** * Boosts the _score of documents from specified indices. * * API name: {@code indices_boost} * * Adds all elements of list to indicesBoost. */ public final Builder indicesBoost(List> list) { this.indicesBoost = _listAddAll(this.indicesBoost, list); return this; } /** * Boosts the _score of documents from specified indices. * * API name: {@code indices_boost} * * Adds one or more values to indicesBoost. */ public final Builder indicesBoost(Map value, Map... values) { this.indicesBoost = _listAdd(this.indicesBoost, value, values); return this; } /** * Update the time interval in which the results (partial or final) for this * search will be available * * API name: {@code keep_alive} */ public final Builder keepAlive(@Nullable Time value) { this.keepAlive = value; return this; } /** * Update the time interval in which the results (partial or final) for this * search will be available * * API name: {@code keep_alive} */ public final Builder keepAlive(Function> fn) { return this.keepAlive(fn.apply(new Time.Builder()).build()); } /** * Control whether the response should be stored in the cluster if it completed * within the provided [wait_for_completion] time (default: false) * * API name: {@code keep_on_completion} */ public final Builder keepOnCompletion(@Nullable Boolean value) { this.keepOnCompletion = value; return this; } /** * Specify whether format-based query failures (such as providing text to a * numeric field) should be ignored * * API name: {@code lenient} */ public final Builder lenient(@Nullable Boolean value) { this.lenient = value; return this; } /** * The number of concurrent shard requests per node this search executes * concurrently. This value should be used to limit the impact of the search on * the cluster in order to limit the number of concurrent shard requests * * API name: {@code max_concurrent_shard_requests} */ public final Builder maxConcurrentShardRequests(@Nullable Long value) { this.maxConcurrentShardRequests = value; return this; } /** * API name: {@code min_compatible_shard_node} */ public final Builder minCompatibleShardNode(@Nullable String value) { this.minCompatibleShardNode = value; return this; } /** * Minimum _score for matching documents. Documents with a lower _score are not * included in the search results. * * API name: {@code min_score} */ public final Builder minScore(@Nullable Double value) { this.minScore = value; return this; } /** * Limits the search to a point in time (PIT). If you provide a PIT, you cannot * specify an <index> in the request path. * * API name: {@code pit} */ public final Builder pit(@Nullable PointInTimeReference value) { this.pit = value; return this; } /** * Limits the search to a point in time (PIT). If you provide a PIT, you cannot * specify an <index> in the request path. * * API name: {@code pit} */ public final Builder pit(Function> fn) { return this.pit(fn.apply(new PointInTimeReference.Builder()).build()); } /** * API name: {@code post_filter} */ public final Builder postFilter(@Nullable Query value) { this.postFilter = value; return this; } /** * API name: {@code post_filter} */ public final Builder postFilter(Function> fn) { return this.postFilter(fn.apply(new Query.Builder()).build()); } /** * API name: {@code pre_filter_shard_size} */ public final Builder preFilterShardSize(@Nullable Long value) { this.preFilterShardSize = value; return this; } /** * Specify the node or shard the operation should be performed on (default: * random) * * API name: {@code preference} */ public final Builder preference(@Nullable String value) { this.preference = value; return this; } /** * API name: {@code profile} */ public final Builder profile(@Nullable Boolean value) { this.profile = value; return this; } /** * Query in the Lucene query string syntax * * API name: {@code q} */ public final Builder q(@Nullable String value) { this.q = value; return this; } /** * Defines the search definition using the Query DSL. * * API name: {@code query} */ public final Builder query(@Nullable Query value) { this.query = value; return this; } /** * Defines the search definition using the Query DSL. * * API name: {@code query} */ public final Builder query(Function> fn) { return this.query(fn.apply(new Query.Builder()).build()); } /** * Specify if request cache should be used for this request or not, defaults to * true * * API name: {@code request_cache} */ public final Builder requestCache(@Nullable Boolean value) { this.requestCache = value; return this; } /** * API name: {@code rescore} * * Adds all elements of list to rescore. */ public final Builder rescore(List list) { this.rescore = _listAddAll(this.rescore, list); return this; } /** * API name: {@code rescore} * * Adds one or more values to rescore. */ public final Builder rescore(Rescore value, Rescore... values) { this.rescore = _listAdd(this.rescore, value, values); return this; } /** * API name: {@code rescore} * * Adds a value to rescore using a builder lambda. */ public final Builder rescore(Function> fn) { return rescore(fn.apply(new Rescore.Builder()).build()); } /** * A comma-separated list of specific routing values * * API name: {@code routing} */ public final Builder routing(@Nullable String value) { this.routing = value; return this; } /** * Defines one or more runtime fields in the search request. These fields take * precedence over mapped fields with the same name. * * API name: {@code runtime_mappings} * * Adds all entries of map to runtimeMappings. */ public final Builder runtimeMappings(Map> map) { this.runtimeMappings = _mapPutAll(this.runtimeMappings, map); return this; } /** * Defines one or more runtime fields in the search request. These fields take * precedence over mapped fields with the same name. * * API name: {@code runtime_mappings} * * Adds an entry to runtimeMappings. */ public final Builder runtimeMappings(String key, List value) { this.runtimeMappings = _mapPut(this.runtimeMappings, key, value); return this; } /** * Retrieve a script evaluation (based on different fields) for each hit. * * API name: {@code script_fields} * * Adds all entries of map to scriptFields. */ public final Builder scriptFields(Map map) { this.scriptFields = _mapPutAll(this.scriptFields, map); return this; } /** * Retrieve a script evaluation (based on different fields) for each hit. * * API name: {@code script_fields} * * Adds an entry to scriptFields. */ public final Builder scriptFields(String key, ScriptField value) { this.scriptFields = _mapPut(this.scriptFields, key, value); return this; } /** * Retrieve a script evaluation (based on different fields) for each hit. * * API name: {@code script_fields} * * Adds an entry to scriptFields using a builder lambda. */ public final Builder scriptFields(String key, Function> fn) { return scriptFields(key, fn.apply(new ScriptField.Builder()).build()); } /** * API name: {@code scroll} */ public final Builder scroll(@Nullable Time value) { this.scroll = value; return this; } /** * API name: {@code scroll} */ public final Builder scroll(Function> fn) { return this.scroll(fn.apply(new Time.Builder()).build()); } /** * API name: {@code search_after} * * Adds all elements of list to searchAfter. */ public final Builder searchAfter(List list) { this.searchAfter = _listAddAll(this.searchAfter, list); return this; } /** * API name: {@code search_after} * * Adds one or more values to searchAfter. */ public final Builder searchAfter(String value, String... values) { this.searchAfter = _listAdd(this.searchAfter, value, values); return this; } /** * Search operation type * * API name: {@code search_type} */ public final Builder searchType(@Nullable SearchType value) { this.searchType = value; return this; } /** * If true, returns sequence number and primary term of the last modification of * each hit. See Optimistic concurrency control. * * API name: {@code seq_no_primary_term} */ public final Builder seqNoPrimaryTerm(@Nullable Boolean value) { this.seqNoPrimaryTerm = value; return this; } /** * The number of hits to return. By default, you cannot page through more than * 10,000 hits using the from and size parameters. To page through more hits, * use the search_after parameter. * * API name: {@code size} */ public final Builder size(@Nullable Integer value) { this.size = value; return this; } /** * API name: {@code slice} */ public final Builder slice(@Nullable SlicedScroll value) { this.slice = value; return this; } /** * API name: {@code slice} */ public final Builder slice(Function> fn) { return this.slice(fn.apply(new SlicedScroll.Builder()).build()); } /** * API name: {@code sort} * * Adds all elements of list to sort. */ public final Builder sort(List list) { this.sort = _listAddAll(this.sort, list); return this; } /** * API name: {@code sort} * * Adds one or more values to sort. */ public final Builder sort(SortOptions value, SortOptions... values) { this.sort = _listAdd(this.sort, value, values); return this; } /** * API name: {@code sort} * * Adds a value to sort using a builder lambda. */ public final Builder sort(Function> fn) { return sort(fn.apply(new SortOptions.Builder()).build()); } /** * Stats groups to associate with the search. Each group maintains a statistics * aggregation for its associated searches. You can retrieve these stats using * the indices stats API. * * API name: {@code stats} * * Adds all elements of list to stats. */ public final Builder stats(List list) { this.stats = _listAddAll(this.stats, list); return this; } /** * Stats groups to associate with the search. Each group maintains a statistics * aggregation for its associated searches. You can retrieve these stats using * the indices stats API. * * API name: {@code stats} * * Adds one or more values to stats. */ public final Builder stats(String value, String... values) { this.stats = _listAdd(this.stats, value, values); return this; } /** * List of stored fields to return as part of a hit. If no fields are specified, * no stored fields are included in the response. If this field is specified, * the _source parameter defaults to false. You can pass _source: true to return * both source fields and stored fields in the search response. * * API name: {@code stored_fields} * * Adds all elements of list to storedFields. */ public final Builder storedFields(List list) { this.storedFields = _listAddAll(this.storedFields, list); return this; } /** * List of stored fields to return as part of a hit. If no fields are specified, * no stored fields are included in the response. If this field is specified, * the _source parameter defaults to false. You can pass _source: true to return * both source fields and stored fields in the search response. * * API name: {@code stored_fields} * * Adds one or more values to storedFields. */ public final Builder storedFields(String value, String... values) { this.storedFields = _listAdd(this.storedFields, value, values); return this; } /** * API name: {@code suggest} */ public final Builder suggest(@Nullable Suggester value) { this.suggest = value; return this; } /** * API name: {@code suggest} */ public final Builder suggest(Function> fn) { return this.suggest(fn.apply(new Suggester.Builder()).build()); } /** * Maximum number of documents to collect for each shard. If a query reaches * this limit, Elasticsearch terminates the query early. Elasticsearch collects * documents before sorting. Defaults to 0, which does not terminate query * execution early. * * API name: {@code terminate_after} */ public final Builder terminateAfter(@Nullable Long value) { this.terminateAfter = value; return this; } /** * Specifies the period of time to wait for a response from each shard. If no * response is received before the timeout expires, the request fails and * returns an error. Defaults to no timeout. * * API name: {@code timeout} */ public final Builder timeout(@Nullable String value) { this.timeout = value; return this; } /** * If true, calculate and return document scores, even if the scores are not * used for sorting. * * API name: {@code track_scores} */ public final Builder trackScores(@Nullable Boolean value) { this.trackScores = value; return this; } /** * Number of hits matching the query to count accurately. If true, the exact * number of hits is returned at the cost of some performance. If false, the * response does not include the total number of hits matching the query. * Defaults to 10,000 hits. * * API name: {@code track_total_hits} */ public final Builder trackTotalHits(@Nullable TrackHits value) { this.trackTotalHits = value; return this; } /** * Number of hits matching the query to count accurately. If true, the exact * number of hits is returned at the cost of some performance. If false, the * response does not include the total number of hits matching the query. * Defaults to 10,000 hits. * * API name: {@code track_total_hits} */ public final Builder trackTotalHits(Function> fn) { return this.trackTotalHits(fn.apply(new TrackHits.Builder()).build()); } /** * If true, returns document version as part of a hit. * * API name: {@code version} */ public final Builder version(@Nullable Boolean value) { this.version = value; return this; } /** * Specify the time that the request should block waiting for the final response * * API name: {@code wait_for_completion_timeout} */ public final Builder waitForCompletionTimeout(@Nullable Time value) { this.waitForCompletionTimeout = value; return this; } /** * Specify the time that the request should block waiting for the final response * * API name: {@code wait_for_completion_timeout} */ public final Builder waitForCompletionTimeout(Function> fn) { return this.waitForCompletionTimeout(fn.apply(new Time.Builder()).build()); } @Override protected Builder self() { return this; } /** * Builds a {@link SubmitRequest}. * * @throws NullPointerException * if some of the required fields are null. */ public SubmitRequest build() { _checkSingleUse(); return new SubmitRequest(this); } } // --------------------------------------------------------------------------------------------- /** * Json deserializer for {@link SubmitRequest} */ public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy(Builder::new, SubmitRequest::setupSubmitRequestDeserializer); protected static void setupSubmitRequestDeserializer(ObjectDeserializer op) { op.add(Builder::source, SourceConfig._DESERIALIZER, "_source"); op.add(Builder::aggregations, JsonpDeserializer.stringMapDeserializer(Aggregation._DESERIALIZER), "aggregations", "aggs"); op.add(Builder::collapse, FieldCollapse._DESERIALIZER, "collapse"); op.add(Builder::docvalueFields, JsonpDeserializer.arrayDeserializer(FieldAndFormat._DESERIALIZER), "docvalue_fields"); op.add(Builder::explain, JsonpDeserializer.booleanDeserializer(), "explain"); op.add(Builder::fields, JsonpDeserializer.arrayDeserializer(FieldAndFormat._DESERIALIZER), "fields"); op.add(Builder::from, JsonpDeserializer.integerDeserializer(), "from"); op.add(Builder::highlight, Highlight._DESERIALIZER, "highlight"); op.add(Builder::indicesBoost, JsonpDeserializer.arrayDeserializer( JsonpDeserializer.stringMapDeserializer(JsonpDeserializer.doubleDeserializer())), "indices_boost"); op.add(Builder::minScore, JsonpDeserializer.doubleDeserializer(), "min_score"); op.add(Builder::pit, PointInTimeReference._DESERIALIZER, "pit"); op.add(Builder::postFilter, Query._DESERIALIZER, "post_filter"); op.add(Builder::profile, JsonpDeserializer.booleanDeserializer(), "profile"); op.add(Builder::query, Query._DESERIALIZER, "query"); op.add(Builder::rescore, JsonpDeserializer.arrayDeserializer(Rescore._DESERIALIZER), "rescore"); op.add(Builder::runtimeMappings, JsonpDeserializer.stringMapDeserializer( JsonpDeserializer.arrayDeserializer(RuntimeField._DESERIALIZER)), "runtime_mappings"); op.add(Builder::scriptFields, JsonpDeserializer.stringMapDeserializer(ScriptField._DESERIALIZER), "script_fields"); op.add(Builder::searchAfter, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "search_after"); op.add(Builder::seqNoPrimaryTerm, JsonpDeserializer.booleanDeserializer(), "seq_no_primary_term"); op.add(Builder::size, JsonpDeserializer.integerDeserializer(), "size"); op.add(Builder::slice, SlicedScroll._DESERIALIZER, "slice"); op.add(Builder::sort, JsonpDeserializer.arrayDeserializer(SortOptions._DESERIALIZER), "sort"); op.add(Builder::stats, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "stats"); op.add(Builder::storedFields, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "stored_fields"); op.add(Builder::suggest, Suggester._DESERIALIZER, "suggest"); op.add(Builder::terminateAfter, JsonpDeserializer.longDeserializer(), "terminate_after"); op.add(Builder::timeout, JsonpDeserializer.stringDeserializer(), "timeout"); op.add(Builder::trackScores, JsonpDeserializer.booleanDeserializer(), "track_scores"); op.add(Builder::trackTotalHits, TrackHits._DESERIALIZER, "track_total_hits"); op.add(Builder::version, JsonpDeserializer.booleanDeserializer(), "version"); } // --------------------------------------------------------------------------------------------- /** * Endpoint "{@code async_search.submit}". */ public static final SimpleEndpoint _ENDPOINT = new SimpleEndpoint<>("es/async_search.submit", // Request method request -> { return "POST"; }, // Request path request -> { final int _index = 1 << 0; int propsSet = 0; if (ApiTypeHelper.isDefined(request.index())) propsSet |= _index; if (propsSet == 0) { StringBuilder buf = new StringBuilder(); buf.append("/_async_search"); return buf.toString(); } if (propsSet == (_index)) { StringBuilder buf = new StringBuilder(); buf.append("/"); SimpleEndpoint.pathEncode(request.index.stream().map(v -> v).collect(Collectors.joining(",")), buf); buf.append("/_async_search"); return buf.toString(); } throw SimpleEndpoint.noPathTemplateFound("path"); }, // Request parameters request -> { Map params = new HashMap<>(); params.put("typed_keys", "true"); if (request.df != null) { params.put("df", request.df); } if (request.preFilterShardSize != null) { params.put("pre_filter_shard_size", String.valueOf(request.preFilterShardSize)); } if (request.minCompatibleShardNode != null) { params.put("min_compatible_shard_node", request.minCompatibleShardNode); } if (request.lenient != null) { params.put("lenient", String.valueOf(request.lenient)); } if (request.routing != null) { params.put("routing", request.routing); } if (request.ignoreUnavailable != null) { params.put("ignore_unavailable", String.valueOf(request.ignoreUnavailable)); } if (request.allowNoIndices != null) { params.put("allow_no_indices", String.valueOf(request.allowNoIndices)); } if (request.analyzer != null) { params.put("analyzer", request.analyzer); } if (request.ignoreThrottled != null) { params.put("ignore_throttled", String.valueOf(request.ignoreThrottled)); } if (request.keepOnCompletion != null) { params.put("keep_on_completion", String.valueOf(request.keepOnCompletion)); } if (request.maxConcurrentShardRequests != null) { params.put("max_concurrent_shard_requests", String.valueOf(request.maxConcurrentShardRequests)); } if (request.allowPartialSearchResults != null) { params.put("allow_partial_search_results", String.valueOf(request.allowPartialSearchResults)); } if (ApiTypeHelper.isDefined(request.expandWildcards)) { params.put("expand_wildcards", request.expandWildcards.stream().map(v -> v.jsonValue()).collect(Collectors.joining(","))); } if (request.preference != null) { params.put("preference", request.preference); } if (request.analyzeWildcard != null) { params.put("analyze_wildcard", String.valueOf(request.analyzeWildcard)); } if (request.scroll != null) { params.put("scroll", request.scroll._toJsonString()); } if (request.waitForCompletionTimeout != null) { params.put("wait_for_completion_timeout", request.waitForCompletionTimeout._toJsonString()); } if (request.searchType != null) { params.put("search_type", request.searchType.jsonValue()); } if (request.ccsMinimizeRoundtrips != null) { params.put("ccs_minimize_roundtrips", String.valueOf(request.ccsMinimizeRoundtrips)); } if (request.q != null) { params.put("q", request.q); } if (request.defaultOperator != null) { params.put("default_operator", request.defaultOperator.jsonValue()); } if (request.keepAlive != null) { params.put("keep_alive", request.keepAlive._toJsonString()); } if (request.requestCache != null) { params.put("request_cache", String.valueOf(request.requestCache)); } if (request.batchedReduceSize != null) { params.put("batched_reduce_size", String.valueOf(request.batchedReduceSize)); } return params; }, SimpleEndpoint.emptyMap(), true, SubmitResponse._DESERIALIZER); /** * Create an "{@code async_search.submit}" endpoint. */ public static Endpoint, ErrorResponse> createSubmitEndpoint( JsonpDeserializer tDocumentDeserializer) { return _ENDPOINT .withResponseDeserializer(SubmitResponse.createSubmitResponseDeserializer(tDocumentDeserializer)); } }
* API name: {@code default_operator} */ public final Builder defaultOperator(@Nullable Operator value) { this.defaultOperator = value; return this; } /** * The field to use as default where no field prefix is given in the query * string *
* API name: {@code df} */ public final Builder df(@Nullable String value) { this.df = value; return this; } /** * Array of wildcard (*) patterns. The request returns doc values for field * names matching these patterns in the hits.fields property of the response. *
* API name: {@code docvalue_fields} *
* Adds all elements of list to docvalueFields. */ public final Builder docvalueFields(List list) { this.docvalueFields = _listAddAll(this.docvalueFields, list); return this; } /** * Array of wildcard (*) patterns. The request returns doc values for field * names matching these patterns in the hits.fields property of the response. * * API name: {@code docvalue_fields} * * Adds one or more values to docvalueFields. */ public final Builder docvalueFields(FieldAndFormat value, FieldAndFormat... values) { this.docvalueFields = _listAdd(this.docvalueFields, value, values); return this; } /** * Array of wildcard (*) patterns. The request returns doc values for field * names matching these patterns in the hits.fields property of the response. * * API name: {@code docvalue_fields} * * Adds a value to docvalueFields using a builder lambda. */ public final Builder docvalueFields(Function> fn) { return docvalueFields(fn.apply(new FieldAndFormat.Builder()).build()); } /** * Whether to expand wildcard expression to concrete indices that are open, * closed or both. * * API name: {@code expand_wildcards} * * Adds all elements of list to expandWildcards. */ public final Builder expandWildcards(List list) { this.expandWildcards = _listAddAll(this.expandWildcards, list); return this; } /** * Whether to expand wildcard expression to concrete indices that are open, * closed or both. * * API name: {@code expand_wildcards} * * Adds one or more values to expandWildcards. */ public final Builder expandWildcards(ExpandWildcard value, ExpandWildcard... values) { this.expandWildcards = _listAdd(this.expandWildcards, value, values); return this; } /** * If true, returns detailed information about score computation as part of a * hit. * * API name: {@code explain} */ public final Builder explain(@Nullable Boolean value) { this.explain = value; return this; } /** * Array of wildcard (*) patterns. The request returns values for field names * matching these patterns in the hits.fields property of the response. * * API name: {@code fields} * * Adds all elements of list to fields. */ public final Builder fields(List list) { this.fields = _listAddAll(this.fields, list); return this; } /** * Array of wildcard (*) patterns. The request returns values for field names * matching these patterns in the hits.fields property of the response. * * API name: {@code fields} * * Adds one or more values to fields. */ public final Builder fields(FieldAndFormat value, FieldAndFormat... values) { this.fields = _listAdd(this.fields, value, values); return this; } /** * Array of wildcard (*) patterns. The request returns values for field names * matching these patterns in the hits.fields property of the response. * * API name: {@code fields} * * Adds a value to fields using a builder lambda. */ public final Builder fields(Function> fn) { return fields(fn.apply(new FieldAndFormat.Builder()).build()); } /** * Starting document offset. By default, you cannot page through more than * 10,000 hits using the from and size parameters. To page through more hits, * use the search_after parameter. * * API name: {@code from} */ public final Builder from(@Nullable Integer value) { this.from = value; return this; } /** * API name: {@code highlight} */ public final Builder highlight(@Nullable Highlight value) { this.highlight = value; return this; } /** * API name: {@code highlight} */ public final Builder highlight(Function> fn) { return this.highlight(fn.apply(new Highlight.Builder()).build()); } /** * Whether specified concrete, expanded or aliased indices should be ignored * when throttled * * API name: {@code ignore_throttled} */ public final Builder ignoreThrottled(@Nullable Boolean value) { this.ignoreThrottled = value; return this; } /** * Whether specified concrete indices should be ignored when unavailable * (missing or closed) * * API name: {@code ignore_unavailable} */ public final Builder ignoreUnavailable(@Nullable Boolean value) { this.ignoreUnavailable = value; return this; } /** * A comma-separated list of index names to search; use _all or * empty string to perform the operation on all indices * * API name: {@code index} * * Adds all elements of list to index. */ public final Builder index(List list) { this.index = _listAddAll(this.index, list); return this; } /** * A comma-separated list of index names to search; use _all or * empty string to perform the operation on all indices * * API name: {@code index} * * Adds one or more values to index. */ public final Builder index(String value, String... values) { this.index = _listAdd(this.index, value, values); return this; } /** * Boosts the _score of documents from specified indices. * * API name: {@code indices_boost} * * Adds all elements of list to indicesBoost. */ public final Builder indicesBoost(List> list) { this.indicesBoost = _listAddAll(this.indicesBoost, list); return this; } /** * Boosts the _score of documents from specified indices. * * API name: {@code indices_boost} * * Adds one or more values to indicesBoost. */ public final Builder indicesBoost(Map value, Map... values) { this.indicesBoost = _listAdd(this.indicesBoost, value, values); return this; } /** * Update the time interval in which the results (partial or final) for this * search will be available * * API name: {@code keep_alive} */ public final Builder keepAlive(@Nullable Time value) { this.keepAlive = value; return this; } /** * Update the time interval in which the results (partial or final) for this * search will be available * * API name: {@code keep_alive} */ public final Builder keepAlive(Function> fn) { return this.keepAlive(fn.apply(new Time.Builder()).build()); } /** * Control whether the response should be stored in the cluster if it completed * within the provided [wait_for_completion] time (default: false) * * API name: {@code keep_on_completion} */ public final Builder keepOnCompletion(@Nullable Boolean value) { this.keepOnCompletion = value; return this; } /** * Specify whether format-based query failures (such as providing text to a * numeric field) should be ignored * * API name: {@code lenient} */ public final Builder lenient(@Nullable Boolean value) { this.lenient = value; return this; } /** * The number of concurrent shard requests per node this search executes * concurrently. This value should be used to limit the impact of the search on * the cluster in order to limit the number of concurrent shard requests * * API name: {@code max_concurrent_shard_requests} */ public final Builder maxConcurrentShardRequests(@Nullable Long value) { this.maxConcurrentShardRequests = value; return this; } /** * API name: {@code min_compatible_shard_node} */ public final Builder minCompatibleShardNode(@Nullable String value) { this.minCompatibleShardNode = value; return this; } /** * Minimum _score for matching documents. Documents with a lower _score are not * included in the search results. * * API name: {@code min_score} */ public final Builder minScore(@Nullable Double value) { this.minScore = value; return this; } /** * Limits the search to a point in time (PIT). If you provide a PIT, you cannot * specify an <index> in the request path. * * API name: {@code pit} */ public final Builder pit(@Nullable PointInTimeReference value) { this.pit = value; return this; } /** * Limits the search to a point in time (PIT). If you provide a PIT, you cannot * specify an <index> in the request path. * * API name: {@code pit} */ public final Builder pit(Function> fn) { return this.pit(fn.apply(new PointInTimeReference.Builder()).build()); } /** * API name: {@code post_filter} */ public final Builder postFilter(@Nullable Query value) { this.postFilter = value; return this; } /** * API name: {@code post_filter} */ public final Builder postFilter(Function> fn) { return this.postFilter(fn.apply(new Query.Builder()).build()); } /** * API name: {@code pre_filter_shard_size} */ public final Builder preFilterShardSize(@Nullable Long value) { this.preFilterShardSize = value; return this; } /** * Specify the node or shard the operation should be performed on (default: * random) * * API name: {@code preference} */ public final Builder preference(@Nullable String value) { this.preference = value; return this; } /** * API name: {@code profile} */ public final Builder profile(@Nullable Boolean value) { this.profile = value; return this; } /** * Query in the Lucene query string syntax * * API name: {@code q} */ public final Builder q(@Nullable String value) { this.q = value; return this; } /** * Defines the search definition using the Query DSL. * * API name: {@code query} */ public final Builder query(@Nullable Query value) { this.query = value; return this; } /** * Defines the search definition using the Query DSL. * * API name: {@code query} */ public final Builder query(Function> fn) { return this.query(fn.apply(new Query.Builder()).build()); } /** * Specify if request cache should be used for this request or not, defaults to * true * * API name: {@code request_cache} */ public final Builder requestCache(@Nullable Boolean value) { this.requestCache = value; return this; } /** * API name: {@code rescore} * * Adds all elements of list to rescore. */ public final Builder rescore(List list) { this.rescore = _listAddAll(this.rescore, list); return this; } /** * API name: {@code rescore} * * Adds one or more values to rescore. */ public final Builder rescore(Rescore value, Rescore... values) { this.rescore = _listAdd(this.rescore, value, values); return this; } /** * API name: {@code rescore} * * Adds a value to rescore using a builder lambda. */ public final Builder rescore(Function> fn) { return rescore(fn.apply(new Rescore.Builder()).build()); } /** * A comma-separated list of specific routing values * * API name: {@code routing} */ public final Builder routing(@Nullable String value) { this.routing = value; return this; } /** * Defines one or more runtime fields in the search request. These fields take * precedence over mapped fields with the same name. * * API name: {@code runtime_mappings} * * Adds all entries of map to runtimeMappings. */ public final Builder runtimeMappings(Map> map) { this.runtimeMappings = _mapPutAll(this.runtimeMappings, map); return this; } /** * Defines one or more runtime fields in the search request. These fields take * precedence over mapped fields with the same name. * * API name: {@code runtime_mappings} * * Adds an entry to runtimeMappings. */ public final Builder runtimeMappings(String key, List value) { this.runtimeMappings = _mapPut(this.runtimeMappings, key, value); return this; } /** * Retrieve a script evaluation (based on different fields) for each hit. * * API name: {@code script_fields} * * Adds all entries of map to scriptFields. */ public final Builder scriptFields(Map map) { this.scriptFields = _mapPutAll(this.scriptFields, map); return this; } /** * Retrieve a script evaluation (based on different fields) for each hit. * * API name: {@code script_fields} * * Adds an entry to scriptFields. */ public final Builder scriptFields(String key, ScriptField value) { this.scriptFields = _mapPut(this.scriptFields, key, value); return this; } /** * Retrieve a script evaluation (based on different fields) for each hit. * * API name: {@code script_fields} * * Adds an entry to scriptFields using a builder lambda. */ public final Builder scriptFields(String key, Function> fn) { return scriptFields(key, fn.apply(new ScriptField.Builder()).build()); } /** * API name: {@code scroll} */ public final Builder scroll(@Nullable Time value) { this.scroll = value; return this; } /** * API name: {@code scroll} */ public final Builder scroll(Function> fn) { return this.scroll(fn.apply(new Time.Builder()).build()); } /** * API name: {@code search_after} * * Adds all elements of list to searchAfter. */ public final Builder searchAfter(List list) { this.searchAfter = _listAddAll(this.searchAfter, list); return this; } /** * API name: {@code search_after} * * Adds one or more values to searchAfter. */ public final Builder searchAfter(String value, String... values) { this.searchAfter = _listAdd(this.searchAfter, value, values); return this; } /** * Search operation type * * API name: {@code search_type} */ public final Builder searchType(@Nullable SearchType value) { this.searchType = value; return this; } /** * If true, returns sequence number and primary term of the last modification of * each hit. See Optimistic concurrency control. * * API name: {@code seq_no_primary_term} */ public final Builder seqNoPrimaryTerm(@Nullable Boolean value) { this.seqNoPrimaryTerm = value; return this; } /** * The number of hits to return. By default, you cannot page through more than * 10,000 hits using the from and size parameters. To page through more hits, * use the search_after parameter. * * API name: {@code size} */ public final Builder size(@Nullable Integer value) { this.size = value; return this; } /** * API name: {@code slice} */ public final Builder slice(@Nullable SlicedScroll value) { this.slice = value; return this; } /** * API name: {@code slice} */ public final Builder slice(Function> fn) { return this.slice(fn.apply(new SlicedScroll.Builder()).build()); } /** * API name: {@code sort} * * Adds all elements of list to sort. */ public final Builder sort(List list) { this.sort = _listAddAll(this.sort, list); return this; } /** * API name: {@code sort} * * Adds one or more values to sort. */ public final Builder sort(SortOptions value, SortOptions... values) { this.sort = _listAdd(this.sort, value, values); return this; } /** * API name: {@code sort} * * Adds a value to sort using a builder lambda. */ public final Builder sort(Function> fn) { return sort(fn.apply(new SortOptions.Builder()).build()); } /** * Stats groups to associate with the search. Each group maintains a statistics * aggregation for its associated searches. You can retrieve these stats using * the indices stats API. * * API name: {@code stats} * * Adds all elements of list to stats. */ public final Builder stats(List list) { this.stats = _listAddAll(this.stats, list); return this; } /** * Stats groups to associate with the search. Each group maintains a statistics * aggregation for its associated searches. You can retrieve these stats using * the indices stats API. * * API name: {@code stats} * * Adds one or more values to stats. */ public final Builder stats(String value, String... values) { this.stats = _listAdd(this.stats, value, values); return this; } /** * List of stored fields to return as part of a hit. If no fields are specified, * no stored fields are included in the response. If this field is specified, * the _source parameter defaults to false. You can pass _source: true to return * both source fields and stored fields in the search response. * * API name: {@code stored_fields} * * Adds all elements of list to storedFields. */ public final Builder storedFields(List list) { this.storedFields = _listAddAll(this.storedFields, list); return this; } /** * List of stored fields to return as part of a hit. If no fields are specified, * no stored fields are included in the response. If this field is specified, * the _source parameter defaults to false. You can pass _source: true to return * both source fields and stored fields in the search response. * * API name: {@code stored_fields} * * Adds one or more values to storedFields. */ public final Builder storedFields(String value, String... values) { this.storedFields = _listAdd(this.storedFields, value, values); return this; } /** * API name: {@code suggest} */ public final Builder suggest(@Nullable Suggester value) { this.suggest = value; return this; } /** * API name: {@code suggest} */ public final Builder suggest(Function> fn) { return this.suggest(fn.apply(new Suggester.Builder()).build()); } /** * Maximum number of documents to collect for each shard. If a query reaches * this limit, Elasticsearch terminates the query early. Elasticsearch collects * documents before sorting. Defaults to 0, which does not terminate query * execution early. * * API name: {@code terminate_after} */ public final Builder terminateAfter(@Nullable Long value) { this.terminateAfter = value; return this; } /** * Specifies the period of time to wait for a response from each shard. If no * response is received before the timeout expires, the request fails and * returns an error. Defaults to no timeout. * * API name: {@code timeout} */ public final Builder timeout(@Nullable String value) { this.timeout = value; return this; } /** * If true, calculate and return document scores, even if the scores are not * used for sorting. * * API name: {@code track_scores} */ public final Builder trackScores(@Nullable Boolean value) { this.trackScores = value; return this; } /** * Number of hits matching the query to count accurately. If true, the exact * number of hits is returned at the cost of some performance. If false, the * response does not include the total number of hits matching the query. * Defaults to 10,000 hits. * * API name: {@code track_total_hits} */ public final Builder trackTotalHits(@Nullable TrackHits value) { this.trackTotalHits = value; return this; } /** * Number of hits matching the query to count accurately. If true, the exact * number of hits is returned at the cost of some performance. If false, the * response does not include the total number of hits matching the query. * Defaults to 10,000 hits. * * API name: {@code track_total_hits} */ public final Builder trackTotalHits(Function> fn) { return this.trackTotalHits(fn.apply(new TrackHits.Builder()).build()); } /** * If true, returns document version as part of a hit. * * API name: {@code version} */ public final Builder version(@Nullable Boolean value) { this.version = value; return this; } /** * Specify the time that the request should block waiting for the final response * * API name: {@code wait_for_completion_timeout} */ public final Builder waitForCompletionTimeout(@Nullable Time value) { this.waitForCompletionTimeout = value; return this; } /** * Specify the time that the request should block waiting for the final response * * API name: {@code wait_for_completion_timeout} */ public final Builder waitForCompletionTimeout(Function> fn) { return this.waitForCompletionTimeout(fn.apply(new Time.Builder()).build()); } @Override protected Builder self() { return this; } /** * Builds a {@link SubmitRequest}. * * @throws NullPointerException * if some of the required fields are null. */ public SubmitRequest build() { _checkSingleUse(); return new SubmitRequest(this); } } // --------------------------------------------------------------------------------------------- /** * Json deserializer for {@link SubmitRequest} */ public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy(Builder::new, SubmitRequest::setupSubmitRequestDeserializer); protected static void setupSubmitRequestDeserializer(ObjectDeserializer op) { op.add(Builder::source, SourceConfig._DESERIALIZER, "_source"); op.add(Builder::aggregations, JsonpDeserializer.stringMapDeserializer(Aggregation._DESERIALIZER), "aggregations", "aggs"); op.add(Builder::collapse, FieldCollapse._DESERIALIZER, "collapse"); op.add(Builder::docvalueFields, JsonpDeserializer.arrayDeserializer(FieldAndFormat._DESERIALIZER), "docvalue_fields"); op.add(Builder::explain, JsonpDeserializer.booleanDeserializer(), "explain"); op.add(Builder::fields, JsonpDeserializer.arrayDeserializer(FieldAndFormat._DESERIALIZER), "fields"); op.add(Builder::from, JsonpDeserializer.integerDeserializer(), "from"); op.add(Builder::highlight, Highlight._DESERIALIZER, "highlight"); op.add(Builder::indicesBoost, JsonpDeserializer.arrayDeserializer( JsonpDeserializer.stringMapDeserializer(JsonpDeserializer.doubleDeserializer())), "indices_boost"); op.add(Builder::minScore, JsonpDeserializer.doubleDeserializer(), "min_score"); op.add(Builder::pit, PointInTimeReference._DESERIALIZER, "pit"); op.add(Builder::postFilter, Query._DESERIALIZER, "post_filter"); op.add(Builder::profile, JsonpDeserializer.booleanDeserializer(), "profile"); op.add(Builder::query, Query._DESERIALIZER, "query"); op.add(Builder::rescore, JsonpDeserializer.arrayDeserializer(Rescore._DESERIALIZER), "rescore"); op.add(Builder::runtimeMappings, JsonpDeserializer.stringMapDeserializer( JsonpDeserializer.arrayDeserializer(RuntimeField._DESERIALIZER)), "runtime_mappings"); op.add(Builder::scriptFields, JsonpDeserializer.stringMapDeserializer(ScriptField._DESERIALIZER), "script_fields"); op.add(Builder::searchAfter, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "search_after"); op.add(Builder::seqNoPrimaryTerm, JsonpDeserializer.booleanDeserializer(), "seq_no_primary_term"); op.add(Builder::size, JsonpDeserializer.integerDeserializer(), "size"); op.add(Builder::slice, SlicedScroll._DESERIALIZER, "slice"); op.add(Builder::sort, JsonpDeserializer.arrayDeserializer(SortOptions._DESERIALIZER), "sort"); op.add(Builder::stats, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "stats"); op.add(Builder::storedFields, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "stored_fields"); op.add(Builder::suggest, Suggester._DESERIALIZER, "suggest"); op.add(Builder::terminateAfter, JsonpDeserializer.longDeserializer(), "terminate_after"); op.add(Builder::timeout, JsonpDeserializer.stringDeserializer(), "timeout"); op.add(Builder::trackScores, JsonpDeserializer.booleanDeserializer(), "track_scores"); op.add(Builder::trackTotalHits, TrackHits._DESERIALIZER, "track_total_hits"); op.add(Builder::version, JsonpDeserializer.booleanDeserializer(), "version"); } // --------------------------------------------------------------------------------------------- /** * Endpoint "{@code async_search.submit}". */ public static final SimpleEndpoint _ENDPOINT = new SimpleEndpoint<>("es/async_search.submit", // Request method request -> { return "POST"; }, // Request path request -> { final int _index = 1 << 0; int propsSet = 0; if (ApiTypeHelper.isDefined(request.index())) propsSet |= _index; if (propsSet == 0) { StringBuilder buf = new StringBuilder(); buf.append("/_async_search"); return buf.toString(); } if (propsSet == (_index)) { StringBuilder buf = new StringBuilder(); buf.append("/"); SimpleEndpoint.pathEncode(request.index.stream().map(v -> v).collect(Collectors.joining(",")), buf); buf.append("/_async_search"); return buf.toString(); } throw SimpleEndpoint.noPathTemplateFound("path"); }, // Request parameters request -> { Map params = new HashMap<>(); params.put("typed_keys", "true"); if (request.df != null) { params.put("df", request.df); } if (request.preFilterShardSize != null) { params.put("pre_filter_shard_size", String.valueOf(request.preFilterShardSize)); } if (request.minCompatibleShardNode != null) { params.put("min_compatible_shard_node", request.minCompatibleShardNode); } if (request.lenient != null) { params.put("lenient", String.valueOf(request.lenient)); } if (request.routing != null) { params.put("routing", request.routing); } if (request.ignoreUnavailable != null) { params.put("ignore_unavailable", String.valueOf(request.ignoreUnavailable)); } if (request.allowNoIndices != null) { params.put("allow_no_indices", String.valueOf(request.allowNoIndices)); } if (request.analyzer != null) { params.put("analyzer", request.analyzer); } if (request.ignoreThrottled != null) { params.put("ignore_throttled", String.valueOf(request.ignoreThrottled)); } if (request.keepOnCompletion != null) { params.put("keep_on_completion", String.valueOf(request.keepOnCompletion)); } if (request.maxConcurrentShardRequests != null) { params.put("max_concurrent_shard_requests", String.valueOf(request.maxConcurrentShardRequests)); } if (request.allowPartialSearchResults != null) { params.put("allow_partial_search_results", String.valueOf(request.allowPartialSearchResults)); } if (ApiTypeHelper.isDefined(request.expandWildcards)) { params.put("expand_wildcards", request.expandWildcards.stream().map(v -> v.jsonValue()).collect(Collectors.joining(","))); } if (request.preference != null) { params.put("preference", request.preference); } if (request.analyzeWildcard != null) { params.put("analyze_wildcard", String.valueOf(request.analyzeWildcard)); } if (request.scroll != null) { params.put("scroll", request.scroll._toJsonString()); } if (request.waitForCompletionTimeout != null) { params.put("wait_for_completion_timeout", request.waitForCompletionTimeout._toJsonString()); } if (request.searchType != null) { params.put("search_type", request.searchType.jsonValue()); } if (request.ccsMinimizeRoundtrips != null) { params.put("ccs_minimize_roundtrips", String.valueOf(request.ccsMinimizeRoundtrips)); } if (request.q != null) { params.put("q", request.q); } if (request.defaultOperator != null) { params.put("default_operator", request.defaultOperator.jsonValue()); } if (request.keepAlive != null) { params.put("keep_alive", request.keepAlive._toJsonString()); } if (request.requestCache != null) { params.put("request_cache", String.valueOf(request.requestCache)); } if (request.batchedReduceSize != null) { params.put("batched_reduce_size", String.valueOf(request.batchedReduceSize)); } return params; }, SimpleEndpoint.emptyMap(), true, SubmitResponse._DESERIALIZER); /** * Create an "{@code async_search.submit}" endpoint. */ public static Endpoint, ErrorResponse> createSubmitEndpoint( JsonpDeserializer tDocumentDeserializer) { return _ENDPOINT .withResponseDeserializer(SubmitResponse.createSubmitResponseDeserializer(tDocumentDeserializer)); } }
list
docvalueFields
* Adds one or more values to docvalueFields. */ public final Builder docvalueFields(FieldAndFormat value, FieldAndFormat... values) { this.docvalueFields = _listAdd(this.docvalueFields, value, values); return this; } /** * Array of wildcard (*) patterns. The request returns doc values for field * names matching these patterns in the hits.fields property of the response. *
* Adds a value to docvalueFields using a builder lambda. */ public final Builder docvalueFields(Function> fn) { return docvalueFields(fn.apply(new FieldAndFormat.Builder()).build()); } /** * Whether to expand wildcard expression to concrete indices that are open, * closed or both. * * API name: {@code expand_wildcards} * * Adds all elements of list to expandWildcards. */ public final Builder expandWildcards(List list) { this.expandWildcards = _listAddAll(this.expandWildcards, list); return this; } /** * Whether to expand wildcard expression to concrete indices that are open, * closed or both. * * API name: {@code expand_wildcards} * * Adds one or more values to expandWildcards. */ public final Builder expandWildcards(ExpandWildcard value, ExpandWildcard... values) { this.expandWildcards = _listAdd(this.expandWildcards, value, values); return this; } /** * If true, returns detailed information about score computation as part of a * hit. * * API name: {@code explain} */ public final Builder explain(@Nullable Boolean value) { this.explain = value; return this; } /** * Array of wildcard (*) patterns. The request returns values for field names * matching these patterns in the hits.fields property of the response. * * API name: {@code fields} * * Adds all elements of list to fields. */ public final Builder fields(List list) { this.fields = _listAddAll(this.fields, list); return this; } /** * Array of wildcard (*) patterns. The request returns values for field names * matching these patterns in the hits.fields property of the response. * * API name: {@code fields} * * Adds one or more values to fields. */ public final Builder fields(FieldAndFormat value, FieldAndFormat... values) { this.fields = _listAdd(this.fields, value, values); return this; } /** * Array of wildcard (*) patterns. The request returns values for field names * matching these patterns in the hits.fields property of the response. * * API name: {@code fields} * * Adds a value to fields using a builder lambda. */ public final Builder fields(Function> fn) { return fields(fn.apply(new FieldAndFormat.Builder()).build()); } /** * Starting document offset. By default, you cannot page through more than * 10,000 hits using the from and size parameters. To page through more hits, * use the search_after parameter. * * API name: {@code from} */ public final Builder from(@Nullable Integer value) { this.from = value; return this; } /** * API name: {@code highlight} */ public final Builder highlight(@Nullable Highlight value) { this.highlight = value; return this; } /** * API name: {@code highlight} */ public final Builder highlight(Function> fn) { return this.highlight(fn.apply(new Highlight.Builder()).build()); } /** * Whether specified concrete, expanded or aliased indices should be ignored * when throttled * * API name: {@code ignore_throttled} */ public final Builder ignoreThrottled(@Nullable Boolean value) { this.ignoreThrottled = value; return this; } /** * Whether specified concrete indices should be ignored when unavailable * (missing or closed) * * API name: {@code ignore_unavailable} */ public final Builder ignoreUnavailable(@Nullable Boolean value) { this.ignoreUnavailable = value; return this; } /** * A comma-separated list of index names to search; use _all or * empty string to perform the operation on all indices * * API name: {@code index} * * Adds all elements of list to index. */ public final Builder index(List list) { this.index = _listAddAll(this.index, list); return this; } /** * A comma-separated list of index names to search; use _all or * empty string to perform the operation on all indices * * API name: {@code index} * * Adds one or more values to index. */ public final Builder index(String value, String... values) { this.index = _listAdd(this.index, value, values); return this; } /** * Boosts the _score of documents from specified indices. * * API name: {@code indices_boost} * * Adds all elements of list to indicesBoost. */ public final Builder indicesBoost(List> list) { this.indicesBoost = _listAddAll(this.indicesBoost, list); return this; } /** * Boosts the _score of documents from specified indices. * * API name: {@code indices_boost} * * Adds one or more values to indicesBoost. */ public final Builder indicesBoost(Map value, Map... values) { this.indicesBoost = _listAdd(this.indicesBoost, value, values); return this; } /** * Update the time interval in which the results (partial or final) for this * search will be available * * API name: {@code keep_alive} */ public final Builder keepAlive(@Nullable Time value) { this.keepAlive = value; return this; } /** * Update the time interval in which the results (partial or final) for this * search will be available * * API name: {@code keep_alive} */ public final Builder keepAlive(Function> fn) { return this.keepAlive(fn.apply(new Time.Builder()).build()); } /** * Control whether the response should be stored in the cluster if it completed * within the provided [wait_for_completion] time (default: false) * * API name: {@code keep_on_completion} */ public final Builder keepOnCompletion(@Nullable Boolean value) { this.keepOnCompletion = value; return this; } /** * Specify whether format-based query failures (such as providing text to a * numeric field) should be ignored * * API name: {@code lenient} */ public final Builder lenient(@Nullable Boolean value) { this.lenient = value; return this; } /** * The number of concurrent shard requests per node this search executes * concurrently. This value should be used to limit the impact of the search on * the cluster in order to limit the number of concurrent shard requests * * API name: {@code max_concurrent_shard_requests} */ public final Builder maxConcurrentShardRequests(@Nullable Long value) { this.maxConcurrentShardRequests = value; return this; } /** * API name: {@code min_compatible_shard_node} */ public final Builder minCompatibleShardNode(@Nullable String value) { this.minCompatibleShardNode = value; return this; } /** * Minimum _score for matching documents. Documents with a lower _score are not * included in the search results. * * API name: {@code min_score} */ public final Builder minScore(@Nullable Double value) { this.minScore = value; return this; } /** * Limits the search to a point in time (PIT). If you provide a PIT, you cannot * specify an <index> in the request path. * * API name: {@code pit} */ public final Builder pit(@Nullable PointInTimeReference value) { this.pit = value; return this; } /** * Limits the search to a point in time (PIT). If you provide a PIT, you cannot * specify an <index> in the request path. * * API name: {@code pit} */ public final Builder pit(Function> fn) { return this.pit(fn.apply(new PointInTimeReference.Builder()).build()); } /** * API name: {@code post_filter} */ public final Builder postFilter(@Nullable Query value) { this.postFilter = value; return this; } /** * API name: {@code post_filter} */ public final Builder postFilter(Function> fn) { return this.postFilter(fn.apply(new Query.Builder()).build()); } /** * API name: {@code pre_filter_shard_size} */ public final Builder preFilterShardSize(@Nullable Long value) { this.preFilterShardSize = value; return this; } /** * Specify the node or shard the operation should be performed on (default: * random) * * API name: {@code preference} */ public final Builder preference(@Nullable String value) { this.preference = value; return this; } /** * API name: {@code profile} */ public final Builder profile(@Nullable Boolean value) { this.profile = value; return this; } /** * Query in the Lucene query string syntax * * API name: {@code q} */ public final Builder q(@Nullable String value) { this.q = value; return this; } /** * Defines the search definition using the Query DSL. * * API name: {@code query} */ public final Builder query(@Nullable Query value) { this.query = value; return this; } /** * Defines the search definition using the Query DSL. * * API name: {@code query} */ public final Builder query(Function> fn) { return this.query(fn.apply(new Query.Builder()).build()); } /** * Specify if request cache should be used for this request or not, defaults to * true * * API name: {@code request_cache} */ public final Builder requestCache(@Nullable Boolean value) { this.requestCache = value; return this; } /** * API name: {@code rescore} * * Adds all elements of list to rescore. */ public final Builder rescore(List list) { this.rescore = _listAddAll(this.rescore, list); return this; } /** * API name: {@code rescore} * * Adds one or more values to rescore. */ public final Builder rescore(Rescore value, Rescore... values) { this.rescore = _listAdd(this.rescore, value, values); return this; } /** * API name: {@code rescore} * * Adds a value to rescore using a builder lambda. */ public final Builder rescore(Function> fn) { return rescore(fn.apply(new Rescore.Builder()).build()); } /** * A comma-separated list of specific routing values * * API name: {@code routing} */ public final Builder routing(@Nullable String value) { this.routing = value; return this; } /** * Defines one or more runtime fields in the search request. These fields take * precedence over mapped fields with the same name. * * API name: {@code runtime_mappings} * * Adds all entries of map to runtimeMappings. */ public final Builder runtimeMappings(Map> map) { this.runtimeMappings = _mapPutAll(this.runtimeMappings, map); return this; } /** * Defines one or more runtime fields in the search request. These fields take * precedence over mapped fields with the same name. * * API name: {@code runtime_mappings} * * Adds an entry to runtimeMappings. */ public final Builder runtimeMappings(String key, List value) { this.runtimeMappings = _mapPut(this.runtimeMappings, key, value); return this; } /** * Retrieve a script evaluation (based on different fields) for each hit. * * API name: {@code script_fields} * * Adds all entries of map to scriptFields. */ public final Builder scriptFields(Map map) { this.scriptFields = _mapPutAll(this.scriptFields, map); return this; } /** * Retrieve a script evaluation (based on different fields) for each hit. * * API name: {@code script_fields} * * Adds an entry to scriptFields. */ public final Builder scriptFields(String key, ScriptField value) { this.scriptFields = _mapPut(this.scriptFields, key, value); return this; } /** * Retrieve a script evaluation (based on different fields) for each hit. * * API name: {@code script_fields} * * Adds an entry to scriptFields using a builder lambda. */ public final Builder scriptFields(String key, Function> fn) { return scriptFields(key, fn.apply(new ScriptField.Builder()).build()); } /** * API name: {@code scroll} */ public final Builder scroll(@Nullable Time value) { this.scroll = value; return this; } /** * API name: {@code scroll} */ public final Builder scroll(Function> fn) { return this.scroll(fn.apply(new Time.Builder()).build()); } /** * API name: {@code search_after} * * Adds all elements of list to searchAfter. */ public final Builder searchAfter(List list) { this.searchAfter = _listAddAll(this.searchAfter, list); return this; } /** * API name: {@code search_after} * * Adds one or more values to searchAfter. */ public final Builder searchAfter(String value, String... values) { this.searchAfter = _listAdd(this.searchAfter, value, values); return this; } /** * Search operation type * * API name: {@code search_type} */ public final Builder searchType(@Nullable SearchType value) { this.searchType = value; return this; } /** * If true, returns sequence number and primary term of the last modification of * each hit. See Optimistic concurrency control. * * API name: {@code seq_no_primary_term} */ public final Builder seqNoPrimaryTerm(@Nullable Boolean value) { this.seqNoPrimaryTerm = value; return this; } /** * The number of hits to return. By default, you cannot page through more than * 10,000 hits using the from and size parameters. To page through more hits, * use the search_after parameter. * * API name: {@code size} */ public final Builder size(@Nullable Integer value) { this.size = value; return this; } /** * API name: {@code slice} */ public final Builder slice(@Nullable SlicedScroll value) { this.slice = value; return this; } /** * API name: {@code slice} */ public final Builder slice(Function> fn) { return this.slice(fn.apply(new SlicedScroll.Builder()).build()); } /** * API name: {@code sort} * * Adds all elements of list to sort. */ public final Builder sort(List list) { this.sort = _listAddAll(this.sort, list); return this; } /** * API name: {@code sort} * * Adds one or more values to sort. */ public final Builder sort(SortOptions value, SortOptions... values) { this.sort = _listAdd(this.sort, value, values); return this; } /** * API name: {@code sort} * * Adds a value to sort using a builder lambda. */ public final Builder sort(Function> fn) { return sort(fn.apply(new SortOptions.Builder()).build()); } /** * Stats groups to associate with the search. Each group maintains a statistics * aggregation for its associated searches. You can retrieve these stats using * the indices stats API. * * API name: {@code stats} * * Adds all elements of list to stats. */ public final Builder stats(List list) { this.stats = _listAddAll(this.stats, list); return this; } /** * Stats groups to associate with the search. Each group maintains a statistics * aggregation for its associated searches. You can retrieve these stats using * the indices stats API. * * API name: {@code stats} * * Adds one or more values to stats. */ public final Builder stats(String value, String... values) { this.stats = _listAdd(this.stats, value, values); return this; } /** * List of stored fields to return as part of a hit. If no fields are specified, * no stored fields are included in the response. If this field is specified, * the _source parameter defaults to false. You can pass _source: true to return * both source fields and stored fields in the search response. * * API name: {@code stored_fields} * * Adds all elements of list to storedFields. */ public final Builder storedFields(List list) { this.storedFields = _listAddAll(this.storedFields, list); return this; } /** * List of stored fields to return as part of a hit. If no fields are specified, * no stored fields are included in the response. If this field is specified, * the _source parameter defaults to false. You can pass _source: true to return * both source fields and stored fields in the search response. * * API name: {@code stored_fields} * * Adds one or more values to storedFields. */ public final Builder storedFields(String value, String... values) { this.storedFields = _listAdd(this.storedFields, value, values); return this; } /** * API name: {@code suggest} */ public final Builder suggest(@Nullable Suggester value) { this.suggest = value; return this; } /** * API name: {@code suggest} */ public final Builder suggest(Function> fn) { return this.suggest(fn.apply(new Suggester.Builder()).build()); } /** * Maximum number of documents to collect for each shard. If a query reaches * this limit, Elasticsearch terminates the query early. Elasticsearch collects * documents before sorting. Defaults to 0, which does not terminate query * execution early. * * API name: {@code terminate_after} */ public final Builder terminateAfter(@Nullable Long value) { this.terminateAfter = value; return this; } /** * Specifies the period of time to wait for a response from each shard. If no * response is received before the timeout expires, the request fails and * returns an error. Defaults to no timeout. * * API name: {@code timeout} */ public final Builder timeout(@Nullable String value) { this.timeout = value; return this; } /** * If true, calculate and return document scores, even if the scores are not * used for sorting. * * API name: {@code track_scores} */ public final Builder trackScores(@Nullable Boolean value) { this.trackScores = value; return this; } /** * Number of hits matching the query to count accurately. If true, the exact * number of hits is returned at the cost of some performance. If false, the * response does not include the total number of hits matching the query. * Defaults to 10,000 hits. * * API name: {@code track_total_hits} */ public final Builder trackTotalHits(@Nullable TrackHits value) { this.trackTotalHits = value; return this; } /** * Number of hits matching the query to count accurately. If true, the exact * number of hits is returned at the cost of some performance. If false, the * response does not include the total number of hits matching the query. * Defaults to 10,000 hits. * * API name: {@code track_total_hits} */ public final Builder trackTotalHits(Function> fn) { return this.trackTotalHits(fn.apply(new TrackHits.Builder()).build()); } /** * If true, returns document version as part of a hit. * * API name: {@code version} */ public final Builder version(@Nullable Boolean value) { this.version = value; return this; } /** * Specify the time that the request should block waiting for the final response * * API name: {@code wait_for_completion_timeout} */ public final Builder waitForCompletionTimeout(@Nullable Time value) { this.waitForCompletionTimeout = value; return this; } /** * Specify the time that the request should block waiting for the final response * * API name: {@code wait_for_completion_timeout} */ public final Builder waitForCompletionTimeout(Function> fn) { return this.waitForCompletionTimeout(fn.apply(new Time.Builder()).build()); } @Override protected Builder self() { return this; } /** * Builds a {@link SubmitRequest}. * * @throws NullPointerException * if some of the required fields are null. */ public SubmitRequest build() { _checkSingleUse(); return new SubmitRequest(this); } } // --------------------------------------------------------------------------------------------- /** * Json deserializer for {@link SubmitRequest} */ public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy(Builder::new, SubmitRequest::setupSubmitRequestDeserializer); protected static void setupSubmitRequestDeserializer(ObjectDeserializer op) { op.add(Builder::source, SourceConfig._DESERIALIZER, "_source"); op.add(Builder::aggregations, JsonpDeserializer.stringMapDeserializer(Aggregation._DESERIALIZER), "aggregations", "aggs"); op.add(Builder::collapse, FieldCollapse._DESERIALIZER, "collapse"); op.add(Builder::docvalueFields, JsonpDeserializer.arrayDeserializer(FieldAndFormat._DESERIALIZER), "docvalue_fields"); op.add(Builder::explain, JsonpDeserializer.booleanDeserializer(), "explain"); op.add(Builder::fields, JsonpDeserializer.arrayDeserializer(FieldAndFormat._DESERIALIZER), "fields"); op.add(Builder::from, JsonpDeserializer.integerDeserializer(), "from"); op.add(Builder::highlight, Highlight._DESERIALIZER, "highlight"); op.add(Builder::indicesBoost, JsonpDeserializer.arrayDeserializer( JsonpDeserializer.stringMapDeserializer(JsonpDeserializer.doubleDeserializer())), "indices_boost"); op.add(Builder::minScore, JsonpDeserializer.doubleDeserializer(), "min_score"); op.add(Builder::pit, PointInTimeReference._DESERIALIZER, "pit"); op.add(Builder::postFilter, Query._DESERIALIZER, "post_filter"); op.add(Builder::profile, JsonpDeserializer.booleanDeserializer(), "profile"); op.add(Builder::query, Query._DESERIALIZER, "query"); op.add(Builder::rescore, JsonpDeserializer.arrayDeserializer(Rescore._DESERIALIZER), "rescore"); op.add(Builder::runtimeMappings, JsonpDeserializer.stringMapDeserializer( JsonpDeserializer.arrayDeserializer(RuntimeField._DESERIALIZER)), "runtime_mappings"); op.add(Builder::scriptFields, JsonpDeserializer.stringMapDeserializer(ScriptField._DESERIALIZER), "script_fields"); op.add(Builder::searchAfter, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "search_after"); op.add(Builder::seqNoPrimaryTerm, JsonpDeserializer.booleanDeserializer(), "seq_no_primary_term"); op.add(Builder::size, JsonpDeserializer.integerDeserializer(), "size"); op.add(Builder::slice, SlicedScroll._DESERIALIZER, "slice"); op.add(Builder::sort, JsonpDeserializer.arrayDeserializer(SortOptions._DESERIALIZER), "sort"); op.add(Builder::stats, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "stats"); op.add(Builder::storedFields, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "stored_fields"); op.add(Builder::suggest, Suggester._DESERIALIZER, "suggest"); op.add(Builder::terminateAfter, JsonpDeserializer.longDeserializer(), "terminate_after"); op.add(Builder::timeout, JsonpDeserializer.stringDeserializer(), "timeout"); op.add(Builder::trackScores, JsonpDeserializer.booleanDeserializer(), "track_scores"); op.add(Builder::trackTotalHits, TrackHits._DESERIALIZER, "track_total_hits"); op.add(Builder::version, JsonpDeserializer.booleanDeserializer(), "version"); } // --------------------------------------------------------------------------------------------- /** * Endpoint "{@code async_search.submit}". */ public static final SimpleEndpoint _ENDPOINT = new SimpleEndpoint<>("es/async_search.submit", // Request method request -> { return "POST"; }, // Request path request -> { final int _index = 1 << 0; int propsSet = 0; if (ApiTypeHelper.isDefined(request.index())) propsSet |= _index; if (propsSet == 0) { StringBuilder buf = new StringBuilder(); buf.append("/_async_search"); return buf.toString(); } if (propsSet == (_index)) { StringBuilder buf = new StringBuilder(); buf.append("/"); SimpleEndpoint.pathEncode(request.index.stream().map(v -> v).collect(Collectors.joining(",")), buf); buf.append("/_async_search"); return buf.toString(); } throw SimpleEndpoint.noPathTemplateFound("path"); }, // Request parameters request -> { Map params = new HashMap<>(); params.put("typed_keys", "true"); if (request.df != null) { params.put("df", request.df); } if (request.preFilterShardSize != null) { params.put("pre_filter_shard_size", String.valueOf(request.preFilterShardSize)); } if (request.minCompatibleShardNode != null) { params.put("min_compatible_shard_node", request.minCompatibleShardNode); } if (request.lenient != null) { params.put("lenient", String.valueOf(request.lenient)); } if (request.routing != null) { params.put("routing", request.routing); } if (request.ignoreUnavailable != null) { params.put("ignore_unavailable", String.valueOf(request.ignoreUnavailable)); } if (request.allowNoIndices != null) { params.put("allow_no_indices", String.valueOf(request.allowNoIndices)); } if (request.analyzer != null) { params.put("analyzer", request.analyzer); } if (request.ignoreThrottled != null) { params.put("ignore_throttled", String.valueOf(request.ignoreThrottled)); } if (request.keepOnCompletion != null) { params.put("keep_on_completion", String.valueOf(request.keepOnCompletion)); } if (request.maxConcurrentShardRequests != null) { params.put("max_concurrent_shard_requests", String.valueOf(request.maxConcurrentShardRequests)); } if (request.allowPartialSearchResults != null) { params.put("allow_partial_search_results", String.valueOf(request.allowPartialSearchResults)); } if (ApiTypeHelper.isDefined(request.expandWildcards)) { params.put("expand_wildcards", request.expandWildcards.stream().map(v -> v.jsonValue()).collect(Collectors.joining(","))); } if (request.preference != null) { params.put("preference", request.preference); } if (request.analyzeWildcard != null) { params.put("analyze_wildcard", String.valueOf(request.analyzeWildcard)); } if (request.scroll != null) { params.put("scroll", request.scroll._toJsonString()); } if (request.waitForCompletionTimeout != null) { params.put("wait_for_completion_timeout", request.waitForCompletionTimeout._toJsonString()); } if (request.searchType != null) { params.put("search_type", request.searchType.jsonValue()); } if (request.ccsMinimizeRoundtrips != null) { params.put("ccs_minimize_roundtrips", String.valueOf(request.ccsMinimizeRoundtrips)); } if (request.q != null) { params.put("q", request.q); } if (request.defaultOperator != null) { params.put("default_operator", request.defaultOperator.jsonValue()); } if (request.keepAlive != null) { params.put("keep_alive", request.keepAlive._toJsonString()); } if (request.requestCache != null) { params.put("request_cache", String.valueOf(request.requestCache)); } if (request.batchedReduceSize != null) { params.put("batched_reduce_size", String.valueOf(request.batchedReduceSize)); } return params; }, SimpleEndpoint.emptyMap(), true, SubmitResponse._DESERIALIZER); /** * Create an "{@code async_search.submit}" endpoint. */ public static Endpoint, ErrorResponse> createSubmitEndpoint( JsonpDeserializer tDocumentDeserializer) { return _ENDPOINT .withResponseDeserializer(SubmitResponse.createSubmitResponseDeserializer(tDocumentDeserializer)); } }
* API name: {@code expand_wildcards} *
* Adds all elements of list to expandWildcards. */ public final Builder expandWildcards(List list) { this.expandWildcards = _listAddAll(this.expandWildcards, list); return this; } /** * Whether to expand wildcard expression to concrete indices that are open, * closed or both. * * API name: {@code expand_wildcards} * * Adds one or more values to expandWildcards. */ public final Builder expandWildcards(ExpandWildcard value, ExpandWildcard... values) { this.expandWildcards = _listAdd(this.expandWildcards, value, values); return this; } /** * If true, returns detailed information about score computation as part of a * hit. * * API name: {@code explain} */ public final Builder explain(@Nullable Boolean value) { this.explain = value; return this; } /** * Array of wildcard (*) patterns. The request returns values for field names * matching these patterns in the hits.fields property of the response. * * API name: {@code fields} * * Adds all elements of list to fields. */ public final Builder fields(List list) { this.fields = _listAddAll(this.fields, list); return this; } /** * Array of wildcard (*) patterns. The request returns values for field names * matching these patterns in the hits.fields property of the response. * * API name: {@code fields} * * Adds one or more values to fields. */ public final Builder fields(FieldAndFormat value, FieldAndFormat... values) { this.fields = _listAdd(this.fields, value, values); return this; } /** * Array of wildcard (*) patterns. The request returns values for field names * matching these patterns in the hits.fields property of the response. * * API name: {@code fields} * * Adds a value to fields using a builder lambda. */ public final Builder fields(Function> fn) { return fields(fn.apply(new FieldAndFormat.Builder()).build()); } /** * Starting document offset. By default, you cannot page through more than * 10,000 hits using the from and size parameters. To page through more hits, * use the search_after parameter. * * API name: {@code from} */ public final Builder from(@Nullable Integer value) { this.from = value; return this; } /** * API name: {@code highlight} */ public final Builder highlight(@Nullable Highlight value) { this.highlight = value; return this; } /** * API name: {@code highlight} */ public final Builder highlight(Function> fn) { return this.highlight(fn.apply(new Highlight.Builder()).build()); } /** * Whether specified concrete, expanded or aliased indices should be ignored * when throttled * * API name: {@code ignore_throttled} */ public final Builder ignoreThrottled(@Nullable Boolean value) { this.ignoreThrottled = value; return this; } /** * Whether specified concrete indices should be ignored when unavailable * (missing or closed) * * API name: {@code ignore_unavailable} */ public final Builder ignoreUnavailable(@Nullable Boolean value) { this.ignoreUnavailable = value; return this; } /** * A comma-separated list of index names to search; use _all or * empty string to perform the operation on all indices * * API name: {@code index} * * Adds all elements of list to index. */ public final Builder index(List list) { this.index = _listAddAll(this.index, list); return this; } /** * A comma-separated list of index names to search; use _all or * empty string to perform the operation on all indices * * API name: {@code index} * * Adds one or more values to index. */ public final Builder index(String value, String... values) { this.index = _listAdd(this.index, value, values); return this; } /** * Boosts the _score of documents from specified indices. * * API name: {@code indices_boost} * * Adds all elements of list to indicesBoost. */ public final Builder indicesBoost(List> list) { this.indicesBoost = _listAddAll(this.indicesBoost, list); return this; } /** * Boosts the _score of documents from specified indices. * * API name: {@code indices_boost} * * Adds one or more values to indicesBoost. */ public final Builder indicesBoost(Map value, Map... values) { this.indicesBoost = _listAdd(this.indicesBoost, value, values); return this; } /** * Update the time interval in which the results (partial or final) for this * search will be available * * API name: {@code keep_alive} */ public final Builder keepAlive(@Nullable Time value) { this.keepAlive = value; return this; } /** * Update the time interval in which the results (partial or final) for this * search will be available * * API name: {@code keep_alive} */ public final Builder keepAlive(Function> fn) { return this.keepAlive(fn.apply(new Time.Builder()).build()); } /** * Control whether the response should be stored in the cluster if it completed * within the provided [wait_for_completion] time (default: false) * * API name: {@code keep_on_completion} */ public final Builder keepOnCompletion(@Nullable Boolean value) { this.keepOnCompletion = value; return this; } /** * Specify whether format-based query failures (such as providing text to a * numeric field) should be ignored * * API name: {@code lenient} */ public final Builder lenient(@Nullable Boolean value) { this.lenient = value; return this; } /** * The number of concurrent shard requests per node this search executes * concurrently. This value should be used to limit the impact of the search on * the cluster in order to limit the number of concurrent shard requests * * API name: {@code max_concurrent_shard_requests} */ public final Builder maxConcurrentShardRequests(@Nullable Long value) { this.maxConcurrentShardRequests = value; return this; } /** * API name: {@code min_compatible_shard_node} */ public final Builder minCompatibleShardNode(@Nullable String value) { this.minCompatibleShardNode = value; return this; } /** * Minimum _score for matching documents. Documents with a lower _score are not * included in the search results. * * API name: {@code min_score} */ public final Builder minScore(@Nullable Double value) { this.minScore = value; return this; } /** * Limits the search to a point in time (PIT). If you provide a PIT, you cannot * specify an <index> in the request path. * * API name: {@code pit} */ public final Builder pit(@Nullable PointInTimeReference value) { this.pit = value; return this; } /** * Limits the search to a point in time (PIT). If you provide a PIT, you cannot * specify an <index> in the request path. * * API name: {@code pit} */ public final Builder pit(Function> fn) { return this.pit(fn.apply(new PointInTimeReference.Builder()).build()); } /** * API name: {@code post_filter} */ public final Builder postFilter(@Nullable Query value) { this.postFilter = value; return this; } /** * API name: {@code post_filter} */ public final Builder postFilter(Function> fn) { return this.postFilter(fn.apply(new Query.Builder()).build()); } /** * API name: {@code pre_filter_shard_size} */ public final Builder preFilterShardSize(@Nullable Long value) { this.preFilterShardSize = value; return this; } /** * Specify the node or shard the operation should be performed on (default: * random) * * API name: {@code preference} */ public final Builder preference(@Nullable String value) { this.preference = value; return this; } /** * API name: {@code profile} */ public final Builder profile(@Nullable Boolean value) { this.profile = value; return this; } /** * Query in the Lucene query string syntax * * API name: {@code q} */ public final Builder q(@Nullable String value) { this.q = value; return this; } /** * Defines the search definition using the Query DSL. * * API name: {@code query} */ public final Builder query(@Nullable Query value) { this.query = value; return this; } /** * Defines the search definition using the Query DSL. * * API name: {@code query} */ public final Builder query(Function> fn) { return this.query(fn.apply(new Query.Builder()).build()); } /** * Specify if request cache should be used for this request or not, defaults to * true * * API name: {@code request_cache} */ public final Builder requestCache(@Nullable Boolean value) { this.requestCache = value; return this; } /** * API name: {@code rescore} * * Adds all elements of list to rescore. */ public final Builder rescore(List list) { this.rescore = _listAddAll(this.rescore, list); return this; } /** * API name: {@code rescore} * * Adds one or more values to rescore. */ public final Builder rescore(Rescore value, Rescore... values) { this.rescore = _listAdd(this.rescore, value, values); return this; } /** * API name: {@code rescore} * * Adds a value to rescore using a builder lambda. */ public final Builder rescore(Function> fn) { return rescore(fn.apply(new Rescore.Builder()).build()); } /** * A comma-separated list of specific routing values * * API name: {@code routing} */ public final Builder routing(@Nullable String value) { this.routing = value; return this; } /** * Defines one or more runtime fields in the search request. These fields take * precedence over mapped fields with the same name. * * API name: {@code runtime_mappings} * * Adds all entries of map to runtimeMappings. */ public final Builder runtimeMappings(Map> map) { this.runtimeMappings = _mapPutAll(this.runtimeMappings, map); return this; } /** * Defines one or more runtime fields in the search request. These fields take * precedence over mapped fields with the same name. * * API name: {@code runtime_mappings} * * Adds an entry to runtimeMappings. */ public final Builder runtimeMappings(String key, List value) { this.runtimeMappings = _mapPut(this.runtimeMappings, key, value); return this; } /** * Retrieve a script evaluation (based on different fields) for each hit. * * API name: {@code script_fields} * * Adds all entries of map to scriptFields. */ public final Builder scriptFields(Map map) { this.scriptFields = _mapPutAll(this.scriptFields, map); return this; } /** * Retrieve a script evaluation (based on different fields) for each hit. * * API name: {@code script_fields} * * Adds an entry to scriptFields. */ public final Builder scriptFields(String key, ScriptField value) { this.scriptFields = _mapPut(this.scriptFields, key, value); return this; } /** * Retrieve a script evaluation (based on different fields) for each hit. * * API name: {@code script_fields} * * Adds an entry to scriptFields using a builder lambda. */ public final Builder scriptFields(String key, Function> fn) { return scriptFields(key, fn.apply(new ScriptField.Builder()).build()); } /** * API name: {@code scroll} */ public final Builder scroll(@Nullable Time value) { this.scroll = value; return this; } /** * API name: {@code scroll} */ public final Builder scroll(Function> fn) { return this.scroll(fn.apply(new Time.Builder()).build()); } /** * API name: {@code search_after} * * Adds all elements of list to searchAfter. */ public final Builder searchAfter(List list) { this.searchAfter = _listAddAll(this.searchAfter, list); return this; } /** * API name: {@code search_after} * * Adds one or more values to searchAfter. */ public final Builder searchAfter(String value, String... values) { this.searchAfter = _listAdd(this.searchAfter, value, values); return this; } /** * Search operation type * * API name: {@code search_type} */ public final Builder searchType(@Nullable SearchType value) { this.searchType = value; return this; } /** * If true, returns sequence number and primary term of the last modification of * each hit. See Optimistic concurrency control. * * API name: {@code seq_no_primary_term} */ public final Builder seqNoPrimaryTerm(@Nullable Boolean value) { this.seqNoPrimaryTerm = value; return this; } /** * The number of hits to return. By default, you cannot page through more than * 10,000 hits using the from and size parameters. To page through more hits, * use the search_after parameter. * * API name: {@code size} */ public final Builder size(@Nullable Integer value) { this.size = value; return this; } /** * API name: {@code slice} */ public final Builder slice(@Nullable SlicedScroll value) { this.slice = value; return this; } /** * API name: {@code slice} */ public final Builder slice(Function> fn) { return this.slice(fn.apply(new SlicedScroll.Builder()).build()); } /** * API name: {@code sort} * * Adds all elements of list to sort. */ public final Builder sort(List list) { this.sort = _listAddAll(this.sort, list); return this; } /** * API name: {@code sort} * * Adds one or more values to sort. */ public final Builder sort(SortOptions value, SortOptions... values) { this.sort = _listAdd(this.sort, value, values); return this; } /** * API name: {@code sort} * * Adds a value to sort using a builder lambda. */ public final Builder sort(Function> fn) { return sort(fn.apply(new SortOptions.Builder()).build()); } /** * Stats groups to associate with the search. Each group maintains a statistics * aggregation for its associated searches. You can retrieve these stats using * the indices stats API. * * API name: {@code stats} * * Adds all elements of list to stats. */ public final Builder stats(List list) { this.stats = _listAddAll(this.stats, list); return this; } /** * Stats groups to associate with the search. Each group maintains a statistics * aggregation for its associated searches. You can retrieve these stats using * the indices stats API. * * API name: {@code stats} * * Adds one or more values to stats. */ public final Builder stats(String value, String... values) { this.stats = _listAdd(this.stats, value, values); return this; } /** * List of stored fields to return as part of a hit. If no fields are specified, * no stored fields are included in the response. If this field is specified, * the _source parameter defaults to false. You can pass _source: true to return * both source fields and stored fields in the search response. * * API name: {@code stored_fields} * * Adds all elements of list to storedFields. */ public final Builder storedFields(List list) { this.storedFields = _listAddAll(this.storedFields, list); return this; } /** * List of stored fields to return as part of a hit. If no fields are specified, * no stored fields are included in the response. If this field is specified, * the _source parameter defaults to false. You can pass _source: true to return * both source fields and stored fields in the search response. * * API name: {@code stored_fields} * * Adds one or more values to storedFields. */ public final Builder storedFields(String value, String... values) { this.storedFields = _listAdd(this.storedFields, value, values); return this; } /** * API name: {@code suggest} */ public final Builder suggest(@Nullable Suggester value) { this.suggest = value; return this; } /** * API name: {@code suggest} */ public final Builder suggest(Function> fn) { return this.suggest(fn.apply(new Suggester.Builder()).build()); } /** * Maximum number of documents to collect for each shard. If a query reaches * this limit, Elasticsearch terminates the query early. Elasticsearch collects * documents before sorting. Defaults to 0, which does not terminate query * execution early. * * API name: {@code terminate_after} */ public final Builder terminateAfter(@Nullable Long value) { this.terminateAfter = value; return this; } /** * Specifies the period of time to wait for a response from each shard. If no * response is received before the timeout expires, the request fails and * returns an error. Defaults to no timeout. * * API name: {@code timeout} */ public final Builder timeout(@Nullable String value) { this.timeout = value; return this; } /** * If true, calculate and return document scores, even if the scores are not * used for sorting. * * API name: {@code track_scores} */ public final Builder trackScores(@Nullable Boolean value) { this.trackScores = value; return this; } /** * Number of hits matching the query to count accurately. If true, the exact * number of hits is returned at the cost of some performance. If false, the * response does not include the total number of hits matching the query. * Defaults to 10,000 hits. * * API name: {@code track_total_hits} */ public final Builder trackTotalHits(@Nullable TrackHits value) { this.trackTotalHits = value; return this; } /** * Number of hits matching the query to count accurately. If true, the exact * number of hits is returned at the cost of some performance. If false, the * response does not include the total number of hits matching the query. * Defaults to 10,000 hits. * * API name: {@code track_total_hits} */ public final Builder trackTotalHits(Function> fn) { return this.trackTotalHits(fn.apply(new TrackHits.Builder()).build()); } /** * If true, returns document version as part of a hit. * * API name: {@code version} */ public final Builder version(@Nullable Boolean value) { this.version = value; return this; } /** * Specify the time that the request should block waiting for the final response * * API name: {@code wait_for_completion_timeout} */ public final Builder waitForCompletionTimeout(@Nullable Time value) { this.waitForCompletionTimeout = value; return this; } /** * Specify the time that the request should block waiting for the final response * * API name: {@code wait_for_completion_timeout} */ public final Builder waitForCompletionTimeout(Function> fn) { return this.waitForCompletionTimeout(fn.apply(new Time.Builder()).build()); } @Override protected Builder self() { return this; } /** * Builds a {@link SubmitRequest}. * * @throws NullPointerException * if some of the required fields are null. */ public SubmitRequest build() { _checkSingleUse(); return new SubmitRequest(this); } } // --------------------------------------------------------------------------------------------- /** * Json deserializer for {@link SubmitRequest} */ public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy(Builder::new, SubmitRequest::setupSubmitRequestDeserializer); protected static void setupSubmitRequestDeserializer(ObjectDeserializer op) { op.add(Builder::source, SourceConfig._DESERIALIZER, "_source"); op.add(Builder::aggregations, JsonpDeserializer.stringMapDeserializer(Aggregation._DESERIALIZER), "aggregations", "aggs"); op.add(Builder::collapse, FieldCollapse._DESERIALIZER, "collapse"); op.add(Builder::docvalueFields, JsonpDeserializer.arrayDeserializer(FieldAndFormat._DESERIALIZER), "docvalue_fields"); op.add(Builder::explain, JsonpDeserializer.booleanDeserializer(), "explain"); op.add(Builder::fields, JsonpDeserializer.arrayDeserializer(FieldAndFormat._DESERIALIZER), "fields"); op.add(Builder::from, JsonpDeserializer.integerDeserializer(), "from"); op.add(Builder::highlight, Highlight._DESERIALIZER, "highlight"); op.add(Builder::indicesBoost, JsonpDeserializer.arrayDeserializer( JsonpDeserializer.stringMapDeserializer(JsonpDeserializer.doubleDeserializer())), "indices_boost"); op.add(Builder::minScore, JsonpDeserializer.doubleDeserializer(), "min_score"); op.add(Builder::pit, PointInTimeReference._DESERIALIZER, "pit"); op.add(Builder::postFilter, Query._DESERIALIZER, "post_filter"); op.add(Builder::profile, JsonpDeserializer.booleanDeserializer(), "profile"); op.add(Builder::query, Query._DESERIALIZER, "query"); op.add(Builder::rescore, JsonpDeserializer.arrayDeserializer(Rescore._DESERIALIZER), "rescore"); op.add(Builder::runtimeMappings, JsonpDeserializer.stringMapDeserializer( JsonpDeserializer.arrayDeserializer(RuntimeField._DESERIALIZER)), "runtime_mappings"); op.add(Builder::scriptFields, JsonpDeserializer.stringMapDeserializer(ScriptField._DESERIALIZER), "script_fields"); op.add(Builder::searchAfter, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "search_after"); op.add(Builder::seqNoPrimaryTerm, JsonpDeserializer.booleanDeserializer(), "seq_no_primary_term"); op.add(Builder::size, JsonpDeserializer.integerDeserializer(), "size"); op.add(Builder::slice, SlicedScroll._DESERIALIZER, "slice"); op.add(Builder::sort, JsonpDeserializer.arrayDeserializer(SortOptions._DESERIALIZER), "sort"); op.add(Builder::stats, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "stats"); op.add(Builder::storedFields, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "stored_fields"); op.add(Builder::suggest, Suggester._DESERIALIZER, "suggest"); op.add(Builder::terminateAfter, JsonpDeserializer.longDeserializer(), "terminate_after"); op.add(Builder::timeout, JsonpDeserializer.stringDeserializer(), "timeout"); op.add(Builder::trackScores, JsonpDeserializer.booleanDeserializer(), "track_scores"); op.add(Builder::trackTotalHits, TrackHits._DESERIALIZER, "track_total_hits"); op.add(Builder::version, JsonpDeserializer.booleanDeserializer(), "version"); } // --------------------------------------------------------------------------------------------- /** * Endpoint "{@code async_search.submit}". */ public static final SimpleEndpoint _ENDPOINT = new SimpleEndpoint<>("es/async_search.submit", // Request method request -> { return "POST"; }, // Request path request -> { final int _index = 1 << 0; int propsSet = 0; if (ApiTypeHelper.isDefined(request.index())) propsSet |= _index; if (propsSet == 0) { StringBuilder buf = new StringBuilder(); buf.append("/_async_search"); return buf.toString(); } if (propsSet == (_index)) { StringBuilder buf = new StringBuilder(); buf.append("/"); SimpleEndpoint.pathEncode(request.index.stream().map(v -> v).collect(Collectors.joining(",")), buf); buf.append("/_async_search"); return buf.toString(); } throw SimpleEndpoint.noPathTemplateFound("path"); }, // Request parameters request -> { Map params = new HashMap<>(); params.put("typed_keys", "true"); if (request.df != null) { params.put("df", request.df); } if (request.preFilterShardSize != null) { params.put("pre_filter_shard_size", String.valueOf(request.preFilterShardSize)); } if (request.minCompatibleShardNode != null) { params.put("min_compatible_shard_node", request.minCompatibleShardNode); } if (request.lenient != null) { params.put("lenient", String.valueOf(request.lenient)); } if (request.routing != null) { params.put("routing", request.routing); } if (request.ignoreUnavailable != null) { params.put("ignore_unavailable", String.valueOf(request.ignoreUnavailable)); } if (request.allowNoIndices != null) { params.put("allow_no_indices", String.valueOf(request.allowNoIndices)); } if (request.analyzer != null) { params.put("analyzer", request.analyzer); } if (request.ignoreThrottled != null) { params.put("ignore_throttled", String.valueOf(request.ignoreThrottled)); } if (request.keepOnCompletion != null) { params.put("keep_on_completion", String.valueOf(request.keepOnCompletion)); } if (request.maxConcurrentShardRequests != null) { params.put("max_concurrent_shard_requests", String.valueOf(request.maxConcurrentShardRequests)); } if (request.allowPartialSearchResults != null) { params.put("allow_partial_search_results", String.valueOf(request.allowPartialSearchResults)); } if (ApiTypeHelper.isDefined(request.expandWildcards)) { params.put("expand_wildcards", request.expandWildcards.stream().map(v -> v.jsonValue()).collect(Collectors.joining(","))); } if (request.preference != null) { params.put("preference", request.preference); } if (request.analyzeWildcard != null) { params.put("analyze_wildcard", String.valueOf(request.analyzeWildcard)); } if (request.scroll != null) { params.put("scroll", request.scroll._toJsonString()); } if (request.waitForCompletionTimeout != null) { params.put("wait_for_completion_timeout", request.waitForCompletionTimeout._toJsonString()); } if (request.searchType != null) { params.put("search_type", request.searchType.jsonValue()); } if (request.ccsMinimizeRoundtrips != null) { params.put("ccs_minimize_roundtrips", String.valueOf(request.ccsMinimizeRoundtrips)); } if (request.q != null) { params.put("q", request.q); } if (request.defaultOperator != null) { params.put("default_operator", request.defaultOperator.jsonValue()); } if (request.keepAlive != null) { params.put("keep_alive", request.keepAlive._toJsonString()); } if (request.requestCache != null) { params.put("request_cache", String.valueOf(request.requestCache)); } if (request.batchedReduceSize != null) { params.put("batched_reduce_size", String.valueOf(request.batchedReduceSize)); } return params; }, SimpleEndpoint.emptyMap(), true, SubmitResponse._DESERIALIZER); /** * Create an "{@code async_search.submit}" endpoint. */ public static Endpoint, ErrorResponse> createSubmitEndpoint( JsonpDeserializer tDocumentDeserializer) { return _ENDPOINT .withResponseDeserializer(SubmitResponse.createSubmitResponseDeserializer(tDocumentDeserializer)); } }
expandWildcards
* Adds one or more values to expandWildcards. */ public final Builder expandWildcards(ExpandWildcard value, ExpandWildcard... values) { this.expandWildcards = _listAdd(this.expandWildcards, value, values); return this; } /** * If true, returns detailed information about score computation as part of a * hit. *
* API name: {@code explain} */ public final Builder explain(@Nullable Boolean value) { this.explain = value; return this; } /** * Array of wildcard (*) patterns. The request returns values for field names * matching these patterns in the hits.fields property of the response. *
* API name: {@code fields} *
* Adds all elements of list to fields. */ public final Builder fields(List list) { this.fields = _listAddAll(this.fields, list); return this; } /** * Array of wildcard (*) patterns. The request returns values for field names * matching these patterns in the hits.fields property of the response. * * API name: {@code fields} * * Adds one or more values to fields. */ public final Builder fields(FieldAndFormat value, FieldAndFormat... values) { this.fields = _listAdd(this.fields, value, values); return this; } /** * Array of wildcard (*) patterns. The request returns values for field names * matching these patterns in the hits.fields property of the response. * * API name: {@code fields} * * Adds a value to fields using a builder lambda. */ public final Builder fields(Function> fn) { return fields(fn.apply(new FieldAndFormat.Builder()).build()); } /** * Starting document offset. By default, you cannot page through more than * 10,000 hits using the from and size parameters. To page through more hits, * use the search_after parameter. * * API name: {@code from} */ public final Builder from(@Nullable Integer value) { this.from = value; return this; } /** * API name: {@code highlight} */ public final Builder highlight(@Nullable Highlight value) { this.highlight = value; return this; } /** * API name: {@code highlight} */ public final Builder highlight(Function> fn) { return this.highlight(fn.apply(new Highlight.Builder()).build()); } /** * Whether specified concrete, expanded or aliased indices should be ignored * when throttled * * API name: {@code ignore_throttled} */ public final Builder ignoreThrottled(@Nullable Boolean value) { this.ignoreThrottled = value; return this; } /** * Whether specified concrete indices should be ignored when unavailable * (missing or closed) * * API name: {@code ignore_unavailable} */ public final Builder ignoreUnavailable(@Nullable Boolean value) { this.ignoreUnavailable = value; return this; } /** * A comma-separated list of index names to search; use _all or * empty string to perform the operation on all indices * * API name: {@code index} * * Adds all elements of list to index. */ public final Builder index(List list) { this.index = _listAddAll(this.index, list); return this; } /** * A comma-separated list of index names to search; use _all or * empty string to perform the operation on all indices * * API name: {@code index} * * Adds one or more values to index. */ public final Builder index(String value, String... values) { this.index = _listAdd(this.index, value, values); return this; } /** * Boosts the _score of documents from specified indices. * * API name: {@code indices_boost} * * Adds all elements of list to indicesBoost. */ public final Builder indicesBoost(List> list) { this.indicesBoost = _listAddAll(this.indicesBoost, list); return this; } /** * Boosts the _score of documents from specified indices. * * API name: {@code indices_boost} * * Adds one or more values to indicesBoost. */ public final Builder indicesBoost(Map value, Map... values) { this.indicesBoost = _listAdd(this.indicesBoost, value, values); return this; } /** * Update the time interval in which the results (partial or final) for this * search will be available * * API name: {@code keep_alive} */ public final Builder keepAlive(@Nullable Time value) { this.keepAlive = value; return this; } /** * Update the time interval in which the results (partial or final) for this * search will be available * * API name: {@code keep_alive} */ public final Builder keepAlive(Function> fn) { return this.keepAlive(fn.apply(new Time.Builder()).build()); } /** * Control whether the response should be stored in the cluster if it completed * within the provided [wait_for_completion] time (default: false) * * API name: {@code keep_on_completion} */ public final Builder keepOnCompletion(@Nullable Boolean value) { this.keepOnCompletion = value; return this; } /** * Specify whether format-based query failures (such as providing text to a * numeric field) should be ignored * * API name: {@code lenient} */ public final Builder lenient(@Nullable Boolean value) { this.lenient = value; return this; } /** * The number of concurrent shard requests per node this search executes * concurrently. This value should be used to limit the impact of the search on * the cluster in order to limit the number of concurrent shard requests * * API name: {@code max_concurrent_shard_requests} */ public final Builder maxConcurrentShardRequests(@Nullable Long value) { this.maxConcurrentShardRequests = value; return this; } /** * API name: {@code min_compatible_shard_node} */ public final Builder minCompatibleShardNode(@Nullable String value) { this.minCompatibleShardNode = value; return this; } /** * Minimum _score for matching documents. Documents with a lower _score are not * included in the search results. * * API name: {@code min_score} */ public final Builder minScore(@Nullable Double value) { this.minScore = value; return this; } /** * Limits the search to a point in time (PIT). If you provide a PIT, you cannot * specify an <index> in the request path. * * API name: {@code pit} */ public final Builder pit(@Nullable PointInTimeReference value) { this.pit = value; return this; } /** * Limits the search to a point in time (PIT). If you provide a PIT, you cannot * specify an <index> in the request path. * * API name: {@code pit} */ public final Builder pit(Function> fn) { return this.pit(fn.apply(new PointInTimeReference.Builder()).build()); } /** * API name: {@code post_filter} */ public final Builder postFilter(@Nullable Query value) { this.postFilter = value; return this; } /** * API name: {@code post_filter} */ public final Builder postFilter(Function> fn) { return this.postFilter(fn.apply(new Query.Builder()).build()); } /** * API name: {@code pre_filter_shard_size} */ public final Builder preFilterShardSize(@Nullable Long value) { this.preFilterShardSize = value; return this; } /** * Specify the node or shard the operation should be performed on (default: * random) * * API name: {@code preference} */ public final Builder preference(@Nullable String value) { this.preference = value; return this; } /** * API name: {@code profile} */ public final Builder profile(@Nullable Boolean value) { this.profile = value; return this; } /** * Query in the Lucene query string syntax * * API name: {@code q} */ public final Builder q(@Nullable String value) { this.q = value; return this; } /** * Defines the search definition using the Query DSL. * * API name: {@code query} */ public final Builder query(@Nullable Query value) { this.query = value; return this; } /** * Defines the search definition using the Query DSL. * * API name: {@code query} */ public final Builder query(Function> fn) { return this.query(fn.apply(new Query.Builder()).build()); } /** * Specify if request cache should be used for this request or not, defaults to * true * * API name: {@code request_cache} */ public final Builder requestCache(@Nullable Boolean value) { this.requestCache = value; return this; } /** * API name: {@code rescore} * * Adds all elements of list to rescore. */ public final Builder rescore(List list) { this.rescore = _listAddAll(this.rescore, list); return this; } /** * API name: {@code rescore} * * Adds one or more values to rescore. */ public final Builder rescore(Rescore value, Rescore... values) { this.rescore = _listAdd(this.rescore, value, values); return this; } /** * API name: {@code rescore} * * Adds a value to rescore using a builder lambda. */ public final Builder rescore(Function> fn) { return rescore(fn.apply(new Rescore.Builder()).build()); } /** * A comma-separated list of specific routing values * * API name: {@code routing} */ public final Builder routing(@Nullable String value) { this.routing = value; return this; } /** * Defines one or more runtime fields in the search request. These fields take * precedence over mapped fields with the same name. * * API name: {@code runtime_mappings} * * Adds all entries of map to runtimeMappings. */ public final Builder runtimeMappings(Map> map) { this.runtimeMappings = _mapPutAll(this.runtimeMappings, map); return this; } /** * Defines one or more runtime fields in the search request. These fields take * precedence over mapped fields with the same name. * * API name: {@code runtime_mappings} * * Adds an entry to runtimeMappings. */ public final Builder runtimeMappings(String key, List value) { this.runtimeMappings = _mapPut(this.runtimeMappings, key, value); return this; } /** * Retrieve a script evaluation (based on different fields) for each hit. * * API name: {@code script_fields} * * Adds all entries of map to scriptFields. */ public final Builder scriptFields(Map map) { this.scriptFields = _mapPutAll(this.scriptFields, map); return this; } /** * Retrieve a script evaluation (based on different fields) for each hit. * * API name: {@code script_fields} * * Adds an entry to scriptFields. */ public final Builder scriptFields(String key, ScriptField value) { this.scriptFields = _mapPut(this.scriptFields, key, value); return this; } /** * Retrieve a script evaluation (based on different fields) for each hit. * * API name: {@code script_fields} * * Adds an entry to scriptFields using a builder lambda. */ public final Builder scriptFields(String key, Function> fn) { return scriptFields(key, fn.apply(new ScriptField.Builder()).build()); } /** * API name: {@code scroll} */ public final Builder scroll(@Nullable Time value) { this.scroll = value; return this; } /** * API name: {@code scroll} */ public final Builder scroll(Function> fn) { return this.scroll(fn.apply(new Time.Builder()).build()); } /** * API name: {@code search_after} * * Adds all elements of list to searchAfter. */ public final Builder searchAfter(List list) { this.searchAfter = _listAddAll(this.searchAfter, list); return this; } /** * API name: {@code search_after} * * Adds one or more values to searchAfter. */ public final Builder searchAfter(String value, String... values) { this.searchAfter = _listAdd(this.searchAfter, value, values); return this; } /** * Search operation type * * API name: {@code search_type} */ public final Builder searchType(@Nullable SearchType value) { this.searchType = value; return this; } /** * If true, returns sequence number and primary term of the last modification of * each hit. See Optimistic concurrency control. * * API name: {@code seq_no_primary_term} */ public final Builder seqNoPrimaryTerm(@Nullable Boolean value) { this.seqNoPrimaryTerm = value; return this; } /** * The number of hits to return. By default, you cannot page through more than * 10,000 hits using the from and size parameters. To page through more hits, * use the search_after parameter. * * API name: {@code size} */ public final Builder size(@Nullable Integer value) { this.size = value; return this; } /** * API name: {@code slice} */ public final Builder slice(@Nullable SlicedScroll value) { this.slice = value; return this; } /** * API name: {@code slice} */ public final Builder slice(Function> fn) { return this.slice(fn.apply(new SlicedScroll.Builder()).build()); } /** * API name: {@code sort} * * Adds all elements of list to sort. */ public final Builder sort(List list) { this.sort = _listAddAll(this.sort, list); return this; } /** * API name: {@code sort} * * Adds one or more values to sort. */ public final Builder sort(SortOptions value, SortOptions... values) { this.sort = _listAdd(this.sort, value, values); return this; } /** * API name: {@code sort} * * Adds a value to sort using a builder lambda. */ public final Builder sort(Function> fn) { return sort(fn.apply(new SortOptions.Builder()).build()); } /** * Stats groups to associate with the search. Each group maintains a statistics * aggregation for its associated searches. You can retrieve these stats using * the indices stats API. * * API name: {@code stats} * * Adds all elements of list to stats. */ public final Builder stats(List list) { this.stats = _listAddAll(this.stats, list); return this; } /** * Stats groups to associate with the search. Each group maintains a statistics * aggregation for its associated searches. You can retrieve these stats using * the indices stats API. * * API name: {@code stats} * * Adds one or more values to stats. */ public final Builder stats(String value, String... values) { this.stats = _listAdd(this.stats, value, values); return this; } /** * List of stored fields to return as part of a hit. If no fields are specified, * no stored fields are included in the response. If this field is specified, * the _source parameter defaults to false. You can pass _source: true to return * both source fields and stored fields in the search response. * * API name: {@code stored_fields} * * Adds all elements of list to storedFields. */ public final Builder storedFields(List list) { this.storedFields = _listAddAll(this.storedFields, list); return this; } /** * List of stored fields to return as part of a hit. If no fields are specified, * no stored fields are included in the response. If this field is specified, * the _source parameter defaults to false. You can pass _source: true to return * both source fields and stored fields in the search response. * * API name: {@code stored_fields} * * Adds one or more values to storedFields. */ public final Builder storedFields(String value, String... values) { this.storedFields = _listAdd(this.storedFields, value, values); return this; } /** * API name: {@code suggest} */ public final Builder suggest(@Nullable Suggester value) { this.suggest = value; return this; } /** * API name: {@code suggest} */ public final Builder suggest(Function> fn) { return this.suggest(fn.apply(new Suggester.Builder()).build()); } /** * Maximum number of documents to collect for each shard. If a query reaches * this limit, Elasticsearch terminates the query early. Elasticsearch collects * documents before sorting. Defaults to 0, which does not terminate query * execution early. * * API name: {@code terminate_after} */ public final Builder terminateAfter(@Nullable Long value) { this.terminateAfter = value; return this; } /** * Specifies the period of time to wait for a response from each shard. If no * response is received before the timeout expires, the request fails and * returns an error. Defaults to no timeout. * * API name: {@code timeout} */ public final Builder timeout(@Nullable String value) { this.timeout = value; return this; } /** * If true, calculate and return document scores, even if the scores are not * used for sorting. * * API name: {@code track_scores} */ public final Builder trackScores(@Nullable Boolean value) { this.trackScores = value; return this; } /** * Number of hits matching the query to count accurately. If true, the exact * number of hits is returned at the cost of some performance. If false, the * response does not include the total number of hits matching the query. * Defaults to 10,000 hits. * * API name: {@code track_total_hits} */ public final Builder trackTotalHits(@Nullable TrackHits value) { this.trackTotalHits = value; return this; } /** * Number of hits matching the query to count accurately. If true, the exact * number of hits is returned at the cost of some performance. If false, the * response does not include the total number of hits matching the query. * Defaults to 10,000 hits. * * API name: {@code track_total_hits} */ public final Builder trackTotalHits(Function> fn) { return this.trackTotalHits(fn.apply(new TrackHits.Builder()).build()); } /** * If true, returns document version as part of a hit. * * API name: {@code version} */ public final Builder version(@Nullable Boolean value) { this.version = value; return this; } /** * Specify the time that the request should block waiting for the final response * * API name: {@code wait_for_completion_timeout} */ public final Builder waitForCompletionTimeout(@Nullable Time value) { this.waitForCompletionTimeout = value; return this; } /** * Specify the time that the request should block waiting for the final response * * API name: {@code wait_for_completion_timeout} */ public final Builder waitForCompletionTimeout(Function> fn) { return this.waitForCompletionTimeout(fn.apply(new Time.Builder()).build()); } @Override protected Builder self() { return this; } /** * Builds a {@link SubmitRequest}. * * @throws NullPointerException * if some of the required fields are null. */ public SubmitRequest build() { _checkSingleUse(); return new SubmitRequest(this); } } // --------------------------------------------------------------------------------------------- /** * Json deserializer for {@link SubmitRequest} */ public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy(Builder::new, SubmitRequest::setupSubmitRequestDeserializer); protected static void setupSubmitRequestDeserializer(ObjectDeserializer op) { op.add(Builder::source, SourceConfig._DESERIALIZER, "_source"); op.add(Builder::aggregations, JsonpDeserializer.stringMapDeserializer(Aggregation._DESERIALIZER), "aggregations", "aggs"); op.add(Builder::collapse, FieldCollapse._DESERIALIZER, "collapse"); op.add(Builder::docvalueFields, JsonpDeserializer.arrayDeserializer(FieldAndFormat._DESERIALIZER), "docvalue_fields"); op.add(Builder::explain, JsonpDeserializer.booleanDeserializer(), "explain"); op.add(Builder::fields, JsonpDeserializer.arrayDeserializer(FieldAndFormat._DESERIALIZER), "fields"); op.add(Builder::from, JsonpDeserializer.integerDeserializer(), "from"); op.add(Builder::highlight, Highlight._DESERIALIZER, "highlight"); op.add(Builder::indicesBoost, JsonpDeserializer.arrayDeserializer( JsonpDeserializer.stringMapDeserializer(JsonpDeserializer.doubleDeserializer())), "indices_boost"); op.add(Builder::minScore, JsonpDeserializer.doubleDeserializer(), "min_score"); op.add(Builder::pit, PointInTimeReference._DESERIALIZER, "pit"); op.add(Builder::postFilter, Query._DESERIALIZER, "post_filter"); op.add(Builder::profile, JsonpDeserializer.booleanDeserializer(), "profile"); op.add(Builder::query, Query._DESERIALIZER, "query"); op.add(Builder::rescore, JsonpDeserializer.arrayDeserializer(Rescore._DESERIALIZER), "rescore"); op.add(Builder::runtimeMappings, JsonpDeserializer.stringMapDeserializer( JsonpDeserializer.arrayDeserializer(RuntimeField._DESERIALIZER)), "runtime_mappings"); op.add(Builder::scriptFields, JsonpDeserializer.stringMapDeserializer(ScriptField._DESERIALIZER), "script_fields"); op.add(Builder::searchAfter, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "search_after"); op.add(Builder::seqNoPrimaryTerm, JsonpDeserializer.booleanDeserializer(), "seq_no_primary_term"); op.add(Builder::size, JsonpDeserializer.integerDeserializer(), "size"); op.add(Builder::slice, SlicedScroll._DESERIALIZER, "slice"); op.add(Builder::sort, JsonpDeserializer.arrayDeserializer(SortOptions._DESERIALIZER), "sort"); op.add(Builder::stats, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "stats"); op.add(Builder::storedFields, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "stored_fields"); op.add(Builder::suggest, Suggester._DESERIALIZER, "suggest"); op.add(Builder::terminateAfter, JsonpDeserializer.longDeserializer(), "terminate_after"); op.add(Builder::timeout, JsonpDeserializer.stringDeserializer(), "timeout"); op.add(Builder::trackScores, JsonpDeserializer.booleanDeserializer(), "track_scores"); op.add(Builder::trackTotalHits, TrackHits._DESERIALIZER, "track_total_hits"); op.add(Builder::version, JsonpDeserializer.booleanDeserializer(), "version"); } // --------------------------------------------------------------------------------------------- /** * Endpoint "{@code async_search.submit}". */ public static final SimpleEndpoint _ENDPOINT = new SimpleEndpoint<>("es/async_search.submit", // Request method request -> { return "POST"; }, // Request path request -> { final int _index = 1 << 0; int propsSet = 0; if (ApiTypeHelper.isDefined(request.index())) propsSet |= _index; if (propsSet == 0) { StringBuilder buf = new StringBuilder(); buf.append("/_async_search"); return buf.toString(); } if (propsSet == (_index)) { StringBuilder buf = new StringBuilder(); buf.append("/"); SimpleEndpoint.pathEncode(request.index.stream().map(v -> v).collect(Collectors.joining(",")), buf); buf.append("/_async_search"); return buf.toString(); } throw SimpleEndpoint.noPathTemplateFound("path"); }, // Request parameters request -> { Map params = new HashMap<>(); params.put("typed_keys", "true"); if (request.df != null) { params.put("df", request.df); } if (request.preFilterShardSize != null) { params.put("pre_filter_shard_size", String.valueOf(request.preFilterShardSize)); } if (request.minCompatibleShardNode != null) { params.put("min_compatible_shard_node", request.minCompatibleShardNode); } if (request.lenient != null) { params.put("lenient", String.valueOf(request.lenient)); } if (request.routing != null) { params.put("routing", request.routing); } if (request.ignoreUnavailable != null) { params.put("ignore_unavailable", String.valueOf(request.ignoreUnavailable)); } if (request.allowNoIndices != null) { params.put("allow_no_indices", String.valueOf(request.allowNoIndices)); } if (request.analyzer != null) { params.put("analyzer", request.analyzer); } if (request.ignoreThrottled != null) { params.put("ignore_throttled", String.valueOf(request.ignoreThrottled)); } if (request.keepOnCompletion != null) { params.put("keep_on_completion", String.valueOf(request.keepOnCompletion)); } if (request.maxConcurrentShardRequests != null) { params.put("max_concurrent_shard_requests", String.valueOf(request.maxConcurrentShardRequests)); } if (request.allowPartialSearchResults != null) { params.put("allow_partial_search_results", String.valueOf(request.allowPartialSearchResults)); } if (ApiTypeHelper.isDefined(request.expandWildcards)) { params.put("expand_wildcards", request.expandWildcards.stream().map(v -> v.jsonValue()).collect(Collectors.joining(","))); } if (request.preference != null) { params.put("preference", request.preference); } if (request.analyzeWildcard != null) { params.put("analyze_wildcard", String.valueOf(request.analyzeWildcard)); } if (request.scroll != null) { params.put("scroll", request.scroll._toJsonString()); } if (request.waitForCompletionTimeout != null) { params.put("wait_for_completion_timeout", request.waitForCompletionTimeout._toJsonString()); } if (request.searchType != null) { params.put("search_type", request.searchType.jsonValue()); } if (request.ccsMinimizeRoundtrips != null) { params.put("ccs_minimize_roundtrips", String.valueOf(request.ccsMinimizeRoundtrips)); } if (request.q != null) { params.put("q", request.q); } if (request.defaultOperator != null) { params.put("default_operator", request.defaultOperator.jsonValue()); } if (request.keepAlive != null) { params.put("keep_alive", request.keepAlive._toJsonString()); } if (request.requestCache != null) { params.put("request_cache", String.valueOf(request.requestCache)); } if (request.batchedReduceSize != null) { params.put("batched_reduce_size", String.valueOf(request.batchedReduceSize)); } return params; }, SimpleEndpoint.emptyMap(), true, SubmitResponse._DESERIALIZER); /** * Create an "{@code async_search.submit}" endpoint. */ public static Endpoint, ErrorResponse> createSubmitEndpoint( JsonpDeserializer tDocumentDeserializer) { return _ENDPOINT .withResponseDeserializer(SubmitResponse.createSubmitResponseDeserializer(tDocumentDeserializer)); } }
fields
* Adds one or more values to fields. */ public final Builder fields(FieldAndFormat value, FieldAndFormat... values) { this.fields = _listAdd(this.fields, value, values); return this; } /** * Array of wildcard (*) patterns. The request returns values for field names * matching these patterns in the hits.fields property of the response. *
* Adds a value to fields using a builder lambda. */ public final Builder fields(Function> fn) { return fields(fn.apply(new FieldAndFormat.Builder()).build()); } /** * Starting document offset. By default, you cannot page through more than * 10,000 hits using the from and size parameters. To page through more hits, * use the search_after parameter. * * API name: {@code from} */ public final Builder from(@Nullable Integer value) { this.from = value; return this; } /** * API name: {@code highlight} */ public final Builder highlight(@Nullable Highlight value) { this.highlight = value; return this; } /** * API name: {@code highlight} */ public final Builder highlight(Function> fn) { return this.highlight(fn.apply(new Highlight.Builder()).build()); } /** * Whether specified concrete, expanded or aliased indices should be ignored * when throttled * * API name: {@code ignore_throttled} */ public final Builder ignoreThrottled(@Nullable Boolean value) { this.ignoreThrottled = value; return this; } /** * Whether specified concrete indices should be ignored when unavailable * (missing or closed) * * API name: {@code ignore_unavailable} */ public final Builder ignoreUnavailable(@Nullable Boolean value) { this.ignoreUnavailable = value; return this; } /** * A comma-separated list of index names to search; use _all or * empty string to perform the operation on all indices * * API name: {@code index} * * Adds all elements of list to index. */ public final Builder index(List list) { this.index = _listAddAll(this.index, list); return this; } /** * A comma-separated list of index names to search; use _all or * empty string to perform the operation on all indices * * API name: {@code index} * * Adds one or more values to index. */ public final Builder index(String value, String... values) { this.index = _listAdd(this.index, value, values); return this; } /** * Boosts the _score of documents from specified indices. * * API name: {@code indices_boost} * * Adds all elements of list to indicesBoost. */ public final Builder indicesBoost(List> list) { this.indicesBoost = _listAddAll(this.indicesBoost, list); return this; } /** * Boosts the _score of documents from specified indices. * * API name: {@code indices_boost} * * Adds one or more values to indicesBoost. */ public final Builder indicesBoost(Map value, Map... values) { this.indicesBoost = _listAdd(this.indicesBoost, value, values); return this; } /** * Update the time interval in which the results (partial or final) for this * search will be available * * API name: {@code keep_alive} */ public final Builder keepAlive(@Nullable Time value) { this.keepAlive = value; return this; } /** * Update the time interval in which the results (partial or final) for this * search will be available * * API name: {@code keep_alive} */ public final Builder keepAlive(Function> fn) { return this.keepAlive(fn.apply(new Time.Builder()).build()); } /** * Control whether the response should be stored in the cluster if it completed * within the provided [wait_for_completion] time (default: false) * * API name: {@code keep_on_completion} */ public final Builder keepOnCompletion(@Nullable Boolean value) { this.keepOnCompletion = value; return this; } /** * Specify whether format-based query failures (such as providing text to a * numeric field) should be ignored * * API name: {@code lenient} */ public final Builder lenient(@Nullable Boolean value) { this.lenient = value; return this; } /** * The number of concurrent shard requests per node this search executes * concurrently. This value should be used to limit the impact of the search on * the cluster in order to limit the number of concurrent shard requests * * API name: {@code max_concurrent_shard_requests} */ public final Builder maxConcurrentShardRequests(@Nullable Long value) { this.maxConcurrentShardRequests = value; return this; } /** * API name: {@code min_compatible_shard_node} */ public final Builder minCompatibleShardNode(@Nullable String value) { this.minCompatibleShardNode = value; return this; } /** * Minimum _score for matching documents. Documents with a lower _score are not * included in the search results. * * API name: {@code min_score} */ public final Builder minScore(@Nullable Double value) { this.minScore = value; return this; } /** * Limits the search to a point in time (PIT). If you provide a PIT, you cannot * specify an <index> in the request path. * * API name: {@code pit} */ public final Builder pit(@Nullable PointInTimeReference value) { this.pit = value; return this; } /** * Limits the search to a point in time (PIT). If you provide a PIT, you cannot * specify an <index> in the request path. * * API name: {@code pit} */ public final Builder pit(Function> fn) { return this.pit(fn.apply(new PointInTimeReference.Builder()).build()); } /** * API name: {@code post_filter} */ public final Builder postFilter(@Nullable Query value) { this.postFilter = value; return this; } /** * API name: {@code post_filter} */ public final Builder postFilter(Function> fn) { return this.postFilter(fn.apply(new Query.Builder()).build()); } /** * API name: {@code pre_filter_shard_size} */ public final Builder preFilterShardSize(@Nullable Long value) { this.preFilterShardSize = value; return this; } /** * Specify the node or shard the operation should be performed on (default: * random) * * API name: {@code preference} */ public final Builder preference(@Nullable String value) { this.preference = value; return this; } /** * API name: {@code profile} */ public final Builder profile(@Nullable Boolean value) { this.profile = value; return this; } /** * Query in the Lucene query string syntax * * API name: {@code q} */ public final Builder q(@Nullable String value) { this.q = value; return this; } /** * Defines the search definition using the Query DSL. * * API name: {@code query} */ public final Builder query(@Nullable Query value) { this.query = value; return this; } /** * Defines the search definition using the Query DSL. * * API name: {@code query} */ public final Builder query(Function> fn) { return this.query(fn.apply(new Query.Builder()).build()); } /** * Specify if request cache should be used for this request or not, defaults to * true * * API name: {@code request_cache} */ public final Builder requestCache(@Nullable Boolean value) { this.requestCache = value; return this; } /** * API name: {@code rescore} * * Adds all elements of list to rescore. */ public final Builder rescore(List list) { this.rescore = _listAddAll(this.rescore, list); return this; } /** * API name: {@code rescore} * * Adds one or more values to rescore. */ public final Builder rescore(Rescore value, Rescore... values) { this.rescore = _listAdd(this.rescore, value, values); return this; } /** * API name: {@code rescore} * * Adds a value to rescore using a builder lambda. */ public final Builder rescore(Function> fn) { return rescore(fn.apply(new Rescore.Builder()).build()); } /** * A comma-separated list of specific routing values * * API name: {@code routing} */ public final Builder routing(@Nullable String value) { this.routing = value; return this; } /** * Defines one or more runtime fields in the search request. These fields take * precedence over mapped fields with the same name. * * API name: {@code runtime_mappings} * * Adds all entries of map to runtimeMappings. */ public final Builder runtimeMappings(Map> map) { this.runtimeMappings = _mapPutAll(this.runtimeMappings, map); return this; } /** * Defines one or more runtime fields in the search request. These fields take * precedence over mapped fields with the same name. * * API name: {@code runtime_mappings} * * Adds an entry to runtimeMappings. */ public final Builder runtimeMappings(String key, List value) { this.runtimeMappings = _mapPut(this.runtimeMappings, key, value); return this; } /** * Retrieve a script evaluation (based on different fields) for each hit. * * API name: {@code script_fields} * * Adds all entries of map to scriptFields. */ public final Builder scriptFields(Map map) { this.scriptFields = _mapPutAll(this.scriptFields, map); return this; } /** * Retrieve a script evaluation (based on different fields) for each hit. * * API name: {@code script_fields} * * Adds an entry to scriptFields. */ public final Builder scriptFields(String key, ScriptField value) { this.scriptFields = _mapPut(this.scriptFields, key, value); return this; } /** * Retrieve a script evaluation (based on different fields) for each hit. * * API name: {@code script_fields} * * Adds an entry to scriptFields using a builder lambda. */ public final Builder scriptFields(String key, Function> fn) { return scriptFields(key, fn.apply(new ScriptField.Builder()).build()); } /** * API name: {@code scroll} */ public final Builder scroll(@Nullable Time value) { this.scroll = value; return this; } /** * API name: {@code scroll} */ public final Builder scroll(Function> fn) { return this.scroll(fn.apply(new Time.Builder()).build()); } /** * API name: {@code search_after} * * Adds all elements of list to searchAfter. */ public final Builder searchAfter(List list) { this.searchAfter = _listAddAll(this.searchAfter, list); return this; } /** * API name: {@code search_after} * * Adds one or more values to searchAfter. */ public final Builder searchAfter(String value, String... values) { this.searchAfter = _listAdd(this.searchAfter, value, values); return this; } /** * Search operation type * * API name: {@code search_type} */ public final Builder searchType(@Nullable SearchType value) { this.searchType = value; return this; } /** * If true, returns sequence number and primary term of the last modification of * each hit. See Optimistic concurrency control. * * API name: {@code seq_no_primary_term} */ public final Builder seqNoPrimaryTerm(@Nullable Boolean value) { this.seqNoPrimaryTerm = value; return this; } /** * The number of hits to return. By default, you cannot page through more than * 10,000 hits using the from and size parameters. To page through more hits, * use the search_after parameter. * * API name: {@code size} */ public final Builder size(@Nullable Integer value) { this.size = value; return this; } /** * API name: {@code slice} */ public final Builder slice(@Nullable SlicedScroll value) { this.slice = value; return this; } /** * API name: {@code slice} */ public final Builder slice(Function> fn) { return this.slice(fn.apply(new SlicedScroll.Builder()).build()); } /** * API name: {@code sort} * * Adds all elements of list to sort. */ public final Builder sort(List list) { this.sort = _listAddAll(this.sort, list); return this; } /** * API name: {@code sort} * * Adds one or more values to sort. */ public final Builder sort(SortOptions value, SortOptions... values) { this.sort = _listAdd(this.sort, value, values); return this; } /** * API name: {@code sort} * * Adds a value to sort using a builder lambda. */ public final Builder sort(Function> fn) { return sort(fn.apply(new SortOptions.Builder()).build()); } /** * Stats groups to associate with the search. Each group maintains a statistics * aggregation for its associated searches. You can retrieve these stats using * the indices stats API. * * API name: {@code stats} * * Adds all elements of list to stats. */ public final Builder stats(List list) { this.stats = _listAddAll(this.stats, list); return this; } /** * Stats groups to associate with the search. Each group maintains a statistics * aggregation for its associated searches. You can retrieve these stats using * the indices stats API. * * API name: {@code stats} * * Adds one or more values to stats. */ public final Builder stats(String value, String... values) { this.stats = _listAdd(this.stats, value, values); return this; } /** * List of stored fields to return as part of a hit. If no fields are specified, * no stored fields are included in the response. If this field is specified, * the _source parameter defaults to false. You can pass _source: true to return * both source fields and stored fields in the search response. * * API name: {@code stored_fields} * * Adds all elements of list to storedFields. */ public final Builder storedFields(List list) { this.storedFields = _listAddAll(this.storedFields, list); return this; } /** * List of stored fields to return as part of a hit. If no fields are specified, * no stored fields are included in the response. If this field is specified, * the _source parameter defaults to false. You can pass _source: true to return * both source fields and stored fields in the search response. * * API name: {@code stored_fields} * * Adds one or more values to storedFields. */ public final Builder storedFields(String value, String... values) { this.storedFields = _listAdd(this.storedFields, value, values); return this; } /** * API name: {@code suggest} */ public final Builder suggest(@Nullable Suggester value) { this.suggest = value; return this; } /** * API name: {@code suggest} */ public final Builder suggest(Function> fn) { return this.suggest(fn.apply(new Suggester.Builder()).build()); } /** * Maximum number of documents to collect for each shard. If a query reaches * this limit, Elasticsearch terminates the query early. Elasticsearch collects * documents before sorting. Defaults to 0, which does not terminate query * execution early. * * API name: {@code terminate_after} */ public final Builder terminateAfter(@Nullable Long value) { this.terminateAfter = value; return this; } /** * Specifies the period of time to wait for a response from each shard. If no * response is received before the timeout expires, the request fails and * returns an error. Defaults to no timeout. * * API name: {@code timeout} */ public final Builder timeout(@Nullable String value) { this.timeout = value; return this; } /** * If true, calculate and return document scores, even if the scores are not * used for sorting. * * API name: {@code track_scores} */ public final Builder trackScores(@Nullable Boolean value) { this.trackScores = value; return this; } /** * Number of hits matching the query to count accurately. If true, the exact * number of hits is returned at the cost of some performance. If false, the * response does not include the total number of hits matching the query. * Defaults to 10,000 hits. * * API name: {@code track_total_hits} */ public final Builder trackTotalHits(@Nullable TrackHits value) { this.trackTotalHits = value; return this; } /** * Number of hits matching the query to count accurately. If true, the exact * number of hits is returned at the cost of some performance. If false, the * response does not include the total number of hits matching the query. * Defaults to 10,000 hits. * * API name: {@code track_total_hits} */ public final Builder trackTotalHits(Function> fn) { return this.trackTotalHits(fn.apply(new TrackHits.Builder()).build()); } /** * If true, returns document version as part of a hit. * * API name: {@code version} */ public final Builder version(@Nullable Boolean value) { this.version = value; return this; } /** * Specify the time that the request should block waiting for the final response * * API name: {@code wait_for_completion_timeout} */ public final Builder waitForCompletionTimeout(@Nullable Time value) { this.waitForCompletionTimeout = value; return this; } /** * Specify the time that the request should block waiting for the final response * * API name: {@code wait_for_completion_timeout} */ public final Builder waitForCompletionTimeout(Function> fn) { return this.waitForCompletionTimeout(fn.apply(new Time.Builder()).build()); } @Override protected Builder self() { return this; } /** * Builds a {@link SubmitRequest}. * * @throws NullPointerException * if some of the required fields are null. */ public SubmitRequest build() { _checkSingleUse(); return new SubmitRequest(this); } } // --------------------------------------------------------------------------------------------- /** * Json deserializer for {@link SubmitRequest} */ public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy(Builder::new, SubmitRequest::setupSubmitRequestDeserializer); protected static void setupSubmitRequestDeserializer(ObjectDeserializer op) { op.add(Builder::source, SourceConfig._DESERIALIZER, "_source"); op.add(Builder::aggregations, JsonpDeserializer.stringMapDeserializer(Aggregation._DESERIALIZER), "aggregations", "aggs"); op.add(Builder::collapse, FieldCollapse._DESERIALIZER, "collapse"); op.add(Builder::docvalueFields, JsonpDeserializer.arrayDeserializer(FieldAndFormat._DESERIALIZER), "docvalue_fields"); op.add(Builder::explain, JsonpDeserializer.booleanDeserializer(), "explain"); op.add(Builder::fields, JsonpDeserializer.arrayDeserializer(FieldAndFormat._DESERIALIZER), "fields"); op.add(Builder::from, JsonpDeserializer.integerDeserializer(), "from"); op.add(Builder::highlight, Highlight._DESERIALIZER, "highlight"); op.add(Builder::indicesBoost, JsonpDeserializer.arrayDeserializer( JsonpDeserializer.stringMapDeserializer(JsonpDeserializer.doubleDeserializer())), "indices_boost"); op.add(Builder::minScore, JsonpDeserializer.doubleDeserializer(), "min_score"); op.add(Builder::pit, PointInTimeReference._DESERIALIZER, "pit"); op.add(Builder::postFilter, Query._DESERIALIZER, "post_filter"); op.add(Builder::profile, JsonpDeserializer.booleanDeserializer(), "profile"); op.add(Builder::query, Query._DESERIALIZER, "query"); op.add(Builder::rescore, JsonpDeserializer.arrayDeserializer(Rescore._DESERIALIZER), "rescore"); op.add(Builder::runtimeMappings, JsonpDeserializer.stringMapDeserializer( JsonpDeserializer.arrayDeserializer(RuntimeField._DESERIALIZER)), "runtime_mappings"); op.add(Builder::scriptFields, JsonpDeserializer.stringMapDeserializer(ScriptField._DESERIALIZER), "script_fields"); op.add(Builder::searchAfter, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "search_after"); op.add(Builder::seqNoPrimaryTerm, JsonpDeserializer.booleanDeserializer(), "seq_no_primary_term"); op.add(Builder::size, JsonpDeserializer.integerDeserializer(), "size"); op.add(Builder::slice, SlicedScroll._DESERIALIZER, "slice"); op.add(Builder::sort, JsonpDeserializer.arrayDeserializer(SortOptions._DESERIALIZER), "sort"); op.add(Builder::stats, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "stats"); op.add(Builder::storedFields, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "stored_fields"); op.add(Builder::suggest, Suggester._DESERIALIZER, "suggest"); op.add(Builder::terminateAfter, JsonpDeserializer.longDeserializer(), "terminate_after"); op.add(Builder::timeout, JsonpDeserializer.stringDeserializer(), "timeout"); op.add(Builder::trackScores, JsonpDeserializer.booleanDeserializer(), "track_scores"); op.add(Builder::trackTotalHits, TrackHits._DESERIALIZER, "track_total_hits"); op.add(Builder::version, JsonpDeserializer.booleanDeserializer(), "version"); } // --------------------------------------------------------------------------------------------- /** * Endpoint "{@code async_search.submit}". */ public static final SimpleEndpoint _ENDPOINT = new SimpleEndpoint<>("es/async_search.submit", // Request method request -> { return "POST"; }, // Request path request -> { final int _index = 1 << 0; int propsSet = 0; if (ApiTypeHelper.isDefined(request.index())) propsSet |= _index; if (propsSet == 0) { StringBuilder buf = new StringBuilder(); buf.append("/_async_search"); return buf.toString(); } if (propsSet == (_index)) { StringBuilder buf = new StringBuilder(); buf.append("/"); SimpleEndpoint.pathEncode(request.index.stream().map(v -> v).collect(Collectors.joining(",")), buf); buf.append("/_async_search"); return buf.toString(); } throw SimpleEndpoint.noPathTemplateFound("path"); }, // Request parameters request -> { Map params = new HashMap<>(); params.put("typed_keys", "true"); if (request.df != null) { params.put("df", request.df); } if (request.preFilterShardSize != null) { params.put("pre_filter_shard_size", String.valueOf(request.preFilterShardSize)); } if (request.minCompatibleShardNode != null) { params.put("min_compatible_shard_node", request.minCompatibleShardNode); } if (request.lenient != null) { params.put("lenient", String.valueOf(request.lenient)); } if (request.routing != null) { params.put("routing", request.routing); } if (request.ignoreUnavailable != null) { params.put("ignore_unavailable", String.valueOf(request.ignoreUnavailable)); } if (request.allowNoIndices != null) { params.put("allow_no_indices", String.valueOf(request.allowNoIndices)); } if (request.analyzer != null) { params.put("analyzer", request.analyzer); } if (request.ignoreThrottled != null) { params.put("ignore_throttled", String.valueOf(request.ignoreThrottled)); } if (request.keepOnCompletion != null) { params.put("keep_on_completion", String.valueOf(request.keepOnCompletion)); } if (request.maxConcurrentShardRequests != null) { params.put("max_concurrent_shard_requests", String.valueOf(request.maxConcurrentShardRequests)); } if (request.allowPartialSearchResults != null) { params.put("allow_partial_search_results", String.valueOf(request.allowPartialSearchResults)); } if (ApiTypeHelper.isDefined(request.expandWildcards)) { params.put("expand_wildcards", request.expandWildcards.stream().map(v -> v.jsonValue()).collect(Collectors.joining(","))); } if (request.preference != null) { params.put("preference", request.preference); } if (request.analyzeWildcard != null) { params.put("analyze_wildcard", String.valueOf(request.analyzeWildcard)); } if (request.scroll != null) { params.put("scroll", request.scroll._toJsonString()); } if (request.waitForCompletionTimeout != null) { params.put("wait_for_completion_timeout", request.waitForCompletionTimeout._toJsonString()); } if (request.searchType != null) { params.put("search_type", request.searchType.jsonValue()); } if (request.ccsMinimizeRoundtrips != null) { params.put("ccs_minimize_roundtrips", String.valueOf(request.ccsMinimizeRoundtrips)); } if (request.q != null) { params.put("q", request.q); } if (request.defaultOperator != null) { params.put("default_operator", request.defaultOperator.jsonValue()); } if (request.keepAlive != null) { params.put("keep_alive", request.keepAlive._toJsonString()); } if (request.requestCache != null) { params.put("request_cache", String.valueOf(request.requestCache)); } if (request.batchedReduceSize != null) { params.put("batched_reduce_size", String.valueOf(request.batchedReduceSize)); } return params; }, SimpleEndpoint.emptyMap(), true, SubmitResponse._DESERIALIZER); /** * Create an "{@code async_search.submit}" endpoint. */ public static Endpoint, ErrorResponse> createSubmitEndpoint( JsonpDeserializer tDocumentDeserializer) { return _ENDPOINT .withResponseDeserializer(SubmitResponse.createSubmitResponseDeserializer(tDocumentDeserializer)); } }
* API name: {@code from} */ public final Builder from(@Nullable Integer value) { this.from = value; return this; } /** * API name: {@code highlight} */ public final Builder highlight(@Nullable Highlight value) { this.highlight = value; return this; } /** * API name: {@code highlight} */ public final Builder highlight(Function> fn) { return this.highlight(fn.apply(new Highlight.Builder()).build()); } /** * Whether specified concrete, expanded or aliased indices should be ignored * when throttled * * API name: {@code ignore_throttled} */ public final Builder ignoreThrottled(@Nullable Boolean value) { this.ignoreThrottled = value; return this; } /** * Whether specified concrete indices should be ignored when unavailable * (missing or closed) * * API name: {@code ignore_unavailable} */ public final Builder ignoreUnavailable(@Nullable Boolean value) { this.ignoreUnavailable = value; return this; } /** * A comma-separated list of index names to search; use _all or * empty string to perform the operation on all indices * * API name: {@code index} * * Adds all elements of list to index. */ public final Builder index(List list) { this.index = _listAddAll(this.index, list); return this; } /** * A comma-separated list of index names to search; use _all or * empty string to perform the operation on all indices * * API name: {@code index} * * Adds one or more values to index. */ public final Builder index(String value, String... values) { this.index = _listAdd(this.index, value, values); return this; } /** * Boosts the _score of documents from specified indices. * * API name: {@code indices_boost} * * Adds all elements of list to indicesBoost. */ public final Builder indicesBoost(List> list) { this.indicesBoost = _listAddAll(this.indicesBoost, list); return this; } /** * Boosts the _score of documents from specified indices. * * API name: {@code indices_boost} * * Adds one or more values to indicesBoost. */ public final Builder indicesBoost(Map value, Map... values) { this.indicesBoost = _listAdd(this.indicesBoost, value, values); return this; } /** * Update the time interval in which the results (partial or final) for this * search will be available * * API name: {@code keep_alive} */ public final Builder keepAlive(@Nullable Time value) { this.keepAlive = value; return this; } /** * Update the time interval in which the results (partial or final) for this * search will be available * * API name: {@code keep_alive} */ public final Builder keepAlive(Function> fn) { return this.keepAlive(fn.apply(new Time.Builder()).build()); } /** * Control whether the response should be stored in the cluster if it completed * within the provided [wait_for_completion] time (default: false) * * API name: {@code keep_on_completion} */ public final Builder keepOnCompletion(@Nullable Boolean value) { this.keepOnCompletion = value; return this; } /** * Specify whether format-based query failures (such as providing text to a * numeric field) should be ignored * * API name: {@code lenient} */ public final Builder lenient(@Nullable Boolean value) { this.lenient = value; return this; } /** * The number of concurrent shard requests per node this search executes * concurrently. This value should be used to limit the impact of the search on * the cluster in order to limit the number of concurrent shard requests * * API name: {@code max_concurrent_shard_requests} */ public final Builder maxConcurrentShardRequests(@Nullable Long value) { this.maxConcurrentShardRequests = value; return this; } /** * API name: {@code min_compatible_shard_node} */ public final Builder minCompatibleShardNode(@Nullable String value) { this.minCompatibleShardNode = value; return this; } /** * Minimum _score for matching documents. Documents with a lower _score are not * included in the search results. * * API name: {@code min_score} */ public final Builder minScore(@Nullable Double value) { this.minScore = value; return this; } /** * Limits the search to a point in time (PIT). If you provide a PIT, you cannot * specify an <index> in the request path. * * API name: {@code pit} */ public final Builder pit(@Nullable PointInTimeReference value) { this.pit = value; return this; } /** * Limits the search to a point in time (PIT). If you provide a PIT, you cannot * specify an <index> in the request path. * * API name: {@code pit} */ public final Builder pit(Function> fn) { return this.pit(fn.apply(new PointInTimeReference.Builder()).build()); } /** * API name: {@code post_filter} */ public final Builder postFilter(@Nullable Query value) { this.postFilter = value; return this; } /** * API name: {@code post_filter} */ public final Builder postFilter(Function> fn) { return this.postFilter(fn.apply(new Query.Builder()).build()); } /** * API name: {@code pre_filter_shard_size} */ public final Builder preFilterShardSize(@Nullable Long value) { this.preFilterShardSize = value; return this; } /** * Specify the node or shard the operation should be performed on (default: * random) * * API name: {@code preference} */ public final Builder preference(@Nullable String value) { this.preference = value; return this; } /** * API name: {@code profile} */ public final Builder profile(@Nullable Boolean value) { this.profile = value; return this; } /** * Query in the Lucene query string syntax * * API name: {@code q} */ public final Builder q(@Nullable String value) { this.q = value; return this; } /** * Defines the search definition using the Query DSL. * * API name: {@code query} */ public final Builder query(@Nullable Query value) { this.query = value; return this; } /** * Defines the search definition using the Query DSL. * * API name: {@code query} */ public final Builder query(Function> fn) { return this.query(fn.apply(new Query.Builder()).build()); } /** * Specify if request cache should be used for this request or not, defaults to * true * * API name: {@code request_cache} */ public final Builder requestCache(@Nullable Boolean value) { this.requestCache = value; return this; } /** * API name: {@code rescore} * * Adds all elements of list to rescore. */ public final Builder rescore(List list) { this.rescore = _listAddAll(this.rescore, list); return this; } /** * API name: {@code rescore} * * Adds one or more values to rescore. */ public final Builder rescore(Rescore value, Rescore... values) { this.rescore = _listAdd(this.rescore, value, values); return this; } /** * API name: {@code rescore} * * Adds a value to rescore using a builder lambda. */ public final Builder rescore(Function> fn) { return rescore(fn.apply(new Rescore.Builder()).build()); } /** * A comma-separated list of specific routing values * * API name: {@code routing} */ public final Builder routing(@Nullable String value) { this.routing = value; return this; } /** * Defines one or more runtime fields in the search request. These fields take * precedence over mapped fields with the same name. * * API name: {@code runtime_mappings} * * Adds all entries of map to runtimeMappings. */ public final Builder runtimeMappings(Map> map) { this.runtimeMappings = _mapPutAll(this.runtimeMappings, map); return this; } /** * Defines one or more runtime fields in the search request. These fields take * precedence over mapped fields with the same name. * * API name: {@code runtime_mappings} * * Adds an entry to runtimeMappings. */ public final Builder runtimeMappings(String key, List value) { this.runtimeMappings = _mapPut(this.runtimeMappings, key, value); return this; } /** * Retrieve a script evaluation (based on different fields) for each hit. * * API name: {@code script_fields} * * Adds all entries of map to scriptFields. */ public final Builder scriptFields(Map map) { this.scriptFields = _mapPutAll(this.scriptFields, map); return this; } /** * Retrieve a script evaluation (based on different fields) for each hit. * * API name: {@code script_fields} * * Adds an entry to scriptFields. */ public final Builder scriptFields(String key, ScriptField value) { this.scriptFields = _mapPut(this.scriptFields, key, value); return this; } /** * Retrieve a script evaluation (based on different fields) for each hit. * * API name: {@code script_fields} * * Adds an entry to scriptFields using a builder lambda. */ public final Builder scriptFields(String key, Function> fn) { return scriptFields(key, fn.apply(new ScriptField.Builder()).build()); } /** * API name: {@code scroll} */ public final Builder scroll(@Nullable Time value) { this.scroll = value; return this; } /** * API name: {@code scroll} */ public final Builder scroll(Function> fn) { return this.scroll(fn.apply(new Time.Builder()).build()); } /** * API name: {@code search_after} * * Adds all elements of list to searchAfter. */ public final Builder searchAfter(List list) { this.searchAfter = _listAddAll(this.searchAfter, list); return this; } /** * API name: {@code search_after} * * Adds one or more values to searchAfter. */ public final Builder searchAfter(String value, String... values) { this.searchAfter = _listAdd(this.searchAfter, value, values); return this; } /** * Search operation type * * API name: {@code search_type} */ public final Builder searchType(@Nullable SearchType value) { this.searchType = value; return this; } /** * If true, returns sequence number and primary term of the last modification of * each hit. See Optimistic concurrency control. * * API name: {@code seq_no_primary_term} */ public final Builder seqNoPrimaryTerm(@Nullable Boolean value) { this.seqNoPrimaryTerm = value; return this; } /** * The number of hits to return. By default, you cannot page through more than * 10,000 hits using the from and size parameters. To page through more hits, * use the search_after parameter. * * API name: {@code size} */ public final Builder size(@Nullable Integer value) { this.size = value; return this; } /** * API name: {@code slice} */ public final Builder slice(@Nullable SlicedScroll value) { this.slice = value; return this; } /** * API name: {@code slice} */ public final Builder slice(Function> fn) { return this.slice(fn.apply(new SlicedScroll.Builder()).build()); } /** * API name: {@code sort} * * Adds all elements of list to sort. */ public final Builder sort(List list) { this.sort = _listAddAll(this.sort, list); return this; } /** * API name: {@code sort} * * Adds one or more values to sort. */ public final Builder sort(SortOptions value, SortOptions... values) { this.sort = _listAdd(this.sort, value, values); return this; } /** * API name: {@code sort} * * Adds a value to sort using a builder lambda. */ public final Builder sort(Function> fn) { return sort(fn.apply(new SortOptions.Builder()).build()); } /** * Stats groups to associate with the search. Each group maintains a statistics * aggregation for its associated searches. You can retrieve these stats using * the indices stats API. * * API name: {@code stats} * * Adds all elements of list to stats. */ public final Builder stats(List list) { this.stats = _listAddAll(this.stats, list); return this; } /** * Stats groups to associate with the search. Each group maintains a statistics * aggregation for its associated searches. You can retrieve these stats using * the indices stats API. * * API name: {@code stats} * * Adds one or more values to stats. */ public final Builder stats(String value, String... values) { this.stats = _listAdd(this.stats, value, values); return this; } /** * List of stored fields to return as part of a hit. If no fields are specified, * no stored fields are included in the response. If this field is specified, * the _source parameter defaults to false. You can pass _source: true to return * both source fields and stored fields in the search response. * * API name: {@code stored_fields} * * Adds all elements of list to storedFields. */ public final Builder storedFields(List list) { this.storedFields = _listAddAll(this.storedFields, list); return this; } /** * List of stored fields to return as part of a hit. If no fields are specified, * no stored fields are included in the response. If this field is specified, * the _source parameter defaults to false. You can pass _source: true to return * both source fields and stored fields in the search response. * * API name: {@code stored_fields} * * Adds one or more values to storedFields. */ public final Builder storedFields(String value, String... values) { this.storedFields = _listAdd(this.storedFields, value, values); return this; } /** * API name: {@code suggest} */ public final Builder suggest(@Nullable Suggester value) { this.suggest = value; return this; } /** * API name: {@code suggest} */ public final Builder suggest(Function> fn) { return this.suggest(fn.apply(new Suggester.Builder()).build()); } /** * Maximum number of documents to collect for each shard. If a query reaches * this limit, Elasticsearch terminates the query early. Elasticsearch collects * documents before sorting. Defaults to 0, which does not terminate query * execution early. * * API name: {@code terminate_after} */ public final Builder terminateAfter(@Nullable Long value) { this.terminateAfter = value; return this; } /** * Specifies the period of time to wait for a response from each shard. If no * response is received before the timeout expires, the request fails and * returns an error. Defaults to no timeout. * * API name: {@code timeout} */ public final Builder timeout(@Nullable String value) { this.timeout = value; return this; } /** * If true, calculate and return document scores, even if the scores are not * used for sorting. * * API name: {@code track_scores} */ public final Builder trackScores(@Nullable Boolean value) { this.trackScores = value; return this; } /** * Number of hits matching the query to count accurately. If true, the exact * number of hits is returned at the cost of some performance. If false, the * response does not include the total number of hits matching the query. * Defaults to 10,000 hits. * * API name: {@code track_total_hits} */ public final Builder trackTotalHits(@Nullable TrackHits value) { this.trackTotalHits = value; return this; } /** * Number of hits matching the query to count accurately. If true, the exact * number of hits is returned at the cost of some performance. If false, the * response does not include the total number of hits matching the query. * Defaults to 10,000 hits. * * API name: {@code track_total_hits} */ public final Builder trackTotalHits(Function> fn) { return this.trackTotalHits(fn.apply(new TrackHits.Builder()).build()); } /** * If true, returns document version as part of a hit. * * API name: {@code version} */ public final Builder version(@Nullable Boolean value) { this.version = value; return this; } /** * Specify the time that the request should block waiting for the final response * * API name: {@code wait_for_completion_timeout} */ public final Builder waitForCompletionTimeout(@Nullable Time value) { this.waitForCompletionTimeout = value; return this; } /** * Specify the time that the request should block waiting for the final response * * API name: {@code wait_for_completion_timeout} */ public final Builder waitForCompletionTimeout(Function> fn) { return this.waitForCompletionTimeout(fn.apply(new Time.Builder()).build()); } @Override protected Builder self() { return this; } /** * Builds a {@link SubmitRequest}. * * @throws NullPointerException * if some of the required fields are null. */ public SubmitRequest build() { _checkSingleUse(); return new SubmitRequest(this); } } // --------------------------------------------------------------------------------------------- /** * Json deserializer for {@link SubmitRequest} */ public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy(Builder::new, SubmitRequest::setupSubmitRequestDeserializer); protected static void setupSubmitRequestDeserializer(ObjectDeserializer op) { op.add(Builder::source, SourceConfig._DESERIALIZER, "_source"); op.add(Builder::aggregations, JsonpDeserializer.stringMapDeserializer(Aggregation._DESERIALIZER), "aggregations", "aggs"); op.add(Builder::collapse, FieldCollapse._DESERIALIZER, "collapse"); op.add(Builder::docvalueFields, JsonpDeserializer.arrayDeserializer(FieldAndFormat._DESERIALIZER), "docvalue_fields"); op.add(Builder::explain, JsonpDeserializer.booleanDeserializer(), "explain"); op.add(Builder::fields, JsonpDeserializer.arrayDeserializer(FieldAndFormat._DESERIALIZER), "fields"); op.add(Builder::from, JsonpDeserializer.integerDeserializer(), "from"); op.add(Builder::highlight, Highlight._DESERIALIZER, "highlight"); op.add(Builder::indicesBoost, JsonpDeserializer.arrayDeserializer( JsonpDeserializer.stringMapDeserializer(JsonpDeserializer.doubleDeserializer())), "indices_boost"); op.add(Builder::minScore, JsonpDeserializer.doubleDeserializer(), "min_score"); op.add(Builder::pit, PointInTimeReference._DESERIALIZER, "pit"); op.add(Builder::postFilter, Query._DESERIALIZER, "post_filter"); op.add(Builder::profile, JsonpDeserializer.booleanDeserializer(), "profile"); op.add(Builder::query, Query._DESERIALIZER, "query"); op.add(Builder::rescore, JsonpDeserializer.arrayDeserializer(Rescore._DESERIALIZER), "rescore"); op.add(Builder::runtimeMappings, JsonpDeserializer.stringMapDeserializer( JsonpDeserializer.arrayDeserializer(RuntimeField._DESERIALIZER)), "runtime_mappings"); op.add(Builder::scriptFields, JsonpDeserializer.stringMapDeserializer(ScriptField._DESERIALIZER), "script_fields"); op.add(Builder::searchAfter, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "search_after"); op.add(Builder::seqNoPrimaryTerm, JsonpDeserializer.booleanDeserializer(), "seq_no_primary_term"); op.add(Builder::size, JsonpDeserializer.integerDeserializer(), "size"); op.add(Builder::slice, SlicedScroll._DESERIALIZER, "slice"); op.add(Builder::sort, JsonpDeserializer.arrayDeserializer(SortOptions._DESERIALIZER), "sort"); op.add(Builder::stats, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "stats"); op.add(Builder::storedFields, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "stored_fields"); op.add(Builder::suggest, Suggester._DESERIALIZER, "suggest"); op.add(Builder::terminateAfter, JsonpDeserializer.longDeserializer(), "terminate_after"); op.add(Builder::timeout, JsonpDeserializer.stringDeserializer(), "timeout"); op.add(Builder::trackScores, JsonpDeserializer.booleanDeserializer(), "track_scores"); op.add(Builder::trackTotalHits, TrackHits._DESERIALIZER, "track_total_hits"); op.add(Builder::version, JsonpDeserializer.booleanDeserializer(), "version"); } // --------------------------------------------------------------------------------------------- /** * Endpoint "{@code async_search.submit}". */ public static final SimpleEndpoint _ENDPOINT = new SimpleEndpoint<>("es/async_search.submit", // Request method request -> { return "POST"; }, // Request path request -> { final int _index = 1 << 0; int propsSet = 0; if (ApiTypeHelper.isDefined(request.index())) propsSet |= _index; if (propsSet == 0) { StringBuilder buf = new StringBuilder(); buf.append("/_async_search"); return buf.toString(); } if (propsSet == (_index)) { StringBuilder buf = new StringBuilder(); buf.append("/"); SimpleEndpoint.pathEncode(request.index.stream().map(v -> v).collect(Collectors.joining(",")), buf); buf.append("/_async_search"); return buf.toString(); } throw SimpleEndpoint.noPathTemplateFound("path"); }, // Request parameters request -> { Map params = new HashMap<>(); params.put("typed_keys", "true"); if (request.df != null) { params.put("df", request.df); } if (request.preFilterShardSize != null) { params.put("pre_filter_shard_size", String.valueOf(request.preFilterShardSize)); } if (request.minCompatibleShardNode != null) { params.put("min_compatible_shard_node", request.minCompatibleShardNode); } if (request.lenient != null) { params.put("lenient", String.valueOf(request.lenient)); } if (request.routing != null) { params.put("routing", request.routing); } if (request.ignoreUnavailable != null) { params.put("ignore_unavailable", String.valueOf(request.ignoreUnavailable)); } if (request.allowNoIndices != null) { params.put("allow_no_indices", String.valueOf(request.allowNoIndices)); } if (request.analyzer != null) { params.put("analyzer", request.analyzer); } if (request.ignoreThrottled != null) { params.put("ignore_throttled", String.valueOf(request.ignoreThrottled)); } if (request.keepOnCompletion != null) { params.put("keep_on_completion", String.valueOf(request.keepOnCompletion)); } if (request.maxConcurrentShardRequests != null) { params.put("max_concurrent_shard_requests", String.valueOf(request.maxConcurrentShardRequests)); } if (request.allowPartialSearchResults != null) { params.put("allow_partial_search_results", String.valueOf(request.allowPartialSearchResults)); } if (ApiTypeHelper.isDefined(request.expandWildcards)) { params.put("expand_wildcards", request.expandWildcards.stream().map(v -> v.jsonValue()).collect(Collectors.joining(","))); } if (request.preference != null) { params.put("preference", request.preference); } if (request.analyzeWildcard != null) { params.put("analyze_wildcard", String.valueOf(request.analyzeWildcard)); } if (request.scroll != null) { params.put("scroll", request.scroll._toJsonString()); } if (request.waitForCompletionTimeout != null) { params.put("wait_for_completion_timeout", request.waitForCompletionTimeout._toJsonString()); } if (request.searchType != null) { params.put("search_type", request.searchType.jsonValue()); } if (request.ccsMinimizeRoundtrips != null) { params.put("ccs_minimize_roundtrips", String.valueOf(request.ccsMinimizeRoundtrips)); } if (request.q != null) { params.put("q", request.q); } if (request.defaultOperator != null) { params.put("default_operator", request.defaultOperator.jsonValue()); } if (request.keepAlive != null) { params.put("keep_alive", request.keepAlive._toJsonString()); } if (request.requestCache != null) { params.put("request_cache", String.valueOf(request.requestCache)); } if (request.batchedReduceSize != null) { params.put("batched_reduce_size", String.valueOf(request.batchedReduceSize)); } return params; }, SimpleEndpoint.emptyMap(), true, SubmitResponse._DESERIALIZER); /** * Create an "{@code async_search.submit}" endpoint. */ public static Endpoint, ErrorResponse> createSubmitEndpoint( JsonpDeserializer tDocumentDeserializer) { return _ENDPOINT .withResponseDeserializer(SubmitResponse.createSubmitResponseDeserializer(tDocumentDeserializer)); } }
* API name: {@code ignore_throttled} */ public final Builder ignoreThrottled(@Nullable Boolean value) { this.ignoreThrottled = value; return this; } /** * Whether specified concrete indices should be ignored when unavailable * (missing or closed) *
* API name: {@code ignore_unavailable} */ public final Builder ignoreUnavailable(@Nullable Boolean value) { this.ignoreUnavailable = value; return this; } /** * A comma-separated list of index names to search; use _all or * empty string to perform the operation on all indices *
* API name: {@code index} *
* Adds all elements of list to index. */ public final Builder index(List list) { this.index = _listAddAll(this.index, list); return this; } /** * A comma-separated list of index names to search; use _all or * empty string to perform the operation on all indices * * API name: {@code index} * * Adds one or more values to index. */ public final Builder index(String value, String... values) { this.index = _listAdd(this.index, value, values); return this; } /** * Boosts the _score of documents from specified indices. * * API name: {@code indices_boost} * * Adds all elements of list to indicesBoost. */ public final Builder indicesBoost(List> list) { this.indicesBoost = _listAddAll(this.indicesBoost, list); return this; } /** * Boosts the _score of documents from specified indices. * * API name: {@code indices_boost} * * Adds one or more values to indicesBoost. */ public final Builder indicesBoost(Map value, Map... values) { this.indicesBoost = _listAdd(this.indicesBoost, value, values); return this; } /** * Update the time interval in which the results (partial or final) for this * search will be available * * API name: {@code keep_alive} */ public final Builder keepAlive(@Nullable Time value) { this.keepAlive = value; return this; } /** * Update the time interval in which the results (partial or final) for this * search will be available * * API name: {@code keep_alive} */ public final Builder keepAlive(Function> fn) { return this.keepAlive(fn.apply(new Time.Builder()).build()); } /** * Control whether the response should be stored in the cluster if it completed * within the provided [wait_for_completion] time (default: false) * * API name: {@code keep_on_completion} */ public final Builder keepOnCompletion(@Nullable Boolean value) { this.keepOnCompletion = value; return this; } /** * Specify whether format-based query failures (such as providing text to a * numeric field) should be ignored * * API name: {@code lenient} */ public final Builder lenient(@Nullable Boolean value) { this.lenient = value; return this; } /** * The number of concurrent shard requests per node this search executes * concurrently. This value should be used to limit the impact of the search on * the cluster in order to limit the number of concurrent shard requests * * API name: {@code max_concurrent_shard_requests} */ public final Builder maxConcurrentShardRequests(@Nullable Long value) { this.maxConcurrentShardRequests = value; return this; } /** * API name: {@code min_compatible_shard_node} */ public final Builder minCompatibleShardNode(@Nullable String value) { this.minCompatibleShardNode = value; return this; } /** * Minimum _score for matching documents. Documents with a lower _score are not * included in the search results. * * API name: {@code min_score} */ public final Builder minScore(@Nullable Double value) { this.minScore = value; return this; } /** * Limits the search to a point in time (PIT). If you provide a PIT, you cannot * specify an <index> in the request path. * * API name: {@code pit} */ public final Builder pit(@Nullable PointInTimeReference value) { this.pit = value; return this; } /** * Limits the search to a point in time (PIT). If you provide a PIT, you cannot * specify an <index> in the request path. * * API name: {@code pit} */ public final Builder pit(Function> fn) { return this.pit(fn.apply(new PointInTimeReference.Builder()).build()); } /** * API name: {@code post_filter} */ public final Builder postFilter(@Nullable Query value) { this.postFilter = value; return this; } /** * API name: {@code post_filter} */ public final Builder postFilter(Function> fn) { return this.postFilter(fn.apply(new Query.Builder()).build()); } /** * API name: {@code pre_filter_shard_size} */ public final Builder preFilterShardSize(@Nullable Long value) { this.preFilterShardSize = value; return this; } /** * Specify the node or shard the operation should be performed on (default: * random) * * API name: {@code preference} */ public final Builder preference(@Nullable String value) { this.preference = value; return this; } /** * API name: {@code profile} */ public final Builder profile(@Nullable Boolean value) { this.profile = value; return this; } /** * Query in the Lucene query string syntax * * API name: {@code q} */ public final Builder q(@Nullable String value) { this.q = value; return this; } /** * Defines the search definition using the Query DSL. * * API name: {@code query} */ public final Builder query(@Nullable Query value) { this.query = value; return this; } /** * Defines the search definition using the Query DSL. * * API name: {@code query} */ public final Builder query(Function> fn) { return this.query(fn.apply(new Query.Builder()).build()); } /** * Specify if request cache should be used for this request or not, defaults to * true * * API name: {@code request_cache} */ public final Builder requestCache(@Nullable Boolean value) { this.requestCache = value; return this; } /** * API name: {@code rescore} * * Adds all elements of list to rescore. */ public final Builder rescore(List list) { this.rescore = _listAddAll(this.rescore, list); return this; } /** * API name: {@code rescore} * * Adds one or more values to rescore. */ public final Builder rescore(Rescore value, Rescore... values) { this.rescore = _listAdd(this.rescore, value, values); return this; } /** * API name: {@code rescore} * * Adds a value to rescore using a builder lambda. */ public final Builder rescore(Function> fn) { return rescore(fn.apply(new Rescore.Builder()).build()); } /** * A comma-separated list of specific routing values * * API name: {@code routing} */ public final Builder routing(@Nullable String value) { this.routing = value; return this; } /** * Defines one or more runtime fields in the search request. These fields take * precedence over mapped fields with the same name. * * API name: {@code runtime_mappings} * * Adds all entries of map to runtimeMappings. */ public final Builder runtimeMappings(Map> map) { this.runtimeMappings = _mapPutAll(this.runtimeMappings, map); return this; } /** * Defines one or more runtime fields in the search request. These fields take * precedence over mapped fields with the same name. * * API name: {@code runtime_mappings} * * Adds an entry to runtimeMappings. */ public final Builder runtimeMappings(String key, List value) { this.runtimeMappings = _mapPut(this.runtimeMappings, key, value); return this; } /** * Retrieve a script evaluation (based on different fields) for each hit. * * API name: {@code script_fields} * * Adds all entries of map to scriptFields. */ public final Builder scriptFields(Map map) { this.scriptFields = _mapPutAll(this.scriptFields, map); return this; } /** * Retrieve a script evaluation (based on different fields) for each hit. * * API name: {@code script_fields} * * Adds an entry to scriptFields. */ public final Builder scriptFields(String key, ScriptField value) { this.scriptFields = _mapPut(this.scriptFields, key, value); return this; } /** * Retrieve a script evaluation (based on different fields) for each hit. * * API name: {@code script_fields} * * Adds an entry to scriptFields using a builder lambda. */ public final Builder scriptFields(String key, Function> fn) { return scriptFields(key, fn.apply(new ScriptField.Builder()).build()); } /** * API name: {@code scroll} */ public final Builder scroll(@Nullable Time value) { this.scroll = value; return this; } /** * API name: {@code scroll} */ public final Builder scroll(Function> fn) { return this.scroll(fn.apply(new Time.Builder()).build()); } /** * API name: {@code search_after} * * Adds all elements of list to searchAfter. */ public final Builder searchAfter(List list) { this.searchAfter = _listAddAll(this.searchAfter, list); return this; } /** * API name: {@code search_after} * * Adds one or more values to searchAfter. */ public final Builder searchAfter(String value, String... values) { this.searchAfter = _listAdd(this.searchAfter, value, values); return this; } /** * Search operation type * * API name: {@code search_type} */ public final Builder searchType(@Nullable SearchType value) { this.searchType = value; return this; } /** * If true, returns sequence number and primary term of the last modification of * each hit. See Optimistic concurrency control. * * API name: {@code seq_no_primary_term} */ public final Builder seqNoPrimaryTerm(@Nullable Boolean value) { this.seqNoPrimaryTerm = value; return this; } /** * The number of hits to return. By default, you cannot page through more than * 10,000 hits using the from and size parameters. To page through more hits, * use the search_after parameter. * * API name: {@code size} */ public final Builder size(@Nullable Integer value) { this.size = value; return this; } /** * API name: {@code slice} */ public final Builder slice(@Nullable SlicedScroll value) { this.slice = value; return this; } /** * API name: {@code slice} */ public final Builder slice(Function> fn) { return this.slice(fn.apply(new SlicedScroll.Builder()).build()); } /** * API name: {@code sort} * * Adds all elements of list to sort. */ public final Builder sort(List list) { this.sort = _listAddAll(this.sort, list); return this; } /** * API name: {@code sort} * * Adds one or more values to sort. */ public final Builder sort(SortOptions value, SortOptions... values) { this.sort = _listAdd(this.sort, value, values); return this; } /** * API name: {@code sort} * * Adds a value to sort using a builder lambda. */ public final Builder sort(Function> fn) { return sort(fn.apply(new SortOptions.Builder()).build()); } /** * Stats groups to associate with the search. Each group maintains a statistics * aggregation for its associated searches. You can retrieve these stats using * the indices stats API. * * API name: {@code stats} * * Adds all elements of list to stats. */ public final Builder stats(List list) { this.stats = _listAddAll(this.stats, list); return this; } /** * Stats groups to associate with the search. Each group maintains a statistics * aggregation for its associated searches. You can retrieve these stats using * the indices stats API. * * API name: {@code stats} * * Adds one or more values to stats. */ public final Builder stats(String value, String... values) { this.stats = _listAdd(this.stats, value, values); return this; } /** * List of stored fields to return as part of a hit. If no fields are specified, * no stored fields are included in the response. If this field is specified, * the _source parameter defaults to false. You can pass _source: true to return * both source fields and stored fields in the search response. * * API name: {@code stored_fields} * * Adds all elements of list to storedFields. */ public final Builder storedFields(List list) { this.storedFields = _listAddAll(this.storedFields, list); return this; } /** * List of stored fields to return as part of a hit. If no fields are specified, * no stored fields are included in the response. If this field is specified, * the _source parameter defaults to false. You can pass _source: true to return * both source fields and stored fields in the search response. * * API name: {@code stored_fields} * * Adds one or more values to storedFields. */ public final Builder storedFields(String value, String... values) { this.storedFields = _listAdd(this.storedFields, value, values); return this; } /** * API name: {@code suggest} */ public final Builder suggest(@Nullable Suggester value) { this.suggest = value; return this; } /** * API name: {@code suggest} */ public final Builder suggest(Function> fn) { return this.suggest(fn.apply(new Suggester.Builder()).build()); } /** * Maximum number of documents to collect for each shard. If a query reaches * this limit, Elasticsearch terminates the query early. Elasticsearch collects * documents before sorting. Defaults to 0, which does not terminate query * execution early. * * API name: {@code terminate_after} */ public final Builder terminateAfter(@Nullable Long value) { this.terminateAfter = value; return this; } /** * Specifies the period of time to wait for a response from each shard. If no * response is received before the timeout expires, the request fails and * returns an error. Defaults to no timeout. * * API name: {@code timeout} */ public final Builder timeout(@Nullable String value) { this.timeout = value; return this; } /** * If true, calculate and return document scores, even if the scores are not * used for sorting. * * API name: {@code track_scores} */ public final Builder trackScores(@Nullable Boolean value) { this.trackScores = value; return this; } /** * Number of hits matching the query to count accurately. If true, the exact * number of hits is returned at the cost of some performance. If false, the * response does not include the total number of hits matching the query. * Defaults to 10,000 hits. * * API name: {@code track_total_hits} */ public final Builder trackTotalHits(@Nullable TrackHits value) { this.trackTotalHits = value; return this; } /** * Number of hits matching the query to count accurately. If true, the exact * number of hits is returned at the cost of some performance. If false, the * response does not include the total number of hits matching the query. * Defaults to 10,000 hits. * * API name: {@code track_total_hits} */ public final Builder trackTotalHits(Function> fn) { return this.trackTotalHits(fn.apply(new TrackHits.Builder()).build()); } /** * If true, returns document version as part of a hit. * * API name: {@code version} */ public final Builder version(@Nullable Boolean value) { this.version = value; return this; } /** * Specify the time that the request should block waiting for the final response * * API name: {@code wait_for_completion_timeout} */ public final Builder waitForCompletionTimeout(@Nullable Time value) { this.waitForCompletionTimeout = value; return this; } /** * Specify the time that the request should block waiting for the final response * * API name: {@code wait_for_completion_timeout} */ public final Builder waitForCompletionTimeout(Function> fn) { return this.waitForCompletionTimeout(fn.apply(new Time.Builder()).build()); } @Override protected Builder self() { return this; } /** * Builds a {@link SubmitRequest}. * * @throws NullPointerException * if some of the required fields are null. */ public SubmitRequest build() { _checkSingleUse(); return new SubmitRequest(this); } } // --------------------------------------------------------------------------------------------- /** * Json deserializer for {@link SubmitRequest} */ public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy(Builder::new, SubmitRequest::setupSubmitRequestDeserializer); protected static void setupSubmitRequestDeserializer(ObjectDeserializer op) { op.add(Builder::source, SourceConfig._DESERIALIZER, "_source"); op.add(Builder::aggregations, JsonpDeserializer.stringMapDeserializer(Aggregation._DESERIALIZER), "aggregations", "aggs"); op.add(Builder::collapse, FieldCollapse._DESERIALIZER, "collapse"); op.add(Builder::docvalueFields, JsonpDeserializer.arrayDeserializer(FieldAndFormat._DESERIALIZER), "docvalue_fields"); op.add(Builder::explain, JsonpDeserializer.booleanDeserializer(), "explain"); op.add(Builder::fields, JsonpDeserializer.arrayDeserializer(FieldAndFormat._DESERIALIZER), "fields"); op.add(Builder::from, JsonpDeserializer.integerDeserializer(), "from"); op.add(Builder::highlight, Highlight._DESERIALIZER, "highlight"); op.add(Builder::indicesBoost, JsonpDeserializer.arrayDeserializer( JsonpDeserializer.stringMapDeserializer(JsonpDeserializer.doubleDeserializer())), "indices_boost"); op.add(Builder::minScore, JsonpDeserializer.doubleDeserializer(), "min_score"); op.add(Builder::pit, PointInTimeReference._DESERIALIZER, "pit"); op.add(Builder::postFilter, Query._DESERIALIZER, "post_filter"); op.add(Builder::profile, JsonpDeserializer.booleanDeserializer(), "profile"); op.add(Builder::query, Query._DESERIALIZER, "query"); op.add(Builder::rescore, JsonpDeserializer.arrayDeserializer(Rescore._DESERIALIZER), "rescore"); op.add(Builder::runtimeMappings, JsonpDeserializer.stringMapDeserializer( JsonpDeserializer.arrayDeserializer(RuntimeField._DESERIALIZER)), "runtime_mappings"); op.add(Builder::scriptFields, JsonpDeserializer.stringMapDeserializer(ScriptField._DESERIALIZER), "script_fields"); op.add(Builder::searchAfter, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "search_after"); op.add(Builder::seqNoPrimaryTerm, JsonpDeserializer.booleanDeserializer(), "seq_no_primary_term"); op.add(Builder::size, JsonpDeserializer.integerDeserializer(), "size"); op.add(Builder::slice, SlicedScroll._DESERIALIZER, "slice"); op.add(Builder::sort, JsonpDeserializer.arrayDeserializer(SortOptions._DESERIALIZER), "sort"); op.add(Builder::stats, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "stats"); op.add(Builder::storedFields, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "stored_fields"); op.add(Builder::suggest, Suggester._DESERIALIZER, "suggest"); op.add(Builder::terminateAfter, JsonpDeserializer.longDeserializer(), "terminate_after"); op.add(Builder::timeout, JsonpDeserializer.stringDeserializer(), "timeout"); op.add(Builder::trackScores, JsonpDeserializer.booleanDeserializer(), "track_scores"); op.add(Builder::trackTotalHits, TrackHits._DESERIALIZER, "track_total_hits"); op.add(Builder::version, JsonpDeserializer.booleanDeserializer(), "version"); } // --------------------------------------------------------------------------------------------- /** * Endpoint "{@code async_search.submit}". */ public static final SimpleEndpoint _ENDPOINT = new SimpleEndpoint<>("es/async_search.submit", // Request method request -> { return "POST"; }, // Request path request -> { final int _index = 1 << 0; int propsSet = 0; if (ApiTypeHelper.isDefined(request.index())) propsSet |= _index; if (propsSet == 0) { StringBuilder buf = new StringBuilder(); buf.append("/_async_search"); return buf.toString(); } if (propsSet == (_index)) { StringBuilder buf = new StringBuilder(); buf.append("/"); SimpleEndpoint.pathEncode(request.index.stream().map(v -> v).collect(Collectors.joining(",")), buf); buf.append("/_async_search"); return buf.toString(); } throw SimpleEndpoint.noPathTemplateFound("path"); }, // Request parameters request -> { Map params = new HashMap<>(); params.put("typed_keys", "true"); if (request.df != null) { params.put("df", request.df); } if (request.preFilterShardSize != null) { params.put("pre_filter_shard_size", String.valueOf(request.preFilterShardSize)); } if (request.minCompatibleShardNode != null) { params.put("min_compatible_shard_node", request.minCompatibleShardNode); } if (request.lenient != null) { params.put("lenient", String.valueOf(request.lenient)); } if (request.routing != null) { params.put("routing", request.routing); } if (request.ignoreUnavailable != null) { params.put("ignore_unavailable", String.valueOf(request.ignoreUnavailable)); } if (request.allowNoIndices != null) { params.put("allow_no_indices", String.valueOf(request.allowNoIndices)); } if (request.analyzer != null) { params.put("analyzer", request.analyzer); } if (request.ignoreThrottled != null) { params.put("ignore_throttled", String.valueOf(request.ignoreThrottled)); } if (request.keepOnCompletion != null) { params.put("keep_on_completion", String.valueOf(request.keepOnCompletion)); } if (request.maxConcurrentShardRequests != null) { params.put("max_concurrent_shard_requests", String.valueOf(request.maxConcurrentShardRequests)); } if (request.allowPartialSearchResults != null) { params.put("allow_partial_search_results", String.valueOf(request.allowPartialSearchResults)); } if (ApiTypeHelper.isDefined(request.expandWildcards)) { params.put("expand_wildcards", request.expandWildcards.stream().map(v -> v.jsonValue()).collect(Collectors.joining(","))); } if (request.preference != null) { params.put("preference", request.preference); } if (request.analyzeWildcard != null) { params.put("analyze_wildcard", String.valueOf(request.analyzeWildcard)); } if (request.scroll != null) { params.put("scroll", request.scroll._toJsonString()); } if (request.waitForCompletionTimeout != null) { params.put("wait_for_completion_timeout", request.waitForCompletionTimeout._toJsonString()); } if (request.searchType != null) { params.put("search_type", request.searchType.jsonValue()); } if (request.ccsMinimizeRoundtrips != null) { params.put("ccs_minimize_roundtrips", String.valueOf(request.ccsMinimizeRoundtrips)); } if (request.q != null) { params.put("q", request.q); } if (request.defaultOperator != null) { params.put("default_operator", request.defaultOperator.jsonValue()); } if (request.keepAlive != null) { params.put("keep_alive", request.keepAlive._toJsonString()); } if (request.requestCache != null) { params.put("request_cache", String.valueOf(request.requestCache)); } if (request.batchedReduceSize != null) { params.put("batched_reduce_size", String.valueOf(request.batchedReduceSize)); } return params; }, SimpleEndpoint.emptyMap(), true, SubmitResponse._DESERIALIZER); /** * Create an "{@code async_search.submit}" endpoint. */ public static Endpoint, ErrorResponse> createSubmitEndpoint( JsonpDeserializer tDocumentDeserializer) { return _ENDPOINT .withResponseDeserializer(SubmitResponse.createSubmitResponseDeserializer(tDocumentDeserializer)); } }
index
* Adds one or more values to index. */ public final Builder index(String value, String... values) { this.index = _listAdd(this.index, value, values); return this; } /** * Boosts the _score of documents from specified indices. *
* API name: {@code indices_boost} *
* Adds all elements of list to indicesBoost. */ public final Builder indicesBoost(List> list) { this.indicesBoost = _listAddAll(this.indicesBoost, list); return this; } /** * Boosts the _score of documents from specified indices. * * API name: {@code indices_boost} * * Adds one or more values to indicesBoost. */ public final Builder indicesBoost(Map value, Map... values) { this.indicesBoost = _listAdd(this.indicesBoost, value, values); return this; } /** * Update the time interval in which the results (partial or final) for this * search will be available * * API name: {@code keep_alive} */ public final Builder keepAlive(@Nullable Time value) { this.keepAlive = value; return this; } /** * Update the time interval in which the results (partial or final) for this * search will be available * * API name: {@code keep_alive} */ public final Builder keepAlive(Function> fn) { return this.keepAlive(fn.apply(new Time.Builder()).build()); } /** * Control whether the response should be stored in the cluster if it completed * within the provided [wait_for_completion] time (default: false) * * API name: {@code keep_on_completion} */ public final Builder keepOnCompletion(@Nullable Boolean value) { this.keepOnCompletion = value; return this; } /** * Specify whether format-based query failures (such as providing text to a * numeric field) should be ignored * * API name: {@code lenient} */ public final Builder lenient(@Nullable Boolean value) { this.lenient = value; return this; } /** * The number of concurrent shard requests per node this search executes * concurrently. This value should be used to limit the impact of the search on * the cluster in order to limit the number of concurrent shard requests * * API name: {@code max_concurrent_shard_requests} */ public final Builder maxConcurrentShardRequests(@Nullable Long value) { this.maxConcurrentShardRequests = value; return this; } /** * API name: {@code min_compatible_shard_node} */ public final Builder minCompatibleShardNode(@Nullable String value) { this.minCompatibleShardNode = value; return this; } /** * Minimum _score for matching documents. Documents with a lower _score are not * included in the search results. * * API name: {@code min_score} */ public final Builder minScore(@Nullable Double value) { this.minScore = value; return this; } /** * Limits the search to a point in time (PIT). If you provide a PIT, you cannot * specify an <index> in the request path. * * API name: {@code pit} */ public final Builder pit(@Nullable PointInTimeReference value) { this.pit = value; return this; } /** * Limits the search to a point in time (PIT). If you provide a PIT, you cannot * specify an <index> in the request path. * * API name: {@code pit} */ public final Builder pit(Function> fn) { return this.pit(fn.apply(new PointInTimeReference.Builder()).build()); } /** * API name: {@code post_filter} */ public final Builder postFilter(@Nullable Query value) { this.postFilter = value; return this; } /** * API name: {@code post_filter} */ public final Builder postFilter(Function> fn) { return this.postFilter(fn.apply(new Query.Builder()).build()); } /** * API name: {@code pre_filter_shard_size} */ public final Builder preFilterShardSize(@Nullable Long value) { this.preFilterShardSize = value; return this; } /** * Specify the node or shard the operation should be performed on (default: * random) * * API name: {@code preference} */ public final Builder preference(@Nullable String value) { this.preference = value; return this; } /** * API name: {@code profile} */ public final Builder profile(@Nullable Boolean value) { this.profile = value; return this; } /** * Query in the Lucene query string syntax * * API name: {@code q} */ public final Builder q(@Nullable String value) { this.q = value; return this; } /** * Defines the search definition using the Query DSL. * * API name: {@code query} */ public final Builder query(@Nullable Query value) { this.query = value; return this; } /** * Defines the search definition using the Query DSL. * * API name: {@code query} */ public final Builder query(Function> fn) { return this.query(fn.apply(new Query.Builder()).build()); } /** * Specify if request cache should be used for this request or not, defaults to * true * * API name: {@code request_cache} */ public final Builder requestCache(@Nullable Boolean value) { this.requestCache = value; return this; } /** * API name: {@code rescore} * * Adds all elements of list to rescore. */ public final Builder rescore(List list) { this.rescore = _listAddAll(this.rescore, list); return this; } /** * API name: {@code rescore} * * Adds one or more values to rescore. */ public final Builder rescore(Rescore value, Rescore... values) { this.rescore = _listAdd(this.rescore, value, values); return this; } /** * API name: {@code rescore} * * Adds a value to rescore using a builder lambda. */ public final Builder rescore(Function> fn) { return rescore(fn.apply(new Rescore.Builder()).build()); } /** * A comma-separated list of specific routing values * * API name: {@code routing} */ public final Builder routing(@Nullable String value) { this.routing = value; return this; } /** * Defines one or more runtime fields in the search request. These fields take * precedence over mapped fields with the same name. * * API name: {@code runtime_mappings} * * Adds all entries of map to runtimeMappings. */ public final Builder runtimeMappings(Map> map) { this.runtimeMappings = _mapPutAll(this.runtimeMappings, map); return this; } /** * Defines one or more runtime fields in the search request. These fields take * precedence over mapped fields with the same name. * * API name: {@code runtime_mappings} * * Adds an entry to runtimeMappings. */ public final Builder runtimeMappings(String key, List value) { this.runtimeMappings = _mapPut(this.runtimeMappings, key, value); return this; } /** * Retrieve a script evaluation (based on different fields) for each hit. * * API name: {@code script_fields} * * Adds all entries of map to scriptFields. */ public final Builder scriptFields(Map map) { this.scriptFields = _mapPutAll(this.scriptFields, map); return this; } /** * Retrieve a script evaluation (based on different fields) for each hit. * * API name: {@code script_fields} * * Adds an entry to scriptFields. */ public final Builder scriptFields(String key, ScriptField value) { this.scriptFields = _mapPut(this.scriptFields, key, value); return this; } /** * Retrieve a script evaluation (based on different fields) for each hit. * * API name: {@code script_fields} * * Adds an entry to scriptFields using a builder lambda. */ public final Builder scriptFields(String key, Function> fn) { return scriptFields(key, fn.apply(new ScriptField.Builder()).build()); } /** * API name: {@code scroll} */ public final Builder scroll(@Nullable Time value) { this.scroll = value; return this; } /** * API name: {@code scroll} */ public final Builder scroll(Function> fn) { return this.scroll(fn.apply(new Time.Builder()).build()); } /** * API name: {@code search_after} * * Adds all elements of list to searchAfter. */ public final Builder searchAfter(List list) { this.searchAfter = _listAddAll(this.searchAfter, list); return this; } /** * API name: {@code search_after} * * Adds one or more values to searchAfter. */ public final Builder searchAfter(String value, String... values) { this.searchAfter = _listAdd(this.searchAfter, value, values); return this; } /** * Search operation type * * API name: {@code search_type} */ public final Builder searchType(@Nullable SearchType value) { this.searchType = value; return this; } /** * If true, returns sequence number and primary term of the last modification of * each hit. See Optimistic concurrency control. * * API name: {@code seq_no_primary_term} */ public final Builder seqNoPrimaryTerm(@Nullable Boolean value) { this.seqNoPrimaryTerm = value; return this; } /** * The number of hits to return. By default, you cannot page through more than * 10,000 hits using the from and size parameters. To page through more hits, * use the search_after parameter. * * API name: {@code size} */ public final Builder size(@Nullable Integer value) { this.size = value; return this; } /** * API name: {@code slice} */ public final Builder slice(@Nullable SlicedScroll value) { this.slice = value; return this; } /** * API name: {@code slice} */ public final Builder slice(Function> fn) { return this.slice(fn.apply(new SlicedScroll.Builder()).build()); } /** * API name: {@code sort} * * Adds all elements of list to sort. */ public final Builder sort(List list) { this.sort = _listAddAll(this.sort, list); return this; } /** * API name: {@code sort} * * Adds one or more values to sort. */ public final Builder sort(SortOptions value, SortOptions... values) { this.sort = _listAdd(this.sort, value, values); return this; } /** * API name: {@code sort} * * Adds a value to sort using a builder lambda. */ public final Builder sort(Function> fn) { return sort(fn.apply(new SortOptions.Builder()).build()); } /** * Stats groups to associate with the search. Each group maintains a statistics * aggregation for its associated searches. You can retrieve these stats using * the indices stats API. * * API name: {@code stats} * * Adds all elements of list to stats. */ public final Builder stats(List list) { this.stats = _listAddAll(this.stats, list); return this; } /** * Stats groups to associate with the search. Each group maintains a statistics * aggregation for its associated searches. You can retrieve these stats using * the indices stats API. * * API name: {@code stats} * * Adds one or more values to stats. */ public final Builder stats(String value, String... values) { this.stats = _listAdd(this.stats, value, values); return this; } /** * List of stored fields to return as part of a hit. If no fields are specified, * no stored fields are included in the response. If this field is specified, * the _source parameter defaults to false. You can pass _source: true to return * both source fields and stored fields in the search response. * * API name: {@code stored_fields} * * Adds all elements of list to storedFields. */ public final Builder storedFields(List list) { this.storedFields = _listAddAll(this.storedFields, list); return this; } /** * List of stored fields to return as part of a hit. If no fields are specified, * no stored fields are included in the response. If this field is specified, * the _source parameter defaults to false. You can pass _source: true to return * both source fields and stored fields in the search response. * * API name: {@code stored_fields} * * Adds one or more values to storedFields. */ public final Builder storedFields(String value, String... values) { this.storedFields = _listAdd(this.storedFields, value, values); return this; } /** * API name: {@code suggest} */ public final Builder suggest(@Nullable Suggester value) { this.suggest = value; return this; } /** * API name: {@code suggest} */ public final Builder suggest(Function> fn) { return this.suggest(fn.apply(new Suggester.Builder()).build()); } /** * Maximum number of documents to collect for each shard. If a query reaches * this limit, Elasticsearch terminates the query early. Elasticsearch collects * documents before sorting. Defaults to 0, which does not terminate query * execution early. * * API name: {@code terminate_after} */ public final Builder terminateAfter(@Nullable Long value) { this.terminateAfter = value; return this; } /** * Specifies the period of time to wait for a response from each shard. If no * response is received before the timeout expires, the request fails and * returns an error. Defaults to no timeout. * * API name: {@code timeout} */ public final Builder timeout(@Nullable String value) { this.timeout = value; return this; } /** * If true, calculate and return document scores, even if the scores are not * used for sorting. * * API name: {@code track_scores} */ public final Builder trackScores(@Nullable Boolean value) { this.trackScores = value; return this; } /** * Number of hits matching the query to count accurately. If true, the exact * number of hits is returned at the cost of some performance. If false, the * response does not include the total number of hits matching the query. * Defaults to 10,000 hits. * * API name: {@code track_total_hits} */ public final Builder trackTotalHits(@Nullable TrackHits value) { this.trackTotalHits = value; return this; } /** * Number of hits matching the query to count accurately. If true, the exact * number of hits is returned at the cost of some performance. If false, the * response does not include the total number of hits matching the query. * Defaults to 10,000 hits. * * API name: {@code track_total_hits} */ public final Builder trackTotalHits(Function> fn) { return this.trackTotalHits(fn.apply(new TrackHits.Builder()).build()); } /** * If true, returns document version as part of a hit. * * API name: {@code version} */ public final Builder version(@Nullable Boolean value) { this.version = value; return this; } /** * Specify the time that the request should block waiting for the final response * * API name: {@code wait_for_completion_timeout} */ public final Builder waitForCompletionTimeout(@Nullable Time value) { this.waitForCompletionTimeout = value; return this; } /** * Specify the time that the request should block waiting for the final response * * API name: {@code wait_for_completion_timeout} */ public final Builder waitForCompletionTimeout(Function> fn) { return this.waitForCompletionTimeout(fn.apply(new Time.Builder()).build()); } @Override protected Builder self() { return this; } /** * Builds a {@link SubmitRequest}. * * @throws NullPointerException * if some of the required fields are null. */ public SubmitRequest build() { _checkSingleUse(); return new SubmitRequest(this); } } // --------------------------------------------------------------------------------------------- /** * Json deserializer for {@link SubmitRequest} */ public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy(Builder::new, SubmitRequest::setupSubmitRequestDeserializer); protected static void setupSubmitRequestDeserializer(ObjectDeserializer op) { op.add(Builder::source, SourceConfig._DESERIALIZER, "_source"); op.add(Builder::aggregations, JsonpDeserializer.stringMapDeserializer(Aggregation._DESERIALIZER), "aggregations", "aggs"); op.add(Builder::collapse, FieldCollapse._DESERIALIZER, "collapse"); op.add(Builder::docvalueFields, JsonpDeserializer.arrayDeserializer(FieldAndFormat._DESERIALIZER), "docvalue_fields"); op.add(Builder::explain, JsonpDeserializer.booleanDeserializer(), "explain"); op.add(Builder::fields, JsonpDeserializer.arrayDeserializer(FieldAndFormat._DESERIALIZER), "fields"); op.add(Builder::from, JsonpDeserializer.integerDeserializer(), "from"); op.add(Builder::highlight, Highlight._DESERIALIZER, "highlight"); op.add(Builder::indicesBoost, JsonpDeserializer.arrayDeserializer( JsonpDeserializer.stringMapDeserializer(JsonpDeserializer.doubleDeserializer())), "indices_boost"); op.add(Builder::minScore, JsonpDeserializer.doubleDeserializer(), "min_score"); op.add(Builder::pit, PointInTimeReference._DESERIALIZER, "pit"); op.add(Builder::postFilter, Query._DESERIALIZER, "post_filter"); op.add(Builder::profile, JsonpDeserializer.booleanDeserializer(), "profile"); op.add(Builder::query, Query._DESERIALIZER, "query"); op.add(Builder::rescore, JsonpDeserializer.arrayDeserializer(Rescore._DESERIALIZER), "rescore"); op.add(Builder::runtimeMappings, JsonpDeserializer.stringMapDeserializer( JsonpDeserializer.arrayDeserializer(RuntimeField._DESERIALIZER)), "runtime_mappings"); op.add(Builder::scriptFields, JsonpDeserializer.stringMapDeserializer(ScriptField._DESERIALIZER), "script_fields"); op.add(Builder::searchAfter, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "search_after"); op.add(Builder::seqNoPrimaryTerm, JsonpDeserializer.booleanDeserializer(), "seq_no_primary_term"); op.add(Builder::size, JsonpDeserializer.integerDeserializer(), "size"); op.add(Builder::slice, SlicedScroll._DESERIALIZER, "slice"); op.add(Builder::sort, JsonpDeserializer.arrayDeserializer(SortOptions._DESERIALIZER), "sort"); op.add(Builder::stats, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "stats"); op.add(Builder::storedFields, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "stored_fields"); op.add(Builder::suggest, Suggester._DESERIALIZER, "suggest"); op.add(Builder::terminateAfter, JsonpDeserializer.longDeserializer(), "terminate_after"); op.add(Builder::timeout, JsonpDeserializer.stringDeserializer(), "timeout"); op.add(Builder::trackScores, JsonpDeserializer.booleanDeserializer(), "track_scores"); op.add(Builder::trackTotalHits, TrackHits._DESERIALIZER, "track_total_hits"); op.add(Builder::version, JsonpDeserializer.booleanDeserializer(), "version"); } // --------------------------------------------------------------------------------------------- /** * Endpoint "{@code async_search.submit}". */ public static final SimpleEndpoint _ENDPOINT = new SimpleEndpoint<>("es/async_search.submit", // Request method request -> { return "POST"; }, // Request path request -> { final int _index = 1 << 0; int propsSet = 0; if (ApiTypeHelper.isDefined(request.index())) propsSet |= _index; if (propsSet == 0) { StringBuilder buf = new StringBuilder(); buf.append("/_async_search"); return buf.toString(); } if (propsSet == (_index)) { StringBuilder buf = new StringBuilder(); buf.append("/"); SimpleEndpoint.pathEncode(request.index.stream().map(v -> v).collect(Collectors.joining(",")), buf); buf.append("/_async_search"); return buf.toString(); } throw SimpleEndpoint.noPathTemplateFound("path"); }, // Request parameters request -> { Map params = new HashMap<>(); params.put("typed_keys", "true"); if (request.df != null) { params.put("df", request.df); } if (request.preFilterShardSize != null) { params.put("pre_filter_shard_size", String.valueOf(request.preFilterShardSize)); } if (request.minCompatibleShardNode != null) { params.put("min_compatible_shard_node", request.minCompatibleShardNode); } if (request.lenient != null) { params.put("lenient", String.valueOf(request.lenient)); } if (request.routing != null) { params.put("routing", request.routing); } if (request.ignoreUnavailable != null) { params.put("ignore_unavailable", String.valueOf(request.ignoreUnavailable)); } if (request.allowNoIndices != null) { params.put("allow_no_indices", String.valueOf(request.allowNoIndices)); } if (request.analyzer != null) { params.put("analyzer", request.analyzer); } if (request.ignoreThrottled != null) { params.put("ignore_throttled", String.valueOf(request.ignoreThrottled)); } if (request.keepOnCompletion != null) { params.put("keep_on_completion", String.valueOf(request.keepOnCompletion)); } if (request.maxConcurrentShardRequests != null) { params.put("max_concurrent_shard_requests", String.valueOf(request.maxConcurrentShardRequests)); } if (request.allowPartialSearchResults != null) { params.put("allow_partial_search_results", String.valueOf(request.allowPartialSearchResults)); } if (ApiTypeHelper.isDefined(request.expandWildcards)) { params.put("expand_wildcards", request.expandWildcards.stream().map(v -> v.jsonValue()).collect(Collectors.joining(","))); } if (request.preference != null) { params.put("preference", request.preference); } if (request.analyzeWildcard != null) { params.put("analyze_wildcard", String.valueOf(request.analyzeWildcard)); } if (request.scroll != null) { params.put("scroll", request.scroll._toJsonString()); } if (request.waitForCompletionTimeout != null) { params.put("wait_for_completion_timeout", request.waitForCompletionTimeout._toJsonString()); } if (request.searchType != null) { params.put("search_type", request.searchType.jsonValue()); } if (request.ccsMinimizeRoundtrips != null) { params.put("ccs_minimize_roundtrips", String.valueOf(request.ccsMinimizeRoundtrips)); } if (request.q != null) { params.put("q", request.q); } if (request.defaultOperator != null) { params.put("default_operator", request.defaultOperator.jsonValue()); } if (request.keepAlive != null) { params.put("keep_alive", request.keepAlive._toJsonString()); } if (request.requestCache != null) { params.put("request_cache", String.valueOf(request.requestCache)); } if (request.batchedReduceSize != null) { params.put("batched_reduce_size", String.valueOf(request.batchedReduceSize)); } return params; }, SimpleEndpoint.emptyMap(), true, SubmitResponse._DESERIALIZER); /** * Create an "{@code async_search.submit}" endpoint. */ public static Endpoint, ErrorResponse> createSubmitEndpoint( JsonpDeserializer tDocumentDeserializer) { return _ENDPOINT .withResponseDeserializer(SubmitResponse.createSubmitResponseDeserializer(tDocumentDeserializer)); } }
indicesBoost
* Adds one or more values to indicesBoost. */ public final Builder indicesBoost(Map value, Map... values) { this.indicesBoost = _listAdd(this.indicesBoost, value, values); return this; } /** * Update the time interval in which the results (partial or final) for this * search will be available * * API name: {@code keep_alive} */ public final Builder keepAlive(@Nullable Time value) { this.keepAlive = value; return this; } /** * Update the time interval in which the results (partial or final) for this * search will be available * * API name: {@code keep_alive} */ public final Builder keepAlive(Function> fn) { return this.keepAlive(fn.apply(new Time.Builder()).build()); } /** * Control whether the response should be stored in the cluster if it completed * within the provided [wait_for_completion] time (default: false) * * API name: {@code keep_on_completion} */ public final Builder keepOnCompletion(@Nullable Boolean value) { this.keepOnCompletion = value; return this; } /** * Specify whether format-based query failures (such as providing text to a * numeric field) should be ignored * * API name: {@code lenient} */ public final Builder lenient(@Nullable Boolean value) { this.lenient = value; return this; } /** * The number of concurrent shard requests per node this search executes * concurrently. This value should be used to limit the impact of the search on * the cluster in order to limit the number of concurrent shard requests * * API name: {@code max_concurrent_shard_requests} */ public final Builder maxConcurrentShardRequests(@Nullable Long value) { this.maxConcurrentShardRequests = value; return this; } /** * API name: {@code min_compatible_shard_node} */ public final Builder minCompatibleShardNode(@Nullable String value) { this.minCompatibleShardNode = value; return this; } /** * Minimum _score for matching documents. Documents with a lower _score are not * included in the search results. * * API name: {@code min_score} */ public final Builder minScore(@Nullable Double value) { this.minScore = value; return this; } /** * Limits the search to a point in time (PIT). If you provide a PIT, you cannot * specify an <index> in the request path. * * API name: {@code pit} */ public final Builder pit(@Nullable PointInTimeReference value) { this.pit = value; return this; } /** * Limits the search to a point in time (PIT). If you provide a PIT, you cannot * specify an <index> in the request path. * * API name: {@code pit} */ public final Builder pit(Function> fn) { return this.pit(fn.apply(new PointInTimeReference.Builder()).build()); } /** * API name: {@code post_filter} */ public final Builder postFilter(@Nullable Query value) { this.postFilter = value; return this; } /** * API name: {@code post_filter} */ public final Builder postFilter(Function> fn) { return this.postFilter(fn.apply(new Query.Builder()).build()); } /** * API name: {@code pre_filter_shard_size} */ public final Builder preFilterShardSize(@Nullable Long value) { this.preFilterShardSize = value; return this; } /** * Specify the node or shard the operation should be performed on (default: * random) * * API name: {@code preference} */ public final Builder preference(@Nullable String value) { this.preference = value; return this; } /** * API name: {@code profile} */ public final Builder profile(@Nullable Boolean value) { this.profile = value; return this; } /** * Query in the Lucene query string syntax * * API name: {@code q} */ public final Builder q(@Nullable String value) { this.q = value; return this; } /** * Defines the search definition using the Query DSL. * * API name: {@code query} */ public final Builder query(@Nullable Query value) { this.query = value; return this; } /** * Defines the search definition using the Query DSL. * * API name: {@code query} */ public final Builder query(Function> fn) { return this.query(fn.apply(new Query.Builder()).build()); } /** * Specify if request cache should be used for this request or not, defaults to * true * * API name: {@code request_cache} */ public final Builder requestCache(@Nullable Boolean value) { this.requestCache = value; return this; } /** * API name: {@code rescore} * * Adds all elements of list to rescore. */ public final Builder rescore(List list) { this.rescore = _listAddAll(this.rescore, list); return this; } /** * API name: {@code rescore} * * Adds one or more values to rescore. */ public final Builder rescore(Rescore value, Rescore... values) { this.rescore = _listAdd(this.rescore, value, values); return this; } /** * API name: {@code rescore} * * Adds a value to rescore using a builder lambda. */ public final Builder rescore(Function> fn) { return rescore(fn.apply(new Rescore.Builder()).build()); } /** * A comma-separated list of specific routing values * * API name: {@code routing} */ public final Builder routing(@Nullable String value) { this.routing = value; return this; } /** * Defines one or more runtime fields in the search request. These fields take * precedence over mapped fields with the same name. * * API name: {@code runtime_mappings} * * Adds all entries of map to runtimeMappings. */ public final Builder runtimeMappings(Map> map) { this.runtimeMappings = _mapPutAll(this.runtimeMappings, map); return this; } /** * Defines one or more runtime fields in the search request. These fields take * precedence over mapped fields with the same name. * * API name: {@code runtime_mappings} * * Adds an entry to runtimeMappings. */ public final Builder runtimeMappings(String key, List value) { this.runtimeMappings = _mapPut(this.runtimeMappings, key, value); return this; } /** * Retrieve a script evaluation (based on different fields) for each hit. * * API name: {@code script_fields} * * Adds all entries of map to scriptFields. */ public final Builder scriptFields(Map map) { this.scriptFields = _mapPutAll(this.scriptFields, map); return this; } /** * Retrieve a script evaluation (based on different fields) for each hit. * * API name: {@code script_fields} * * Adds an entry to scriptFields. */ public final Builder scriptFields(String key, ScriptField value) { this.scriptFields = _mapPut(this.scriptFields, key, value); return this; } /** * Retrieve a script evaluation (based on different fields) for each hit. * * API name: {@code script_fields} * * Adds an entry to scriptFields using a builder lambda. */ public final Builder scriptFields(String key, Function> fn) { return scriptFields(key, fn.apply(new ScriptField.Builder()).build()); } /** * API name: {@code scroll} */ public final Builder scroll(@Nullable Time value) { this.scroll = value; return this; } /** * API name: {@code scroll} */ public final Builder scroll(Function> fn) { return this.scroll(fn.apply(new Time.Builder()).build()); } /** * API name: {@code search_after} * * Adds all elements of list to searchAfter. */ public final Builder searchAfter(List list) { this.searchAfter = _listAddAll(this.searchAfter, list); return this; } /** * API name: {@code search_after} * * Adds one or more values to searchAfter. */ public final Builder searchAfter(String value, String... values) { this.searchAfter = _listAdd(this.searchAfter, value, values); return this; } /** * Search operation type * * API name: {@code search_type} */ public final Builder searchType(@Nullable SearchType value) { this.searchType = value; return this; } /** * If true, returns sequence number and primary term of the last modification of * each hit. See Optimistic concurrency control. * * API name: {@code seq_no_primary_term} */ public final Builder seqNoPrimaryTerm(@Nullable Boolean value) { this.seqNoPrimaryTerm = value; return this; } /** * The number of hits to return. By default, you cannot page through more than * 10,000 hits using the from and size parameters. To page through more hits, * use the search_after parameter. * * API name: {@code size} */ public final Builder size(@Nullable Integer value) { this.size = value; return this; } /** * API name: {@code slice} */ public final Builder slice(@Nullable SlicedScroll value) { this.slice = value; return this; } /** * API name: {@code slice} */ public final Builder slice(Function> fn) { return this.slice(fn.apply(new SlicedScroll.Builder()).build()); } /** * API name: {@code sort} * * Adds all elements of list to sort. */ public final Builder sort(List list) { this.sort = _listAddAll(this.sort, list); return this; } /** * API name: {@code sort} * * Adds one or more values to sort. */ public final Builder sort(SortOptions value, SortOptions... values) { this.sort = _listAdd(this.sort, value, values); return this; } /** * API name: {@code sort} * * Adds a value to sort using a builder lambda. */ public final Builder sort(Function> fn) { return sort(fn.apply(new SortOptions.Builder()).build()); } /** * Stats groups to associate with the search. Each group maintains a statistics * aggregation for its associated searches. You can retrieve these stats using * the indices stats API. * * API name: {@code stats} * * Adds all elements of list to stats. */ public final Builder stats(List list) { this.stats = _listAddAll(this.stats, list); return this; } /** * Stats groups to associate with the search. Each group maintains a statistics * aggregation for its associated searches. You can retrieve these stats using * the indices stats API. * * API name: {@code stats} * * Adds one or more values to stats. */ public final Builder stats(String value, String... values) { this.stats = _listAdd(this.stats, value, values); return this; } /** * List of stored fields to return as part of a hit. If no fields are specified, * no stored fields are included in the response. If this field is specified, * the _source parameter defaults to false. You can pass _source: true to return * both source fields and stored fields in the search response. * * API name: {@code stored_fields} * * Adds all elements of list to storedFields. */ public final Builder storedFields(List list) { this.storedFields = _listAddAll(this.storedFields, list); return this; } /** * List of stored fields to return as part of a hit. If no fields are specified, * no stored fields are included in the response. If this field is specified, * the _source parameter defaults to false. You can pass _source: true to return * both source fields and stored fields in the search response. * * API name: {@code stored_fields} * * Adds one or more values to storedFields. */ public final Builder storedFields(String value, String... values) { this.storedFields = _listAdd(this.storedFields, value, values); return this; } /** * API name: {@code suggest} */ public final Builder suggest(@Nullable Suggester value) { this.suggest = value; return this; } /** * API name: {@code suggest} */ public final Builder suggest(Function> fn) { return this.suggest(fn.apply(new Suggester.Builder()).build()); } /** * Maximum number of documents to collect for each shard. If a query reaches * this limit, Elasticsearch terminates the query early. Elasticsearch collects * documents before sorting. Defaults to 0, which does not terminate query * execution early. * * API name: {@code terminate_after} */ public final Builder terminateAfter(@Nullable Long value) { this.terminateAfter = value; return this; } /** * Specifies the period of time to wait for a response from each shard. If no * response is received before the timeout expires, the request fails and * returns an error. Defaults to no timeout. * * API name: {@code timeout} */ public final Builder timeout(@Nullable String value) { this.timeout = value; return this; } /** * If true, calculate and return document scores, even if the scores are not * used for sorting. * * API name: {@code track_scores} */ public final Builder trackScores(@Nullable Boolean value) { this.trackScores = value; return this; } /** * Number of hits matching the query to count accurately. If true, the exact * number of hits is returned at the cost of some performance. If false, the * response does not include the total number of hits matching the query. * Defaults to 10,000 hits. * * API name: {@code track_total_hits} */ public final Builder trackTotalHits(@Nullable TrackHits value) { this.trackTotalHits = value; return this; } /** * Number of hits matching the query to count accurately. If true, the exact * number of hits is returned at the cost of some performance. If false, the * response does not include the total number of hits matching the query. * Defaults to 10,000 hits. * * API name: {@code track_total_hits} */ public final Builder trackTotalHits(Function> fn) { return this.trackTotalHits(fn.apply(new TrackHits.Builder()).build()); } /** * If true, returns document version as part of a hit. * * API name: {@code version} */ public final Builder version(@Nullable Boolean value) { this.version = value; return this; } /** * Specify the time that the request should block waiting for the final response * * API name: {@code wait_for_completion_timeout} */ public final Builder waitForCompletionTimeout(@Nullable Time value) { this.waitForCompletionTimeout = value; return this; } /** * Specify the time that the request should block waiting for the final response * * API name: {@code wait_for_completion_timeout} */ public final Builder waitForCompletionTimeout(Function> fn) { return this.waitForCompletionTimeout(fn.apply(new Time.Builder()).build()); } @Override protected Builder self() { return this; } /** * Builds a {@link SubmitRequest}. * * @throws NullPointerException * if some of the required fields are null. */ public SubmitRequest build() { _checkSingleUse(); return new SubmitRequest(this); } } // --------------------------------------------------------------------------------------------- /** * Json deserializer for {@link SubmitRequest} */ public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy(Builder::new, SubmitRequest::setupSubmitRequestDeserializer); protected static void setupSubmitRequestDeserializer(ObjectDeserializer op) { op.add(Builder::source, SourceConfig._DESERIALIZER, "_source"); op.add(Builder::aggregations, JsonpDeserializer.stringMapDeserializer(Aggregation._DESERIALIZER), "aggregations", "aggs"); op.add(Builder::collapse, FieldCollapse._DESERIALIZER, "collapse"); op.add(Builder::docvalueFields, JsonpDeserializer.arrayDeserializer(FieldAndFormat._DESERIALIZER), "docvalue_fields"); op.add(Builder::explain, JsonpDeserializer.booleanDeserializer(), "explain"); op.add(Builder::fields, JsonpDeserializer.arrayDeserializer(FieldAndFormat._DESERIALIZER), "fields"); op.add(Builder::from, JsonpDeserializer.integerDeserializer(), "from"); op.add(Builder::highlight, Highlight._DESERIALIZER, "highlight"); op.add(Builder::indicesBoost, JsonpDeserializer.arrayDeserializer( JsonpDeserializer.stringMapDeserializer(JsonpDeserializer.doubleDeserializer())), "indices_boost"); op.add(Builder::minScore, JsonpDeserializer.doubleDeserializer(), "min_score"); op.add(Builder::pit, PointInTimeReference._DESERIALIZER, "pit"); op.add(Builder::postFilter, Query._DESERIALIZER, "post_filter"); op.add(Builder::profile, JsonpDeserializer.booleanDeserializer(), "profile"); op.add(Builder::query, Query._DESERIALIZER, "query"); op.add(Builder::rescore, JsonpDeserializer.arrayDeserializer(Rescore._DESERIALIZER), "rescore"); op.add(Builder::runtimeMappings, JsonpDeserializer.stringMapDeserializer( JsonpDeserializer.arrayDeserializer(RuntimeField._DESERIALIZER)), "runtime_mappings"); op.add(Builder::scriptFields, JsonpDeserializer.stringMapDeserializer(ScriptField._DESERIALIZER), "script_fields"); op.add(Builder::searchAfter, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "search_after"); op.add(Builder::seqNoPrimaryTerm, JsonpDeserializer.booleanDeserializer(), "seq_no_primary_term"); op.add(Builder::size, JsonpDeserializer.integerDeserializer(), "size"); op.add(Builder::slice, SlicedScroll._DESERIALIZER, "slice"); op.add(Builder::sort, JsonpDeserializer.arrayDeserializer(SortOptions._DESERIALIZER), "sort"); op.add(Builder::stats, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "stats"); op.add(Builder::storedFields, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "stored_fields"); op.add(Builder::suggest, Suggester._DESERIALIZER, "suggest"); op.add(Builder::terminateAfter, JsonpDeserializer.longDeserializer(), "terminate_after"); op.add(Builder::timeout, JsonpDeserializer.stringDeserializer(), "timeout"); op.add(Builder::trackScores, JsonpDeserializer.booleanDeserializer(), "track_scores"); op.add(Builder::trackTotalHits, TrackHits._DESERIALIZER, "track_total_hits"); op.add(Builder::version, JsonpDeserializer.booleanDeserializer(), "version"); } // --------------------------------------------------------------------------------------------- /** * Endpoint "{@code async_search.submit}". */ public static final SimpleEndpoint _ENDPOINT = new SimpleEndpoint<>("es/async_search.submit", // Request method request -> { return "POST"; }, // Request path request -> { final int _index = 1 << 0; int propsSet = 0; if (ApiTypeHelper.isDefined(request.index())) propsSet |= _index; if (propsSet == 0) { StringBuilder buf = new StringBuilder(); buf.append("/_async_search"); return buf.toString(); } if (propsSet == (_index)) { StringBuilder buf = new StringBuilder(); buf.append("/"); SimpleEndpoint.pathEncode(request.index.stream().map(v -> v).collect(Collectors.joining(",")), buf); buf.append("/_async_search"); return buf.toString(); } throw SimpleEndpoint.noPathTemplateFound("path"); }, // Request parameters request -> { Map params = new HashMap<>(); params.put("typed_keys", "true"); if (request.df != null) { params.put("df", request.df); } if (request.preFilterShardSize != null) { params.put("pre_filter_shard_size", String.valueOf(request.preFilterShardSize)); } if (request.minCompatibleShardNode != null) { params.put("min_compatible_shard_node", request.minCompatibleShardNode); } if (request.lenient != null) { params.put("lenient", String.valueOf(request.lenient)); } if (request.routing != null) { params.put("routing", request.routing); } if (request.ignoreUnavailable != null) { params.put("ignore_unavailable", String.valueOf(request.ignoreUnavailable)); } if (request.allowNoIndices != null) { params.put("allow_no_indices", String.valueOf(request.allowNoIndices)); } if (request.analyzer != null) { params.put("analyzer", request.analyzer); } if (request.ignoreThrottled != null) { params.put("ignore_throttled", String.valueOf(request.ignoreThrottled)); } if (request.keepOnCompletion != null) { params.put("keep_on_completion", String.valueOf(request.keepOnCompletion)); } if (request.maxConcurrentShardRequests != null) { params.put("max_concurrent_shard_requests", String.valueOf(request.maxConcurrentShardRequests)); } if (request.allowPartialSearchResults != null) { params.put("allow_partial_search_results", String.valueOf(request.allowPartialSearchResults)); } if (ApiTypeHelper.isDefined(request.expandWildcards)) { params.put("expand_wildcards", request.expandWildcards.stream().map(v -> v.jsonValue()).collect(Collectors.joining(","))); } if (request.preference != null) { params.put("preference", request.preference); } if (request.analyzeWildcard != null) { params.put("analyze_wildcard", String.valueOf(request.analyzeWildcard)); } if (request.scroll != null) { params.put("scroll", request.scroll._toJsonString()); } if (request.waitForCompletionTimeout != null) { params.put("wait_for_completion_timeout", request.waitForCompletionTimeout._toJsonString()); } if (request.searchType != null) { params.put("search_type", request.searchType.jsonValue()); } if (request.ccsMinimizeRoundtrips != null) { params.put("ccs_minimize_roundtrips", String.valueOf(request.ccsMinimizeRoundtrips)); } if (request.q != null) { params.put("q", request.q); } if (request.defaultOperator != null) { params.put("default_operator", request.defaultOperator.jsonValue()); } if (request.keepAlive != null) { params.put("keep_alive", request.keepAlive._toJsonString()); } if (request.requestCache != null) { params.put("request_cache", String.valueOf(request.requestCache)); } if (request.batchedReduceSize != null) { params.put("batched_reduce_size", String.valueOf(request.batchedReduceSize)); } return params; }, SimpleEndpoint.emptyMap(), true, SubmitResponse._DESERIALIZER); /** * Create an "{@code async_search.submit}" endpoint. */ public static Endpoint, ErrorResponse> createSubmitEndpoint( JsonpDeserializer tDocumentDeserializer) { return _ENDPOINT .withResponseDeserializer(SubmitResponse.createSubmitResponseDeserializer(tDocumentDeserializer)); } }
* API name: {@code keep_alive} */ public final Builder keepAlive(@Nullable Time value) { this.keepAlive = value; return this; } /** * Update the time interval in which the results (partial or final) for this * search will be available *
* API name: {@code keep_alive} */ public final Builder keepAlive(Function> fn) { return this.keepAlive(fn.apply(new Time.Builder()).build()); } /** * Control whether the response should be stored in the cluster if it completed * within the provided [wait_for_completion] time (default: false) * * API name: {@code keep_on_completion} */ public final Builder keepOnCompletion(@Nullable Boolean value) { this.keepOnCompletion = value; return this; } /** * Specify whether format-based query failures (such as providing text to a * numeric field) should be ignored * * API name: {@code lenient} */ public final Builder lenient(@Nullable Boolean value) { this.lenient = value; return this; } /** * The number of concurrent shard requests per node this search executes * concurrently. This value should be used to limit the impact of the search on * the cluster in order to limit the number of concurrent shard requests * * API name: {@code max_concurrent_shard_requests} */ public final Builder maxConcurrentShardRequests(@Nullable Long value) { this.maxConcurrentShardRequests = value; return this; } /** * API name: {@code min_compatible_shard_node} */ public final Builder minCompatibleShardNode(@Nullable String value) { this.minCompatibleShardNode = value; return this; } /** * Minimum _score for matching documents. Documents with a lower _score are not * included in the search results. * * API name: {@code min_score} */ public final Builder minScore(@Nullable Double value) { this.minScore = value; return this; } /** * Limits the search to a point in time (PIT). If you provide a PIT, you cannot * specify an <index> in the request path. * * API name: {@code pit} */ public final Builder pit(@Nullable PointInTimeReference value) { this.pit = value; return this; } /** * Limits the search to a point in time (PIT). If you provide a PIT, you cannot * specify an <index> in the request path. * * API name: {@code pit} */ public final Builder pit(Function> fn) { return this.pit(fn.apply(new PointInTimeReference.Builder()).build()); } /** * API name: {@code post_filter} */ public final Builder postFilter(@Nullable Query value) { this.postFilter = value; return this; } /** * API name: {@code post_filter} */ public final Builder postFilter(Function> fn) { return this.postFilter(fn.apply(new Query.Builder()).build()); } /** * API name: {@code pre_filter_shard_size} */ public final Builder preFilterShardSize(@Nullable Long value) { this.preFilterShardSize = value; return this; } /** * Specify the node or shard the operation should be performed on (default: * random) * * API name: {@code preference} */ public final Builder preference(@Nullable String value) { this.preference = value; return this; } /** * API name: {@code profile} */ public final Builder profile(@Nullable Boolean value) { this.profile = value; return this; } /** * Query in the Lucene query string syntax * * API name: {@code q} */ public final Builder q(@Nullable String value) { this.q = value; return this; } /** * Defines the search definition using the Query DSL. * * API name: {@code query} */ public final Builder query(@Nullable Query value) { this.query = value; return this; } /** * Defines the search definition using the Query DSL. * * API name: {@code query} */ public final Builder query(Function> fn) { return this.query(fn.apply(new Query.Builder()).build()); } /** * Specify if request cache should be used for this request or not, defaults to * true * * API name: {@code request_cache} */ public final Builder requestCache(@Nullable Boolean value) { this.requestCache = value; return this; } /** * API name: {@code rescore} * * Adds all elements of list to rescore. */ public final Builder rescore(List list) { this.rescore = _listAddAll(this.rescore, list); return this; } /** * API name: {@code rescore} * * Adds one or more values to rescore. */ public final Builder rescore(Rescore value, Rescore... values) { this.rescore = _listAdd(this.rescore, value, values); return this; } /** * API name: {@code rescore} * * Adds a value to rescore using a builder lambda. */ public final Builder rescore(Function> fn) { return rescore(fn.apply(new Rescore.Builder()).build()); } /** * A comma-separated list of specific routing values * * API name: {@code routing} */ public final Builder routing(@Nullable String value) { this.routing = value; return this; } /** * Defines one or more runtime fields in the search request. These fields take * precedence over mapped fields with the same name. * * API name: {@code runtime_mappings} * * Adds all entries of map to runtimeMappings. */ public final Builder runtimeMappings(Map> map) { this.runtimeMappings = _mapPutAll(this.runtimeMappings, map); return this; } /** * Defines one or more runtime fields in the search request. These fields take * precedence over mapped fields with the same name. * * API name: {@code runtime_mappings} * * Adds an entry to runtimeMappings. */ public final Builder runtimeMappings(String key, List value) { this.runtimeMappings = _mapPut(this.runtimeMappings, key, value); return this; } /** * Retrieve a script evaluation (based on different fields) for each hit. * * API name: {@code script_fields} * * Adds all entries of map to scriptFields. */ public final Builder scriptFields(Map map) { this.scriptFields = _mapPutAll(this.scriptFields, map); return this; } /** * Retrieve a script evaluation (based on different fields) for each hit. * * API name: {@code script_fields} * * Adds an entry to scriptFields. */ public final Builder scriptFields(String key, ScriptField value) { this.scriptFields = _mapPut(this.scriptFields, key, value); return this; } /** * Retrieve a script evaluation (based on different fields) for each hit. * * API name: {@code script_fields} * * Adds an entry to scriptFields using a builder lambda. */ public final Builder scriptFields(String key, Function> fn) { return scriptFields(key, fn.apply(new ScriptField.Builder()).build()); } /** * API name: {@code scroll} */ public final Builder scroll(@Nullable Time value) { this.scroll = value; return this; } /** * API name: {@code scroll} */ public final Builder scroll(Function> fn) { return this.scroll(fn.apply(new Time.Builder()).build()); } /** * API name: {@code search_after} * * Adds all elements of list to searchAfter. */ public final Builder searchAfter(List list) { this.searchAfter = _listAddAll(this.searchAfter, list); return this; } /** * API name: {@code search_after} * * Adds one or more values to searchAfter. */ public final Builder searchAfter(String value, String... values) { this.searchAfter = _listAdd(this.searchAfter, value, values); return this; } /** * Search operation type * * API name: {@code search_type} */ public final Builder searchType(@Nullable SearchType value) { this.searchType = value; return this; } /** * If true, returns sequence number and primary term of the last modification of * each hit. See Optimistic concurrency control. * * API name: {@code seq_no_primary_term} */ public final Builder seqNoPrimaryTerm(@Nullable Boolean value) { this.seqNoPrimaryTerm = value; return this; } /** * The number of hits to return. By default, you cannot page through more than * 10,000 hits using the from and size parameters. To page through more hits, * use the search_after parameter. * * API name: {@code size} */ public final Builder size(@Nullable Integer value) { this.size = value; return this; } /** * API name: {@code slice} */ public final Builder slice(@Nullable SlicedScroll value) { this.slice = value; return this; } /** * API name: {@code slice} */ public final Builder slice(Function> fn) { return this.slice(fn.apply(new SlicedScroll.Builder()).build()); } /** * API name: {@code sort} * * Adds all elements of list to sort. */ public final Builder sort(List list) { this.sort = _listAddAll(this.sort, list); return this; } /** * API name: {@code sort} * * Adds one or more values to sort. */ public final Builder sort(SortOptions value, SortOptions... values) { this.sort = _listAdd(this.sort, value, values); return this; } /** * API name: {@code sort} * * Adds a value to sort using a builder lambda. */ public final Builder sort(Function> fn) { return sort(fn.apply(new SortOptions.Builder()).build()); } /** * Stats groups to associate with the search. Each group maintains a statistics * aggregation for its associated searches. You can retrieve these stats using * the indices stats API. * * API name: {@code stats} * * Adds all elements of list to stats. */ public final Builder stats(List list) { this.stats = _listAddAll(this.stats, list); return this; } /** * Stats groups to associate with the search. Each group maintains a statistics * aggregation for its associated searches. You can retrieve these stats using * the indices stats API. * * API name: {@code stats} * * Adds one or more values to stats. */ public final Builder stats(String value, String... values) { this.stats = _listAdd(this.stats, value, values); return this; } /** * List of stored fields to return as part of a hit. If no fields are specified, * no stored fields are included in the response. If this field is specified, * the _source parameter defaults to false. You can pass _source: true to return * both source fields and stored fields in the search response. * * API name: {@code stored_fields} * * Adds all elements of list to storedFields. */ public final Builder storedFields(List list) { this.storedFields = _listAddAll(this.storedFields, list); return this; } /** * List of stored fields to return as part of a hit. If no fields are specified, * no stored fields are included in the response. If this field is specified, * the _source parameter defaults to false. You can pass _source: true to return * both source fields and stored fields in the search response. * * API name: {@code stored_fields} * * Adds one or more values to storedFields. */ public final Builder storedFields(String value, String... values) { this.storedFields = _listAdd(this.storedFields, value, values); return this; } /** * API name: {@code suggest} */ public final Builder suggest(@Nullable Suggester value) { this.suggest = value; return this; } /** * API name: {@code suggest} */ public final Builder suggest(Function> fn) { return this.suggest(fn.apply(new Suggester.Builder()).build()); } /** * Maximum number of documents to collect for each shard. If a query reaches * this limit, Elasticsearch terminates the query early. Elasticsearch collects * documents before sorting. Defaults to 0, which does not terminate query * execution early. * * API name: {@code terminate_after} */ public final Builder terminateAfter(@Nullable Long value) { this.terminateAfter = value; return this; } /** * Specifies the period of time to wait for a response from each shard. If no * response is received before the timeout expires, the request fails and * returns an error. Defaults to no timeout. * * API name: {@code timeout} */ public final Builder timeout(@Nullable String value) { this.timeout = value; return this; } /** * If true, calculate and return document scores, even if the scores are not * used for sorting. * * API name: {@code track_scores} */ public final Builder trackScores(@Nullable Boolean value) { this.trackScores = value; return this; } /** * Number of hits matching the query to count accurately. If true, the exact * number of hits is returned at the cost of some performance. If false, the * response does not include the total number of hits matching the query. * Defaults to 10,000 hits. * * API name: {@code track_total_hits} */ public final Builder trackTotalHits(@Nullable TrackHits value) { this.trackTotalHits = value; return this; } /** * Number of hits matching the query to count accurately. If true, the exact * number of hits is returned at the cost of some performance. If false, the * response does not include the total number of hits matching the query. * Defaults to 10,000 hits. * * API name: {@code track_total_hits} */ public final Builder trackTotalHits(Function> fn) { return this.trackTotalHits(fn.apply(new TrackHits.Builder()).build()); } /** * If true, returns document version as part of a hit. * * API name: {@code version} */ public final Builder version(@Nullable Boolean value) { this.version = value; return this; } /** * Specify the time that the request should block waiting for the final response * * API name: {@code wait_for_completion_timeout} */ public final Builder waitForCompletionTimeout(@Nullable Time value) { this.waitForCompletionTimeout = value; return this; } /** * Specify the time that the request should block waiting for the final response * * API name: {@code wait_for_completion_timeout} */ public final Builder waitForCompletionTimeout(Function> fn) { return this.waitForCompletionTimeout(fn.apply(new Time.Builder()).build()); } @Override protected Builder self() { return this; } /** * Builds a {@link SubmitRequest}. * * @throws NullPointerException * if some of the required fields are null. */ public SubmitRequest build() { _checkSingleUse(); return new SubmitRequest(this); } } // --------------------------------------------------------------------------------------------- /** * Json deserializer for {@link SubmitRequest} */ public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy(Builder::new, SubmitRequest::setupSubmitRequestDeserializer); protected static void setupSubmitRequestDeserializer(ObjectDeserializer op) { op.add(Builder::source, SourceConfig._DESERIALIZER, "_source"); op.add(Builder::aggregations, JsonpDeserializer.stringMapDeserializer(Aggregation._DESERIALIZER), "aggregations", "aggs"); op.add(Builder::collapse, FieldCollapse._DESERIALIZER, "collapse"); op.add(Builder::docvalueFields, JsonpDeserializer.arrayDeserializer(FieldAndFormat._DESERIALIZER), "docvalue_fields"); op.add(Builder::explain, JsonpDeserializer.booleanDeserializer(), "explain"); op.add(Builder::fields, JsonpDeserializer.arrayDeserializer(FieldAndFormat._DESERIALIZER), "fields"); op.add(Builder::from, JsonpDeserializer.integerDeserializer(), "from"); op.add(Builder::highlight, Highlight._DESERIALIZER, "highlight"); op.add(Builder::indicesBoost, JsonpDeserializer.arrayDeserializer( JsonpDeserializer.stringMapDeserializer(JsonpDeserializer.doubleDeserializer())), "indices_boost"); op.add(Builder::minScore, JsonpDeserializer.doubleDeserializer(), "min_score"); op.add(Builder::pit, PointInTimeReference._DESERIALIZER, "pit"); op.add(Builder::postFilter, Query._DESERIALIZER, "post_filter"); op.add(Builder::profile, JsonpDeserializer.booleanDeserializer(), "profile"); op.add(Builder::query, Query._DESERIALIZER, "query"); op.add(Builder::rescore, JsonpDeserializer.arrayDeserializer(Rescore._DESERIALIZER), "rescore"); op.add(Builder::runtimeMappings, JsonpDeserializer.stringMapDeserializer( JsonpDeserializer.arrayDeserializer(RuntimeField._DESERIALIZER)), "runtime_mappings"); op.add(Builder::scriptFields, JsonpDeserializer.stringMapDeserializer(ScriptField._DESERIALIZER), "script_fields"); op.add(Builder::searchAfter, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "search_after"); op.add(Builder::seqNoPrimaryTerm, JsonpDeserializer.booleanDeserializer(), "seq_no_primary_term"); op.add(Builder::size, JsonpDeserializer.integerDeserializer(), "size"); op.add(Builder::slice, SlicedScroll._DESERIALIZER, "slice"); op.add(Builder::sort, JsonpDeserializer.arrayDeserializer(SortOptions._DESERIALIZER), "sort"); op.add(Builder::stats, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "stats"); op.add(Builder::storedFields, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "stored_fields"); op.add(Builder::suggest, Suggester._DESERIALIZER, "suggest"); op.add(Builder::terminateAfter, JsonpDeserializer.longDeserializer(), "terminate_after"); op.add(Builder::timeout, JsonpDeserializer.stringDeserializer(), "timeout"); op.add(Builder::trackScores, JsonpDeserializer.booleanDeserializer(), "track_scores"); op.add(Builder::trackTotalHits, TrackHits._DESERIALIZER, "track_total_hits"); op.add(Builder::version, JsonpDeserializer.booleanDeserializer(), "version"); } // --------------------------------------------------------------------------------------------- /** * Endpoint "{@code async_search.submit}". */ public static final SimpleEndpoint _ENDPOINT = new SimpleEndpoint<>("es/async_search.submit", // Request method request -> { return "POST"; }, // Request path request -> { final int _index = 1 << 0; int propsSet = 0; if (ApiTypeHelper.isDefined(request.index())) propsSet |= _index; if (propsSet == 0) { StringBuilder buf = new StringBuilder(); buf.append("/_async_search"); return buf.toString(); } if (propsSet == (_index)) { StringBuilder buf = new StringBuilder(); buf.append("/"); SimpleEndpoint.pathEncode(request.index.stream().map(v -> v).collect(Collectors.joining(",")), buf); buf.append("/_async_search"); return buf.toString(); } throw SimpleEndpoint.noPathTemplateFound("path"); }, // Request parameters request -> { Map params = new HashMap<>(); params.put("typed_keys", "true"); if (request.df != null) { params.put("df", request.df); } if (request.preFilterShardSize != null) { params.put("pre_filter_shard_size", String.valueOf(request.preFilterShardSize)); } if (request.minCompatibleShardNode != null) { params.put("min_compatible_shard_node", request.minCompatibleShardNode); } if (request.lenient != null) { params.put("lenient", String.valueOf(request.lenient)); } if (request.routing != null) { params.put("routing", request.routing); } if (request.ignoreUnavailable != null) { params.put("ignore_unavailable", String.valueOf(request.ignoreUnavailable)); } if (request.allowNoIndices != null) { params.put("allow_no_indices", String.valueOf(request.allowNoIndices)); } if (request.analyzer != null) { params.put("analyzer", request.analyzer); } if (request.ignoreThrottled != null) { params.put("ignore_throttled", String.valueOf(request.ignoreThrottled)); } if (request.keepOnCompletion != null) { params.put("keep_on_completion", String.valueOf(request.keepOnCompletion)); } if (request.maxConcurrentShardRequests != null) { params.put("max_concurrent_shard_requests", String.valueOf(request.maxConcurrentShardRequests)); } if (request.allowPartialSearchResults != null) { params.put("allow_partial_search_results", String.valueOf(request.allowPartialSearchResults)); } if (ApiTypeHelper.isDefined(request.expandWildcards)) { params.put("expand_wildcards", request.expandWildcards.stream().map(v -> v.jsonValue()).collect(Collectors.joining(","))); } if (request.preference != null) { params.put("preference", request.preference); } if (request.analyzeWildcard != null) { params.put("analyze_wildcard", String.valueOf(request.analyzeWildcard)); } if (request.scroll != null) { params.put("scroll", request.scroll._toJsonString()); } if (request.waitForCompletionTimeout != null) { params.put("wait_for_completion_timeout", request.waitForCompletionTimeout._toJsonString()); } if (request.searchType != null) { params.put("search_type", request.searchType.jsonValue()); } if (request.ccsMinimizeRoundtrips != null) { params.put("ccs_minimize_roundtrips", String.valueOf(request.ccsMinimizeRoundtrips)); } if (request.q != null) { params.put("q", request.q); } if (request.defaultOperator != null) { params.put("default_operator", request.defaultOperator.jsonValue()); } if (request.keepAlive != null) { params.put("keep_alive", request.keepAlive._toJsonString()); } if (request.requestCache != null) { params.put("request_cache", String.valueOf(request.requestCache)); } if (request.batchedReduceSize != null) { params.put("batched_reduce_size", String.valueOf(request.batchedReduceSize)); } return params; }, SimpleEndpoint.emptyMap(), true, SubmitResponse._DESERIALIZER); /** * Create an "{@code async_search.submit}" endpoint. */ public static Endpoint, ErrorResponse> createSubmitEndpoint( JsonpDeserializer tDocumentDeserializer) { return _ENDPOINT .withResponseDeserializer(SubmitResponse.createSubmitResponseDeserializer(tDocumentDeserializer)); } }
* API name: {@code keep_on_completion} */ public final Builder keepOnCompletion(@Nullable Boolean value) { this.keepOnCompletion = value; return this; } /** * Specify whether format-based query failures (such as providing text to a * numeric field) should be ignored *
* API name: {@code lenient} */ public final Builder lenient(@Nullable Boolean value) { this.lenient = value; return this; } /** * The number of concurrent shard requests per node this search executes * concurrently. This value should be used to limit the impact of the search on * the cluster in order to limit the number of concurrent shard requests *
* API name: {@code max_concurrent_shard_requests} */ public final Builder maxConcurrentShardRequests(@Nullable Long value) { this.maxConcurrentShardRequests = value; return this; } /** * API name: {@code min_compatible_shard_node} */ public final Builder minCompatibleShardNode(@Nullable String value) { this.minCompatibleShardNode = value; return this; } /** * Minimum _score for matching documents. Documents with a lower _score are not * included in the search results. *
* API name: {@code min_score} */ public final Builder minScore(@Nullable Double value) { this.minScore = value; return this; } /** * Limits the search to a point in time (PIT). If you provide a PIT, you cannot * specify an <index> in the request path. *
* API name: {@code pit} */ public final Builder pit(@Nullable PointInTimeReference value) { this.pit = value; return this; } /** * Limits the search to a point in time (PIT). If you provide a PIT, you cannot * specify an <index> in the request path. *
* API name: {@code pit} */ public final Builder pit(Function> fn) { return this.pit(fn.apply(new PointInTimeReference.Builder()).build()); } /** * API name: {@code post_filter} */ public final Builder postFilter(@Nullable Query value) { this.postFilter = value; return this; } /** * API name: {@code post_filter} */ public final Builder postFilter(Function> fn) { return this.postFilter(fn.apply(new Query.Builder()).build()); } /** * API name: {@code pre_filter_shard_size} */ public final Builder preFilterShardSize(@Nullable Long value) { this.preFilterShardSize = value; return this; } /** * Specify the node or shard the operation should be performed on (default: * random) * * API name: {@code preference} */ public final Builder preference(@Nullable String value) { this.preference = value; return this; } /** * API name: {@code profile} */ public final Builder profile(@Nullable Boolean value) { this.profile = value; return this; } /** * Query in the Lucene query string syntax * * API name: {@code q} */ public final Builder q(@Nullable String value) { this.q = value; return this; } /** * Defines the search definition using the Query DSL. * * API name: {@code query} */ public final Builder query(@Nullable Query value) { this.query = value; return this; } /** * Defines the search definition using the Query DSL. * * API name: {@code query} */ public final Builder query(Function> fn) { return this.query(fn.apply(new Query.Builder()).build()); } /** * Specify if request cache should be used for this request or not, defaults to * true * * API name: {@code request_cache} */ public final Builder requestCache(@Nullable Boolean value) { this.requestCache = value; return this; } /** * API name: {@code rescore} * * Adds all elements of list to rescore. */ public final Builder rescore(List list) { this.rescore = _listAddAll(this.rescore, list); return this; } /** * API name: {@code rescore} * * Adds one or more values to rescore. */ public final Builder rescore(Rescore value, Rescore... values) { this.rescore = _listAdd(this.rescore, value, values); return this; } /** * API name: {@code rescore} * * Adds a value to rescore using a builder lambda. */ public final Builder rescore(Function> fn) { return rescore(fn.apply(new Rescore.Builder()).build()); } /** * A comma-separated list of specific routing values * * API name: {@code routing} */ public final Builder routing(@Nullable String value) { this.routing = value; return this; } /** * Defines one or more runtime fields in the search request. These fields take * precedence over mapped fields with the same name. * * API name: {@code runtime_mappings} * * Adds all entries of map to runtimeMappings. */ public final Builder runtimeMappings(Map> map) { this.runtimeMappings = _mapPutAll(this.runtimeMappings, map); return this; } /** * Defines one or more runtime fields in the search request. These fields take * precedence over mapped fields with the same name. * * API name: {@code runtime_mappings} * * Adds an entry to runtimeMappings. */ public final Builder runtimeMappings(String key, List value) { this.runtimeMappings = _mapPut(this.runtimeMappings, key, value); return this; } /** * Retrieve a script evaluation (based on different fields) for each hit. * * API name: {@code script_fields} * * Adds all entries of map to scriptFields. */ public final Builder scriptFields(Map map) { this.scriptFields = _mapPutAll(this.scriptFields, map); return this; } /** * Retrieve a script evaluation (based on different fields) for each hit. * * API name: {@code script_fields} * * Adds an entry to scriptFields. */ public final Builder scriptFields(String key, ScriptField value) { this.scriptFields = _mapPut(this.scriptFields, key, value); return this; } /** * Retrieve a script evaluation (based on different fields) for each hit. * * API name: {@code script_fields} * * Adds an entry to scriptFields using a builder lambda. */ public final Builder scriptFields(String key, Function> fn) { return scriptFields(key, fn.apply(new ScriptField.Builder()).build()); } /** * API name: {@code scroll} */ public final Builder scroll(@Nullable Time value) { this.scroll = value; return this; } /** * API name: {@code scroll} */ public final Builder scroll(Function> fn) { return this.scroll(fn.apply(new Time.Builder()).build()); } /** * API name: {@code search_after} * * Adds all elements of list to searchAfter. */ public final Builder searchAfter(List list) { this.searchAfter = _listAddAll(this.searchAfter, list); return this; } /** * API name: {@code search_after} * * Adds one or more values to searchAfter. */ public final Builder searchAfter(String value, String... values) { this.searchAfter = _listAdd(this.searchAfter, value, values); return this; } /** * Search operation type * * API name: {@code search_type} */ public final Builder searchType(@Nullable SearchType value) { this.searchType = value; return this; } /** * If true, returns sequence number and primary term of the last modification of * each hit. See Optimistic concurrency control. * * API name: {@code seq_no_primary_term} */ public final Builder seqNoPrimaryTerm(@Nullable Boolean value) { this.seqNoPrimaryTerm = value; return this; } /** * The number of hits to return. By default, you cannot page through more than * 10,000 hits using the from and size parameters. To page through more hits, * use the search_after parameter. * * API name: {@code size} */ public final Builder size(@Nullable Integer value) { this.size = value; return this; } /** * API name: {@code slice} */ public final Builder slice(@Nullable SlicedScroll value) { this.slice = value; return this; } /** * API name: {@code slice} */ public final Builder slice(Function> fn) { return this.slice(fn.apply(new SlicedScroll.Builder()).build()); } /** * API name: {@code sort} * * Adds all elements of list to sort. */ public final Builder sort(List list) { this.sort = _listAddAll(this.sort, list); return this; } /** * API name: {@code sort} * * Adds one or more values to sort. */ public final Builder sort(SortOptions value, SortOptions... values) { this.sort = _listAdd(this.sort, value, values); return this; } /** * API name: {@code sort} * * Adds a value to sort using a builder lambda. */ public final Builder sort(Function> fn) { return sort(fn.apply(new SortOptions.Builder()).build()); } /** * Stats groups to associate with the search. Each group maintains a statistics * aggregation for its associated searches. You can retrieve these stats using * the indices stats API. * * API name: {@code stats} * * Adds all elements of list to stats. */ public final Builder stats(List list) { this.stats = _listAddAll(this.stats, list); return this; } /** * Stats groups to associate with the search. Each group maintains a statistics * aggregation for its associated searches. You can retrieve these stats using * the indices stats API. * * API name: {@code stats} * * Adds one or more values to stats. */ public final Builder stats(String value, String... values) { this.stats = _listAdd(this.stats, value, values); return this; } /** * List of stored fields to return as part of a hit. If no fields are specified, * no stored fields are included in the response. If this field is specified, * the _source parameter defaults to false. You can pass _source: true to return * both source fields and stored fields in the search response. * * API name: {@code stored_fields} * * Adds all elements of list to storedFields. */ public final Builder storedFields(List list) { this.storedFields = _listAddAll(this.storedFields, list); return this; } /** * List of stored fields to return as part of a hit. If no fields are specified, * no stored fields are included in the response. If this field is specified, * the _source parameter defaults to false. You can pass _source: true to return * both source fields and stored fields in the search response. * * API name: {@code stored_fields} * * Adds one or more values to storedFields. */ public final Builder storedFields(String value, String... values) { this.storedFields = _listAdd(this.storedFields, value, values); return this; } /** * API name: {@code suggest} */ public final Builder suggest(@Nullable Suggester value) { this.suggest = value; return this; } /** * API name: {@code suggest} */ public final Builder suggest(Function> fn) { return this.suggest(fn.apply(new Suggester.Builder()).build()); } /** * Maximum number of documents to collect for each shard. If a query reaches * this limit, Elasticsearch terminates the query early. Elasticsearch collects * documents before sorting. Defaults to 0, which does not terminate query * execution early. * * API name: {@code terminate_after} */ public final Builder terminateAfter(@Nullable Long value) { this.terminateAfter = value; return this; } /** * Specifies the period of time to wait for a response from each shard. If no * response is received before the timeout expires, the request fails and * returns an error. Defaults to no timeout. * * API name: {@code timeout} */ public final Builder timeout(@Nullable String value) { this.timeout = value; return this; } /** * If true, calculate and return document scores, even if the scores are not * used for sorting. * * API name: {@code track_scores} */ public final Builder trackScores(@Nullable Boolean value) { this.trackScores = value; return this; } /** * Number of hits matching the query to count accurately. If true, the exact * number of hits is returned at the cost of some performance. If false, the * response does not include the total number of hits matching the query. * Defaults to 10,000 hits. * * API name: {@code track_total_hits} */ public final Builder trackTotalHits(@Nullable TrackHits value) { this.trackTotalHits = value; return this; } /** * Number of hits matching the query to count accurately. If true, the exact * number of hits is returned at the cost of some performance. If false, the * response does not include the total number of hits matching the query. * Defaults to 10,000 hits. * * API name: {@code track_total_hits} */ public final Builder trackTotalHits(Function> fn) { return this.trackTotalHits(fn.apply(new TrackHits.Builder()).build()); } /** * If true, returns document version as part of a hit. * * API name: {@code version} */ public final Builder version(@Nullable Boolean value) { this.version = value; return this; } /** * Specify the time that the request should block waiting for the final response * * API name: {@code wait_for_completion_timeout} */ public final Builder waitForCompletionTimeout(@Nullable Time value) { this.waitForCompletionTimeout = value; return this; } /** * Specify the time that the request should block waiting for the final response * * API name: {@code wait_for_completion_timeout} */ public final Builder waitForCompletionTimeout(Function> fn) { return this.waitForCompletionTimeout(fn.apply(new Time.Builder()).build()); } @Override protected Builder self() { return this; } /** * Builds a {@link SubmitRequest}. * * @throws NullPointerException * if some of the required fields are null. */ public SubmitRequest build() { _checkSingleUse(); return new SubmitRequest(this); } } // --------------------------------------------------------------------------------------------- /** * Json deserializer for {@link SubmitRequest} */ public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy(Builder::new, SubmitRequest::setupSubmitRequestDeserializer); protected static void setupSubmitRequestDeserializer(ObjectDeserializer op) { op.add(Builder::source, SourceConfig._DESERIALIZER, "_source"); op.add(Builder::aggregations, JsonpDeserializer.stringMapDeserializer(Aggregation._DESERIALIZER), "aggregations", "aggs"); op.add(Builder::collapse, FieldCollapse._DESERIALIZER, "collapse"); op.add(Builder::docvalueFields, JsonpDeserializer.arrayDeserializer(FieldAndFormat._DESERIALIZER), "docvalue_fields"); op.add(Builder::explain, JsonpDeserializer.booleanDeserializer(), "explain"); op.add(Builder::fields, JsonpDeserializer.arrayDeserializer(FieldAndFormat._DESERIALIZER), "fields"); op.add(Builder::from, JsonpDeserializer.integerDeserializer(), "from"); op.add(Builder::highlight, Highlight._DESERIALIZER, "highlight"); op.add(Builder::indicesBoost, JsonpDeserializer.arrayDeserializer( JsonpDeserializer.stringMapDeserializer(JsonpDeserializer.doubleDeserializer())), "indices_boost"); op.add(Builder::minScore, JsonpDeserializer.doubleDeserializer(), "min_score"); op.add(Builder::pit, PointInTimeReference._DESERIALIZER, "pit"); op.add(Builder::postFilter, Query._DESERIALIZER, "post_filter"); op.add(Builder::profile, JsonpDeserializer.booleanDeserializer(), "profile"); op.add(Builder::query, Query._DESERIALIZER, "query"); op.add(Builder::rescore, JsonpDeserializer.arrayDeserializer(Rescore._DESERIALIZER), "rescore"); op.add(Builder::runtimeMappings, JsonpDeserializer.stringMapDeserializer( JsonpDeserializer.arrayDeserializer(RuntimeField._DESERIALIZER)), "runtime_mappings"); op.add(Builder::scriptFields, JsonpDeserializer.stringMapDeserializer(ScriptField._DESERIALIZER), "script_fields"); op.add(Builder::searchAfter, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "search_after"); op.add(Builder::seqNoPrimaryTerm, JsonpDeserializer.booleanDeserializer(), "seq_no_primary_term"); op.add(Builder::size, JsonpDeserializer.integerDeserializer(), "size"); op.add(Builder::slice, SlicedScroll._DESERIALIZER, "slice"); op.add(Builder::sort, JsonpDeserializer.arrayDeserializer(SortOptions._DESERIALIZER), "sort"); op.add(Builder::stats, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "stats"); op.add(Builder::storedFields, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "stored_fields"); op.add(Builder::suggest, Suggester._DESERIALIZER, "suggest"); op.add(Builder::terminateAfter, JsonpDeserializer.longDeserializer(), "terminate_after"); op.add(Builder::timeout, JsonpDeserializer.stringDeserializer(), "timeout"); op.add(Builder::trackScores, JsonpDeserializer.booleanDeserializer(), "track_scores"); op.add(Builder::trackTotalHits, TrackHits._DESERIALIZER, "track_total_hits"); op.add(Builder::version, JsonpDeserializer.booleanDeserializer(), "version"); } // --------------------------------------------------------------------------------------------- /** * Endpoint "{@code async_search.submit}". */ public static final SimpleEndpoint _ENDPOINT = new SimpleEndpoint<>("es/async_search.submit", // Request method request -> { return "POST"; }, // Request path request -> { final int _index = 1 << 0; int propsSet = 0; if (ApiTypeHelper.isDefined(request.index())) propsSet |= _index; if (propsSet == 0) { StringBuilder buf = new StringBuilder(); buf.append("/_async_search"); return buf.toString(); } if (propsSet == (_index)) { StringBuilder buf = new StringBuilder(); buf.append("/"); SimpleEndpoint.pathEncode(request.index.stream().map(v -> v).collect(Collectors.joining(",")), buf); buf.append("/_async_search"); return buf.toString(); } throw SimpleEndpoint.noPathTemplateFound("path"); }, // Request parameters request -> { Map params = new HashMap<>(); params.put("typed_keys", "true"); if (request.df != null) { params.put("df", request.df); } if (request.preFilterShardSize != null) { params.put("pre_filter_shard_size", String.valueOf(request.preFilterShardSize)); } if (request.minCompatibleShardNode != null) { params.put("min_compatible_shard_node", request.minCompatibleShardNode); } if (request.lenient != null) { params.put("lenient", String.valueOf(request.lenient)); } if (request.routing != null) { params.put("routing", request.routing); } if (request.ignoreUnavailable != null) { params.put("ignore_unavailable", String.valueOf(request.ignoreUnavailable)); } if (request.allowNoIndices != null) { params.put("allow_no_indices", String.valueOf(request.allowNoIndices)); } if (request.analyzer != null) { params.put("analyzer", request.analyzer); } if (request.ignoreThrottled != null) { params.put("ignore_throttled", String.valueOf(request.ignoreThrottled)); } if (request.keepOnCompletion != null) { params.put("keep_on_completion", String.valueOf(request.keepOnCompletion)); } if (request.maxConcurrentShardRequests != null) { params.put("max_concurrent_shard_requests", String.valueOf(request.maxConcurrentShardRequests)); } if (request.allowPartialSearchResults != null) { params.put("allow_partial_search_results", String.valueOf(request.allowPartialSearchResults)); } if (ApiTypeHelper.isDefined(request.expandWildcards)) { params.put("expand_wildcards", request.expandWildcards.stream().map(v -> v.jsonValue()).collect(Collectors.joining(","))); } if (request.preference != null) { params.put("preference", request.preference); } if (request.analyzeWildcard != null) { params.put("analyze_wildcard", String.valueOf(request.analyzeWildcard)); } if (request.scroll != null) { params.put("scroll", request.scroll._toJsonString()); } if (request.waitForCompletionTimeout != null) { params.put("wait_for_completion_timeout", request.waitForCompletionTimeout._toJsonString()); } if (request.searchType != null) { params.put("search_type", request.searchType.jsonValue()); } if (request.ccsMinimizeRoundtrips != null) { params.put("ccs_minimize_roundtrips", String.valueOf(request.ccsMinimizeRoundtrips)); } if (request.q != null) { params.put("q", request.q); } if (request.defaultOperator != null) { params.put("default_operator", request.defaultOperator.jsonValue()); } if (request.keepAlive != null) { params.put("keep_alive", request.keepAlive._toJsonString()); } if (request.requestCache != null) { params.put("request_cache", String.valueOf(request.requestCache)); } if (request.batchedReduceSize != null) { params.put("batched_reduce_size", String.valueOf(request.batchedReduceSize)); } return params; }, SimpleEndpoint.emptyMap(), true, SubmitResponse._DESERIALIZER); /** * Create an "{@code async_search.submit}" endpoint. */ public static Endpoint, ErrorResponse> createSubmitEndpoint( JsonpDeserializer tDocumentDeserializer) { return _ENDPOINT .withResponseDeserializer(SubmitResponse.createSubmitResponseDeserializer(tDocumentDeserializer)); } }
* API name: {@code preference} */ public final Builder preference(@Nullable String value) { this.preference = value; return this; } /** * API name: {@code profile} */ public final Builder profile(@Nullable Boolean value) { this.profile = value; return this; } /** * Query in the Lucene query string syntax *
* API name: {@code q} */ public final Builder q(@Nullable String value) { this.q = value; return this; } /** * Defines the search definition using the Query DSL. *
* API name: {@code query} */ public final Builder query(@Nullable Query value) { this.query = value; return this; } /** * Defines the search definition using the Query DSL. *
* API name: {@code query} */ public final Builder query(Function> fn) { return this.query(fn.apply(new Query.Builder()).build()); } /** * Specify if request cache should be used for this request or not, defaults to * true * * API name: {@code request_cache} */ public final Builder requestCache(@Nullable Boolean value) { this.requestCache = value; return this; } /** * API name: {@code rescore} * * Adds all elements of list to rescore. */ public final Builder rescore(List list) { this.rescore = _listAddAll(this.rescore, list); return this; } /** * API name: {@code rescore} * * Adds one or more values to rescore. */ public final Builder rescore(Rescore value, Rescore... values) { this.rescore = _listAdd(this.rescore, value, values); return this; } /** * API name: {@code rescore} * * Adds a value to rescore using a builder lambda. */ public final Builder rescore(Function> fn) { return rescore(fn.apply(new Rescore.Builder()).build()); } /** * A comma-separated list of specific routing values * * API name: {@code routing} */ public final Builder routing(@Nullable String value) { this.routing = value; return this; } /** * Defines one or more runtime fields in the search request. These fields take * precedence over mapped fields with the same name. * * API name: {@code runtime_mappings} * * Adds all entries of map to runtimeMappings. */ public final Builder runtimeMappings(Map> map) { this.runtimeMappings = _mapPutAll(this.runtimeMappings, map); return this; } /** * Defines one or more runtime fields in the search request. These fields take * precedence over mapped fields with the same name. * * API name: {@code runtime_mappings} * * Adds an entry to runtimeMappings. */ public final Builder runtimeMappings(String key, List value) { this.runtimeMappings = _mapPut(this.runtimeMappings, key, value); return this; } /** * Retrieve a script evaluation (based on different fields) for each hit. * * API name: {@code script_fields} * * Adds all entries of map to scriptFields. */ public final Builder scriptFields(Map map) { this.scriptFields = _mapPutAll(this.scriptFields, map); return this; } /** * Retrieve a script evaluation (based on different fields) for each hit. * * API name: {@code script_fields} * * Adds an entry to scriptFields. */ public final Builder scriptFields(String key, ScriptField value) { this.scriptFields = _mapPut(this.scriptFields, key, value); return this; } /** * Retrieve a script evaluation (based on different fields) for each hit. * * API name: {@code script_fields} * * Adds an entry to scriptFields using a builder lambda. */ public final Builder scriptFields(String key, Function> fn) { return scriptFields(key, fn.apply(new ScriptField.Builder()).build()); } /** * API name: {@code scroll} */ public final Builder scroll(@Nullable Time value) { this.scroll = value; return this; } /** * API name: {@code scroll} */ public final Builder scroll(Function> fn) { return this.scroll(fn.apply(new Time.Builder()).build()); } /** * API name: {@code search_after} * * Adds all elements of list to searchAfter. */ public final Builder searchAfter(List list) { this.searchAfter = _listAddAll(this.searchAfter, list); return this; } /** * API name: {@code search_after} * * Adds one or more values to searchAfter. */ public final Builder searchAfter(String value, String... values) { this.searchAfter = _listAdd(this.searchAfter, value, values); return this; } /** * Search operation type * * API name: {@code search_type} */ public final Builder searchType(@Nullable SearchType value) { this.searchType = value; return this; } /** * If true, returns sequence number and primary term of the last modification of * each hit. See Optimistic concurrency control. * * API name: {@code seq_no_primary_term} */ public final Builder seqNoPrimaryTerm(@Nullable Boolean value) { this.seqNoPrimaryTerm = value; return this; } /** * The number of hits to return. By default, you cannot page through more than * 10,000 hits using the from and size parameters. To page through more hits, * use the search_after parameter. * * API name: {@code size} */ public final Builder size(@Nullable Integer value) { this.size = value; return this; } /** * API name: {@code slice} */ public final Builder slice(@Nullable SlicedScroll value) { this.slice = value; return this; } /** * API name: {@code slice} */ public final Builder slice(Function> fn) { return this.slice(fn.apply(new SlicedScroll.Builder()).build()); } /** * API name: {@code sort} * * Adds all elements of list to sort. */ public final Builder sort(List list) { this.sort = _listAddAll(this.sort, list); return this; } /** * API name: {@code sort} * * Adds one or more values to sort. */ public final Builder sort(SortOptions value, SortOptions... values) { this.sort = _listAdd(this.sort, value, values); return this; } /** * API name: {@code sort} * * Adds a value to sort using a builder lambda. */ public final Builder sort(Function> fn) { return sort(fn.apply(new SortOptions.Builder()).build()); } /** * Stats groups to associate with the search. Each group maintains a statistics * aggregation for its associated searches. You can retrieve these stats using * the indices stats API. * * API name: {@code stats} * * Adds all elements of list to stats. */ public final Builder stats(List list) { this.stats = _listAddAll(this.stats, list); return this; } /** * Stats groups to associate with the search. Each group maintains a statistics * aggregation for its associated searches. You can retrieve these stats using * the indices stats API. * * API name: {@code stats} * * Adds one or more values to stats. */ public final Builder stats(String value, String... values) { this.stats = _listAdd(this.stats, value, values); return this; } /** * List of stored fields to return as part of a hit. If no fields are specified, * no stored fields are included in the response. If this field is specified, * the _source parameter defaults to false. You can pass _source: true to return * both source fields and stored fields in the search response. * * API name: {@code stored_fields} * * Adds all elements of list to storedFields. */ public final Builder storedFields(List list) { this.storedFields = _listAddAll(this.storedFields, list); return this; } /** * List of stored fields to return as part of a hit. If no fields are specified, * no stored fields are included in the response. If this field is specified, * the _source parameter defaults to false. You can pass _source: true to return * both source fields and stored fields in the search response. * * API name: {@code stored_fields} * * Adds one or more values to storedFields. */ public final Builder storedFields(String value, String... values) { this.storedFields = _listAdd(this.storedFields, value, values); return this; } /** * API name: {@code suggest} */ public final Builder suggest(@Nullable Suggester value) { this.suggest = value; return this; } /** * API name: {@code suggest} */ public final Builder suggest(Function> fn) { return this.suggest(fn.apply(new Suggester.Builder()).build()); } /** * Maximum number of documents to collect for each shard. If a query reaches * this limit, Elasticsearch terminates the query early. Elasticsearch collects * documents before sorting. Defaults to 0, which does not terminate query * execution early. * * API name: {@code terminate_after} */ public final Builder terminateAfter(@Nullable Long value) { this.terminateAfter = value; return this; } /** * Specifies the period of time to wait for a response from each shard. If no * response is received before the timeout expires, the request fails and * returns an error. Defaults to no timeout. * * API name: {@code timeout} */ public final Builder timeout(@Nullable String value) { this.timeout = value; return this; } /** * If true, calculate and return document scores, even if the scores are not * used for sorting. * * API name: {@code track_scores} */ public final Builder trackScores(@Nullable Boolean value) { this.trackScores = value; return this; } /** * Number of hits matching the query to count accurately. If true, the exact * number of hits is returned at the cost of some performance. If false, the * response does not include the total number of hits matching the query. * Defaults to 10,000 hits. * * API name: {@code track_total_hits} */ public final Builder trackTotalHits(@Nullable TrackHits value) { this.trackTotalHits = value; return this; } /** * Number of hits matching the query to count accurately. If true, the exact * number of hits is returned at the cost of some performance. If false, the * response does not include the total number of hits matching the query. * Defaults to 10,000 hits. * * API name: {@code track_total_hits} */ public final Builder trackTotalHits(Function> fn) { return this.trackTotalHits(fn.apply(new TrackHits.Builder()).build()); } /** * If true, returns document version as part of a hit. * * API name: {@code version} */ public final Builder version(@Nullable Boolean value) { this.version = value; return this; } /** * Specify the time that the request should block waiting for the final response * * API name: {@code wait_for_completion_timeout} */ public final Builder waitForCompletionTimeout(@Nullable Time value) { this.waitForCompletionTimeout = value; return this; } /** * Specify the time that the request should block waiting for the final response * * API name: {@code wait_for_completion_timeout} */ public final Builder waitForCompletionTimeout(Function> fn) { return this.waitForCompletionTimeout(fn.apply(new Time.Builder()).build()); } @Override protected Builder self() { return this; } /** * Builds a {@link SubmitRequest}. * * @throws NullPointerException * if some of the required fields are null. */ public SubmitRequest build() { _checkSingleUse(); return new SubmitRequest(this); } } // --------------------------------------------------------------------------------------------- /** * Json deserializer for {@link SubmitRequest} */ public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy(Builder::new, SubmitRequest::setupSubmitRequestDeserializer); protected static void setupSubmitRequestDeserializer(ObjectDeserializer op) { op.add(Builder::source, SourceConfig._DESERIALIZER, "_source"); op.add(Builder::aggregations, JsonpDeserializer.stringMapDeserializer(Aggregation._DESERIALIZER), "aggregations", "aggs"); op.add(Builder::collapse, FieldCollapse._DESERIALIZER, "collapse"); op.add(Builder::docvalueFields, JsonpDeserializer.arrayDeserializer(FieldAndFormat._DESERIALIZER), "docvalue_fields"); op.add(Builder::explain, JsonpDeserializer.booleanDeserializer(), "explain"); op.add(Builder::fields, JsonpDeserializer.arrayDeserializer(FieldAndFormat._DESERIALIZER), "fields"); op.add(Builder::from, JsonpDeserializer.integerDeserializer(), "from"); op.add(Builder::highlight, Highlight._DESERIALIZER, "highlight"); op.add(Builder::indicesBoost, JsonpDeserializer.arrayDeserializer( JsonpDeserializer.stringMapDeserializer(JsonpDeserializer.doubleDeserializer())), "indices_boost"); op.add(Builder::minScore, JsonpDeserializer.doubleDeserializer(), "min_score"); op.add(Builder::pit, PointInTimeReference._DESERIALIZER, "pit"); op.add(Builder::postFilter, Query._DESERIALIZER, "post_filter"); op.add(Builder::profile, JsonpDeserializer.booleanDeserializer(), "profile"); op.add(Builder::query, Query._DESERIALIZER, "query"); op.add(Builder::rescore, JsonpDeserializer.arrayDeserializer(Rescore._DESERIALIZER), "rescore"); op.add(Builder::runtimeMappings, JsonpDeserializer.stringMapDeserializer( JsonpDeserializer.arrayDeserializer(RuntimeField._DESERIALIZER)), "runtime_mappings"); op.add(Builder::scriptFields, JsonpDeserializer.stringMapDeserializer(ScriptField._DESERIALIZER), "script_fields"); op.add(Builder::searchAfter, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "search_after"); op.add(Builder::seqNoPrimaryTerm, JsonpDeserializer.booleanDeserializer(), "seq_no_primary_term"); op.add(Builder::size, JsonpDeserializer.integerDeserializer(), "size"); op.add(Builder::slice, SlicedScroll._DESERIALIZER, "slice"); op.add(Builder::sort, JsonpDeserializer.arrayDeserializer(SortOptions._DESERIALIZER), "sort"); op.add(Builder::stats, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "stats"); op.add(Builder::storedFields, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "stored_fields"); op.add(Builder::suggest, Suggester._DESERIALIZER, "suggest"); op.add(Builder::terminateAfter, JsonpDeserializer.longDeserializer(), "terminate_after"); op.add(Builder::timeout, JsonpDeserializer.stringDeserializer(), "timeout"); op.add(Builder::trackScores, JsonpDeserializer.booleanDeserializer(), "track_scores"); op.add(Builder::trackTotalHits, TrackHits._DESERIALIZER, "track_total_hits"); op.add(Builder::version, JsonpDeserializer.booleanDeserializer(), "version"); } // --------------------------------------------------------------------------------------------- /** * Endpoint "{@code async_search.submit}". */ public static final SimpleEndpoint _ENDPOINT = new SimpleEndpoint<>("es/async_search.submit", // Request method request -> { return "POST"; }, // Request path request -> { final int _index = 1 << 0; int propsSet = 0; if (ApiTypeHelper.isDefined(request.index())) propsSet |= _index; if (propsSet == 0) { StringBuilder buf = new StringBuilder(); buf.append("/_async_search"); return buf.toString(); } if (propsSet == (_index)) { StringBuilder buf = new StringBuilder(); buf.append("/"); SimpleEndpoint.pathEncode(request.index.stream().map(v -> v).collect(Collectors.joining(",")), buf); buf.append("/_async_search"); return buf.toString(); } throw SimpleEndpoint.noPathTemplateFound("path"); }, // Request parameters request -> { Map params = new HashMap<>(); params.put("typed_keys", "true"); if (request.df != null) { params.put("df", request.df); } if (request.preFilterShardSize != null) { params.put("pre_filter_shard_size", String.valueOf(request.preFilterShardSize)); } if (request.minCompatibleShardNode != null) { params.put("min_compatible_shard_node", request.minCompatibleShardNode); } if (request.lenient != null) { params.put("lenient", String.valueOf(request.lenient)); } if (request.routing != null) { params.put("routing", request.routing); } if (request.ignoreUnavailable != null) { params.put("ignore_unavailable", String.valueOf(request.ignoreUnavailable)); } if (request.allowNoIndices != null) { params.put("allow_no_indices", String.valueOf(request.allowNoIndices)); } if (request.analyzer != null) { params.put("analyzer", request.analyzer); } if (request.ignoreThrottled != null) { params.put("ignore_throttled", String.valueOf(request.ignoreThrottled)); } if (request.keepOnCompletion != null) { params.put("keep_on_completion", String.valueOf(request.keepOnCompletion)); } if (request.maxConcurrentShardRequests != null) { params.put("max_concurrent_shard_requests", String.valueOf(request.maxConcurrentShardRequests)); } if (request.allowPartialSearchResults != null) { params.put("allow_partial_search_results", String.valueOf(request.allowPartialSearchResults)); } if (ApiTypeHelper.isDefined(request.expandWildcards)) { params.put("expand_wildcards", request.expandWildcards.stream().map(v -> v.jsonValue()).collect(Collectors.joining(","))); } if (request.preference != null) { params.put("preference", request.preference); } if (request.analyzeWildcard != null) { params.put("analyze_wildcard", String.valueOf(request.analyzeWildcard)); } if (request.scroll != null) { params.put("scroll", request.scroll._toJsonString()); } if (request.waitForCompletionTimeout != null) { params.put("wait_for_completion_timeout", request.waitForCompletionTimeout._toJsonString()); } if (request.searchType != null) { params.put("search_type", request.searchType.jsonValue()); } if (request.ccsMinimizeRoundtrips != null) { params.put("ccs_minimize_roundtrips", String.valueOf(request.ccsMinimizeRoundtrips)); } if (request.q != null) { params.put("q", request.q); } if (request.defaultOperator != null) { params.put("default_operator", request.defaultOperator.jsonValue()); } if (request.keepAlive != null) { params.put("keep_alive", request.keepAlive._toJsonString()); } if (request.requestCache != null) { params.put("request_cache", String.valueOf(request.requestCache)); } if (request.batchedReduceSize != null) { params.put("batched_reduce_size", String.valueOf(request.batchedReduceSize)); } return params; }, SimpleEndpoint.emptyMap(), true, SubmitResponse._DESERIALIZER); /** * Create an "{@code async_search.submit}" endpoint. */ public static Endpoint, ErrorResponse> createSubmitEndpoint( JsonpDeserializer tDocumentDeserializer) { return _ENDPOINT .withResponseDeserializer(SubmitResponse.createSubmitResponseDeserializer(tDocumentDeserializer)); } }
* API name: {@code request_cache} */ public final Builder requestCache(@Nullable Boolean value) { this.requestCache = value; return this; } /** * API name: {@code rescore} *
* Adds all elements of list to rescore. */ public final Builder rescore(List list) { this.rescore = _listAddAll(this.rescore, list); return this; } /** * API name: {@code rescore} * * Adds one or more values to rescore. */ public final Builder rescore(Rescore value, Rescore... values) { this.rescore = _listAdd(this.rescore, value, values); return this; } /** * API name: {@code rescore} * * Adds a value to rescore using a builder lambda. */ public final Builder rescore(Function> fn) { return rescore(fn.apply(new Rescore.Builder()).build()); } /** * A comma-separated list of specific routing values * * API name: {@code routing} */ public final Builder routing(@Nullable String value) { this.routing = value; return this; } /** * Defines one or more runtime fields in the search request. These fields take * precedence over mapped fields with the same name. * * API name: {@code runtime_mappings} * * Adds all entries of map to runtimeMappings. */ public final Builder runtimeMappings(Map> map) { this.runtimeMappings = _mapPutAll(this.runtimeMappings, map); return this; } /** * Defines one or more runtime fields in the search request. These fields take * precedence over mapped fields with the same name. * * API name: {@code runtime_mappings} * * Adds an entry to runtimeMappings. */ public final Builder runtimeMappings(String key, List value) { this.runtimeMappings = _mapPut(this.runtimeMappings, key, value); return this; } /** * Retrieve a script evaluation (based on different fields) for each hit. * * API name: {@code script_fields} * * Adds all entries of map to scriptFields. */ public final Builder scriptFields(Map map) { this.scriptFields = _mapPutAll(this.scriptFields, map); return this; } /** * Retrieve a script evaluation (based on different fields) for each hit. * * API name: {@code script_fields} * * Adds an entry to scriptFields. */ public final Builder scriptFields(String key, ScriptField value) { this.scriptFields = _mapPut(this.scriptFields, key, value); return this; } /** * Retrieve a script evaluation (based on different fields) for each hit. * * API name: {@code script_fields} * * Adds an entry to scriptFields using a builder lambda. */ public final Builder scriptFields(String key, Function> fn) { return scriptFields(key, fn.apply(new ScriptField.Builder()).build()); } /** * API name: {@code scroll} */ public final Builder scroll(@Nullable Time value) { this.scroll = value; return this; } /** * API name: {@code scroll} */ public final Builder scroll(Function> fn) { return this.scroll(fn.apply(new Time.Builder()).build()); } /** * API name: {@code search_after} * * Adds all elements of list to searchAfter. */ public final Builder searchAfter(List list) { this.searchAfter = _listAddAll(this.searchAfter, list); return this; } /** * API name: {@code search_after} * * Adds one or more values to searchAfter. */ public final Builder searchAfter(String value, String... values) { this.searchAfter = _listAdd(this.searchAfter, value, values); return this; } /** * Search operation type * * API name: {@code search_type} */ public final Builder searchType(@Nullable SearchType value) { this.searchType = value; return this; } /** * If true, returns sequence number and primary term of the last modification of * each hit. See Optimistic concurrency control. * * API name: {@code seq_no_primary_term} */ public final Builder seqNoPrimaryTerm(@Nullable Boolean value) { this.seqNoPrimaryTerm = value; return this; } /** * The number of hits to return. By default, you cannot page through more than * 10,000 hits using the from and size parameters. To page through more hits, * use the search_after parameter. * * API name: {@code size} */ public final Builder size(@Nullable Integer value) { this.size = value; return this; } /** * API name: {@code slice} */ public final Builder slice(@Nullable SlicedScroll value) { this.slice = value; return this; } /** * API name: {@code slice} */ public final Builder slice(Function> fn) { return this.slice(fn.apply(new SlicedScroll.Builder()).build()); } /** * API name: {@code sort} * * Adds all elements of list to sort. */ public final Builder sort(List list) { this.sort = _listAddAll(this.sort, list); return this; } /** * API name: {@code sort} * * Adds one or more values to sort. */ public final Builder sort(SortOptions value, SortOptions... values) { this.sort = _listAdd(this.sort, value, values); return this; } /** * API name: {@code sort} * * Adds a value to sort using a builder lambda. */ public final Builder sort(Function> fn) { return sort(fn.apply(new SortOptions.Builder()).build()); } /** * Stats groups to associate with the search. Each group maintains a statistics * aggregation for its associated searches. You can retrieve these stats using * the indices stats API. * * API name: {@code stats} * * Adds all elements of list to stats. */ public final Builder stats(List list) { this.stats = _listAddAll(this.stats, list); return this; } /** * Stats groups to associate with the search. Each group maintains a statistics * aggregation for its associated searches. You can retrieve these stats using * the indices stats API. * * API name: {@code stats} * * Adds one or more values to stats. */ public final Builder stats(String value, String... values) { this.stats = _listAdd(this.stats, value, values); return this; } /** * List of stored fields to return as part of a hit. If no fields are specified, * no stored fields are included in the response. If this field is specified, * the _source parameter defaults to false. You can pass _source: true to return * both source fields and stored fields in the search response. * * API name: {@code stored_fields} * * Adds all elements of list to storedFields. */ public final Builder storedFields(List list) { this.storedFields = _listAddAll(this.storedFields, list); return this; } /** * List of stored fields to return as part of a hit. If no fields are specified, * no stored fields are included in the response. If this field is specified, * the _source parameter defaults to false. You can pass _source: true to return * both source fields and stored fields in the search response. * * API name: {@code stored_fields} * * Adds one or more values to storedFields. */ public final Builder storedFields(String value, String... values) { this.storedFields = _listAdd(this.storedFields, value, values); return this; } /** * API name: {@code suggest} */ public final Builder suggest(@Nullable Suggester value) { this.suggest = value; return this; } /** * API name: {@code suggest} */ public final Builder suggest(Function> fn) { return this.suggest(fn.apply(new Suggester.Builder()).build()); } /** * Maximum number of documents to collect for each shard. If a query reaches * this limit, Elasticsearch terminates the query early. Elasticsearch collects * documents before sorting. Defaults to 0, which does not terminate query * execution early. * * API name: {@code terminate_after} */ public final Builder terminateAfter(@Nullable Long value) { this.terminateAfter = value; return this; } /** * Specifies the period of time to wait for a response from each shard. If no * response is received before the timeout expires, the request fails and * returns an error. Defaults to no timeout. * * API name: {@code timeout} */ public final Builder timeout(@Nullable String value) { this.timeout = value; return this; } /** * If true, calculate and return document scores, even if the scores are not * used for sorting. * * API name: {@code track_scores} */ public final Builder trackScores(@Nullable Boolean value) { this.trackScores = value; return this; } /** * Number of hits matching the query to count accurately. If true, the exact * number of hits is returned at the cost of some performance. If false, the * response does not include the total number of hits matching the query. * Defaults to 10,000 hits. * * API name: {@code track_total_hits} */ public final Builder trackTotalHits(@Nullable TrackHits value) { this.trackTotalHits = value; return this; } /** * Number of hits matching the query to count accurately. If true, the exact * number of hits is returned at the cost of some performance. If false, the * response does not include the total number of hits matching the query. * Defaults to 10,000 hits. * * API name: {@code track_total_hits} */ public final Builder trackTotalHits(Function> fn) { return this.trackTotalHits(fn.apply(new TrackHits.Builder()).build()); } /** * If true, returns document version as part of a hit. * * API name: {@code version} */ public final Builder version(@Nullable Boolean value) { this.version = value; return this; } /** * Specify the time that the request should block waiting for the final response * * API name: {@code wait_for_completion_timeout} */ public final Builder waitForCompletionTimeout(@Nullable Time value) { this.waitForCompletionTimeout = value; return this; } /** * Specify the time that the request should block waiting for the final response * * API name: {@code wait_for_completion_timeout} */ public final Builder waitForCompletionTimeout(Function> fn) { return this.waitForCompletionTimeout(fn.apply(new Time.Builder()).build()); } @Override protected Builder self() { return this; } /** * Builds a {@link SubmitRequest}. * * @throws NullPointerException * if some of the required fields are null. */ public SubmitRequest build() { _checkSingleUse(); return new SubmitRequest(this); } } // --------------------------------------------------------------------------------------------- /** * Json deserializer for {@link SubmitRequest} */ public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy(Builder::new, SubmitRequest::setupSubmitRequestDeserializer); protected static void setupSubmitRequestDeserializer(ObjectDeserializer op) { op.add(Builder::source, SourceConfig._DESERIALIZER, "_source"); op.add(Builder::aggregations, JsonpDeserializer.stringMapDeserializer(Aggregation._DESERIALIZER), "aggregations", "aggs"); op.add(Builder::collapse, FieldCollapse._DESERIALIZER, "collapse"); op.add(Builder::docvalueFields, JsonpDeserializer.arrayDeserializer(FieldAndFormat._DESERIALIZER), "docvalue_fields"); op.add(Builder::explain, JsonpDeserializer.booleanDeserializer(), "explain"); op.add(Builder::fields, JsonpDeserializer.arrayDeserializer(FieldAndFormat._DESERIALIZER), "fields"); op.add(Builder::from, JsonpDeserializer.integerDeserializer(), "from"); op.add(Builder::highlight, Highlight._DESERIALIZER, "highlight"); op.add(Builder::indicesBoost, JsonpDeserializer.arrayDeserializer( JsonpDeserializer.stringMapDeserializer(JsonpDeserializer.doubleDeserializer())), "indices_boost"); op.add(Builder::minScore, JsonpDeserializer.doubleDeserializer(), "min_score"); op.add(Builder::pit, PointInTimeReference._DESERIALIZER, "pit"); op.add(Builder::postFilter, Query._DESERIALIZER, "post_filter"); op.add(Builder::profile, JsonpDeserializer.booleanDeserializer(), "profile"); op.add(Builder::query, Query._DESERIALIZER, "query"); op.add(Builder::rescore, JsonpDeserializer.arrayDeserializer(Rescore._DESERIALIZER), "rescore"); op.add(Builder::runtimeMappings, JsonpDeserializer.stringMapDeserializer( JsonpDeserializer.arrayDeserializer(RuntimeField._DESERIALIZER)), "runtime_mappings"); op.add(Builder::scriptFields, JsonpDeserializer.stringMapDeserializer(ScriptField._DESERIALIZER), "script_fields"); op.add(Builder::searchAfter, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "search_after"); op.add(Builder::seqNoPrimaryTerm, JsonpDeserializer.booleanDeserializer(), "seq_no_primary_term"); op.add(Builder::size, JsonpDeserializer.integerDeserializer(), "size"); op.add(Builder::slice, SlicedScroll._DESERIALIZER, "slice"); op.add(Builder::sort, JsonpDeserializer.arrayDeserializer(SortOptions._DESERIALIZER), "sort"); op.add(Builder::stats, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "stats"); op.add(Builder::storedFields, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "stored_fields"); op.add(Builder::suggest, Suggester._DESERIALIZER, "suggest"); op.add(Builder::terminateAfter, JsonpDeserializer.longDeserializer(), "terminate_after"); op.add(Builder::timeout, JsonpDeserializer.stringDeserializer(), "timeout"); op.add(Builder::trackScores, JsonpDeserializer.booleanDeserializer(), "track_scores"); op.add(Builder::trackTotalHits, TrackHits._DESERIALIZER, "track_total_hits"); op.add(Builder::version, JsonpDeserializer.booleanDeserializer(), "version"); } // --------------------------------------------------------------------------------------------- /** * Endpoint "{@code async_search.submit}". */ public static final SimpleEndpoint _ENDPOINT = new SimpleEndpoint<>("es/async_search.submit", // Request method request -> { return "POST"; }, // Request path request -> { final int _index = 1 << 0; int propsSet = 0; if (ApiTypeHelper.isDefined(request.index())) propsSet |= _index; if (propsSet == 0) { StringBuilder buf = new StringBuilder(); buf.append("/_async_search"); return buf.toString(); } if (propsSet == (_index)) { StringBuilder buf = new StringBuilder(); buf.append("/"); SimpleEndpoint.pathEncode(request.index.stream().map(v -> v).collect(Collectors.joining(",")), buf); buf.append("/_async_search"); return buf.toString(); } throw SimpleEndpoint.noPathTemplateFound("path"); }, // Request parameters request -> { Map params = new HashMap<>(); params.put("typed_keys", "true"); if (request.df != null) { params.put("df", request.df); } if (request.preFilterShardSize != null) { params.put("pre_filter_shard_size", String.valueOf(request.preFilterShardSize)); } if (request.minCompatibleShardNode != null) { params.put("min_compatible_shard_node", request.minCompatibleShardNode); } if (request.lenient != null) { params.put("lenient", String.valueOf(request.lenient)); } if (request.routing != null) { params.put("routing", request.routing); } if (request.ignoreUnavailable != null) { params.put("ignore_unavailable", String.valueOf(request.ignoreUnavailable)); } if (request.allowNoIndices != null) { params.put("allow_no_indices", String.valueOf(request.allowNoIndices)); } if (request.analyzer != null) { params.put("analyzer", request.analyzer); } if (request.ignoreThrottled != null) { params.put("ignore_throttled", String.valueOf(request.ignoreThrottled)); } if (request.keepOnCompletion != null) { params.put("keep_on_completion", String.valueOf(request.keepOnCompletion)); } if (request.maxConcurrentShardRequests != null) { params.put("max_concurrent_shard_requests", String.valueOf(request.maxConcurrentShardRequests)); } if (request.allowPartialSearchResults != null) { params.put("allow_partial_search_results", String.valueOf(request.allowPartialSearchResults)); } if (ApiTypeHelper.isDefined(request.expandWildcards)) { params.put("expand_wildcards", request.expandWildcards.stream().map(v -> v.jsonValue()).collect(Collectors.joining(","))); } if (request.preference != null) { params.put("preference", request.preference); } if (request.analyzeWildcard != null) { params.put("analyze_wildcard", String.valueOf(request.analyzeWildcard)); } if (request.scroll != null) { params.put("scroll", request.scroll._toJsonString()); } if (request.waitForCompletionTimeout != null) { params.put("wait_for_completion_timeout", request.waitForCompletionTimeout._toJsonString()); } if (request.searchType != null) { params.put("search_type", request.searchType.jsonValue()); } if (request.ccsMinimizeRoundtrips != null) { params.put("ccs_minimize_roundtrips", String.valueOf(request.ccsMinimizeRoundtrips)); } if (request.q != null) { params.put("q", request.q); } if (request.defaultOperator != null) { params.put("default_operator", request.defaultOperator.jsonValue()); } if (request.keepAlive != null) { params.put("keep_alive", request.keepAlive._toJsonString()); } if (request.requestCache != null) { params.put("request_cache", String.valueOf(request.requestCache)); } if (request.batchedReduceSize != null) { params.put("batched_reduce_size", String.valueOf(request.batchedReduceSize)); } return params; }, SimpleEndpoint.emptyMap(), true, SubmitResponse._DESERIALIZER); /** * Create an "{@code async_search.submit}" endpoint. */ public static Endpoint, ErrorResponse> createSubmitEndpoint( JsonpDeserializer tDocumentDeserializer) { return _ENDPOINT .withResponseDeserializer(SubmitResponse.createSubmitResponseDeserializer(tDocumentDeserializer)); } }
rescore
* Adds one or more values to rescore. */ public final Builder rescore(Rescore value, Rescore... values) { this.rescore = _listAdd(this.rescore, value, values); return this; } /** * API name: {@code rescore} *
* Adds a value to rescore using a builder lambda. */ public final Builder rescore(Function> fn) { return rescore(fn.apply(new Rescore.Builder()).build()); } /** * A comma-separated list of specific routing values * * API name: {@code routing} */ public final Builder routing(@Nullable String value) { this.routing = value; return this; } /** * Defines one or more runtime fields in the search request. These fields take * precedence over mapped fields with the same name. * * API name: {@code runtime_mappings} * * Adds all entries of map to runtimeMappings. */ public final Builder runtimeMappings(Map> map) { this.runtimeMappings = _mapPutAll(this.runtimeMappings, map); return this; } /** * Defines one or more runtime fields in the search request. These fields take * precedence over mapped fields with the same name. * * API name: {@code runtime_mappings} * * Adds an entry to runtimeMappings. */ public final Builder runtimeMappings(String key, List value) { this.runtimeMappings = _mapPut(this.runtimeMappings, key, value); return this; } /** * Retrieve a script evaluation (based on different fields) for each hit. * * API name: {@code script_fields} * * Adds all entries of map to scriptFields. */ public final Builder scriptFields(Map map) { this.scriptFields = _mapPutAll(this.scriptFields, map); return this; } /** * Retrieve a script evaluation (based on different fields) for each hit. * * API name: {@code script_fields} * * Adds an entry to scriptFields. */ public final Builder scriptFields(String key, ScriptField value) { this.scriptFields = _mapPut(this.scriptFields, key, value); return this; } /** * Retrieve a script evaluation (based on different fields) for each hit. * * API name: {@code script_fields} * * Adds an entry to scriptFields using a builder lambda. */ public final Builder scriptFields(String key, Function> fn) { return scriptFields(key, fn.apply(new ScriptField.Builder()).build()); } /** * API name: {@code scroll} */ public final Builder scroll(@Nullable Time value) { this.scroll = value; return this; } /** * API name: {@code scroll} */ public final Builder scroll(Function> fn) { return this.scroll(fn.apply(new Time.Builder()).build()); } /** * API name: {@code search_after} * * Adds all elements of list to searchAfter. */ public final Builder searchAfter(List list) { this.searchAfter = _listAddAll(this.searchAfter, list); return this; } /** * API name: {@code search_after} * * Adds one or more values to searchAfter. */ public final Builder searchAfter(String value, String... values) { this.searchAfter = _listAdd(this.searchAfter, value, values); return this; } /** * Search operation type * * API name: {@code search_type} */ public final Builder searchType(@Nullable SearchType value) { this.searchType = value; return this; } /** * If true, returns sequence number and primary term of the last modification of * each hit. See Optimistic concurrency control. * * API name: {@code seq_no_primary_term} */ public final Builder seqNoPrimaryTerm(@Nullable Boolean value) { this.seqNoPrimaryTerm = value; return this; } /** * The number of hits to return. By default, you cannot page through more than * 10,000 hits using the from and size parameters. To page through more hits, * use the search_after parameter. * * API name: {@code size} */ public final Builder size(@Nullable Integer value) { this.size = value; return this; } /** * API name: {@code slice} */ public final Builder slice(@Nullable SlicedScroll value) { this.slice = value; return this; } /** * API name: {@code slice} */ public final Builder slice(Function> fn) { return this.slice(fn.apply(new SlicedScroll.Builder()).build()); } /** * API name: {@code sort} * * Adds all elements of list to sort. */ public final Builder sort(List list) { this.sort = _listAddAll(this.sort, list); return this; } /** * API name: {@code sort} * * Adds one or more values to sort. */ public final Builder sort(SortOptions value, SortOptions... values) { this.sort = _listAdd(this.sort, value, values); return this; } /** * API name: {@code sort} * * Adds a value to sort using a builder lambda. */ public final Builder sort(Function> fn) { return sort(fn.apply(new SortOptions.Builder()).build()); } /** * Stats groups to associate with the search. Each group maintains a statistics * aggregation for its associated searches. You can retrieve these stats using * the indices stats API. * * API name: {@code stats} * * Adds all elements of list to stats. */ public final Builder stats(List list) { this.stats = _listAddAll(this.stats, list); return this; } /** * Stats groups to associate with the search. Each group maintains a statistics * aggregation for its associated searches. You can retrieve these stats using * the indices stats API. * * API name: {@code stats} * * Adds one or more values to stats. */ public final Builder stats(String value, String... values) { this.stats = _listAdd(this.stats, value, values); return this; } /** * List of stored fields to return as part of a hit. If no fields are specified, * no stored fields are included in the response. If this field is specified, * the _source parameter defaults to false. You can pass _source: true to return * both source fields and stored fields in the search response. * * API name: {@code stored_fields} * * Adds all elements of list to storedFields. */ public final Builder storedFields(List list) { this.storedFields = _listAddAll(this.storedFields, list); return this; } /** * List of stored fields to return as part of a hit. If no fields are specified, * no stored fields are included in the response. If this field is specified, * the _source parameter defaults to false. You can pass _source: true to return * both source fields and stored fields in the search response. * * API name: {@code stored_fields} * * Adds one or more values to storedFields. */ public final Builder storedFields(String value, String... values) { this.storedFields = _listAdd(this.storedFields, value, values); return this; } /** * API name: {@code suggest} */ public final Builder suggest(@Nullable Suggester value) { this.suggest = value; return this; } /** * API name: {@code suggest} */ public final Builder suggest(Function> fn) { return this.suggest(fn.apply(new Suggester.Builder()).build()); } /** * Maximum number of documents to collect for each shard. If a query reaches * this limit, Elasticsearch terminates the query early. Elasticsearch collects * documents before sorting. Defaults to 0, which does not terminate query * execution early. * * API name: {@code terminate_after} */ public final Builder terminateAfter(@Nullable Long value) { this.terminateAfter = value; return this; } /** * Specifies the period of time to wait for a response from each shard. If no * response is received before the timeout expires, the request fails and * returns an error. Defaults to no timeout. * * API name: {@code timeout} */ public final Builder timeout(@Nullable String value) { this.timeout = value; return this; } /** * If true, calculate and return document scores, even if the scores are not * used for sorting. * * API name: {@code track_scores} */ public final Builder trackScores(@Nullable Boolean value) { this.trackScores = value; return this; } /** * Number of hits matching the query to count accurately. If true, the exact * number of hits is returned at the cost of some performance. If false, the * response does not include the total number of hits matching the query. * Defaults to 10,000 hits. * * API name: {@code track_total_hits} */ public final Builder trackTotalHits(@Nullable TrackHits value) { this.trackTotalHits = value; return this; } /** * Number of hits matching the query to count accurately. If true, the exact * number of hits is returned at the cost of some performance. If false, the * response does not include the total number of hits matching the query. * Defaults to 10,000 hits. * * API name: {@code track_total_hits} */ public final Builder trackTotalHits(Function> fn) { return this.trackTotalHits(fn.apply(new TrackHits.Builder()).build()); } /** * If true, returns document version as part of a hit. * * API name: {@code version} */ public final Builder version(@Nullable Boolean value) { this.version = value; return this; } /** * Specify the time that the request should block waiting for the final response * * API name: {@code wait_for_completion_timeout} */ public final Builder waitForCompletionTimeout(@Nullable Time value) { this.waitForCompletionTimeout = value; return this; } /** * Specify the time that the request should block waiting for the final response * * API name: {@code wait_for_completion_timeout} */ public final Builder waitForCompletionTimeout(Function> fn) { return this.waitForCompletionTimeout(fn.apply(new Time.Builder()).build()); } @Override protected Builder self() { return this; } /** * Builds a {@link SubmitRequest}. * * @throws NullPointerException * if some of the required fields are null. */ public SubmitRequest build() { _checkSingleUse(); return new SubmitRequest(this); } } // --------------------------------------------------------------------------------------------- /** * Json deserializer for {@link SubmitRequest} */ public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy(Builder::new, SubmitRequest::setupSubmitRequestDeserializer); protected static void setupSubmitRequestDeserializer(ObjectDeserializer op) { op.add(Builder::source, SourceConfig._DESERIALIZER, "_source"); op.add(Builder::aggregations, JsonpDeserializer.stringMapDeserializer(Aggregation._DESERIALIZER), "aggregations", "aggs"); op.add(Builder::collapse, FieldCollapse._DESERIALIZER, "collapse"); op.add(Builder::docvalueFields, JsonpDeserializer.arrayDeserializer(FieldAndFormat._DESERIALIZER), "docvalue_fields"); op.add(Builder::explain, JsonpDeserializer.booleanDeserializer(), "explain"); op.add(Builder::fields, JsonpDeserializer.arrayDeserializer(FieldAndFormat._DESERIALIZER), "fields"); op.add(Builder::from, JsonpDeserializer.integerDeserializer(), "from"); op.add(Builder::highlight, Highlight._DESERIALIZER, "highlight"); op.add(Builder::indicesBoost, JsonpDeserializer.arrayDeserializer( JsonpDeserializer.stringMapDeserializer(JsonpDeserializer.doubleDeserializer())), "indices_boost"); op.add(Builder::minScore, JsonpDeserializer.doubleDeserializer(), "min_score"); op.add(Builder::pit, PointInTimeReference._DESERIALIZER, "pit"); op.add(Builder::postFilter, Query._DESERIALIZER, "post_filter"); op.add(Builder::profile, JsonpDeserializer.booleanDeserializer(), "profile"); op.add(Builder::query, Query._DESERIALIZER, "query"); op.add(Builder::rescore, JsonpDeserializer.arrayDeserializer(Rescore._DESERIALIZER), "rescore"); op.add(Builder::runtimeMappings, JsonpDeserializer.stringMapDeserializer( JsonpDeserializer.arrayDeserializer(RuntimeField._DESERIALIZER)), "runtime_mappings"); op.add(Builder::scriptFields, JsonpDeserializer.stringMapDeserializer(ScriptField._DESERIALIZER), "script_fields"); op.add(Builder::searchAfter, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "search_after"); op.add(Builder::seqNoPrimaryTerm, JsonpDeserializer.booleanDeserializer(), "seq_no_primary_term"); op.add(Builder::size, JsonpDeserializer.integerDeserializer(), "size"); op.add(Builder::slice, SlicedScroll._DESERIALIZER, "slice"); op.add(Builder::sort, JsonpDeserializer.arrayDeserializer(SortOptions._DESERIALIZER), "sort"); op.add(Builder::stats, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "stats"); op.add(Builder::storedFields, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "stored_fields"); op.add(Builder::suggest, Suggester._DESERIALIZER, "suggest"); op.add(Builder::terminateAfter, JsonpDeserializer.longDeserializer(), "terminate_after"); op.add(Builder::timeout, JsonpDeserializer.stringDeserializer(), "timeout"); op.add(Builder::trackScores, JsonpDeserializer.booleanDeserializer(), "track_scores"); op.add(Builder::trackTotalHits, TrackHits._DESERIALIZER, "track_total_hits"); op.add(Builder::version, JsonpDeserializer.booleanDeserializer(), "version"); } // --------------------------------------------------------------------------------------------- /** * Endpoint "{@code async_search.submit}". */ public static final SimpleEndpoint _ENDPOINT = new SimpleEndpoint<>("es/async_search.submit", // Request method request -> { return "POST"; }, // Request path request -> { final int _index = 1 << 0; int propsSet = 0; if (ApiTypeHelper.isDefined(request.index())) propsSet |= _index; if (propsSet == 0) { StringBuilder buf = new StringBuilder(); buf.append("/_async_search"); return buf.toString(); } if (propsSet == (_index)) { StringBuilder buf = new StringBuilder(); buf.append("/"); SimpleEndpoint.pathEncode(request.index.stream().map(v -> v).collect(Collectors.joining(",")), buf); buf.append("/_async_search"); return buf.toString(); } throw SimpleEndpoint.noPathTemplateFound("path"); }, // Request parameters request -> { Map params = new HashMap<>(); params.put("typed_keys", "true"); if (request.df != null) { params.put("df", request.df); } if (request.preFilterShardSize != null) { params.put("pre_filter_shard_size", String.valueOf(request.preFilterShardSize)); } if (request.minCompatibleShardNode != null) { params.put("min_compatible_shard_node", request.minCompatibleShardNode); } if (request.lenient != null) { params.put("lenient", String.valueOf(request.lenient)); } if (request.routing != null) { params.put("routing", request.routing); } if (request.ignoreUnavailable != null) { params.put("ignore_unavailable", String.valueOf(request.ignoreUnavailable)); } if (request.allowNoIndices != null) { params.put("allow_no_indices", String.valueOf(request.allowNoIndices)); } if (request.analyzer != null) { params.put("analyzer", request.analyzer); } if (request.ignoreThrottled != null) { params.put("ignore_throttled", String.valueOf(request.ignoreThrottled)); } if (request.keepOnCompletion != null) { params.put("keep_on_completion", String.valueOf(request.keepOnCompletion)); } if (request.maxConcurrentShardRequests != null) { params.put("max_concurrent_shard_requests", String.valueOf(request.maxConcurrentShardRequests)); } if (request.allowPartialSearchResults != null) { params.put("allow_partial_search_results", String.valueOf(request.allowPartialSearchResults)); } if (ApiTypeHelper.isDefined(request.expandWildcards)) { params.put("expand_wildcards", request.expandWildcards.stream().map(v -> v.jsonValue()).collect(Collectors.joining(","))); } if (request.preference != null) { params.put("preference", request.preference); } if (request.analyzeWildcard != null) { params.put("analyze_wildcard", String.valueOf(request.analyzeWildcard)); } if (request.scroll != null) { params.put("scroll", request.scroll._toJsonString()); } if (request.waitForCompletionTimeout != null) { params.put("wait_for_completion_timeout", request.waitForCompletionTimeout._toJsonString()); } if (request.searchType != null) { params.put("search_type", request.searchType.jsonValue()); } if (request.ccsMinimizeRoundtrips != null) { params.put("ccs_minimize_roundtrips", String.valueOf(request.ccsMinimizeRoundtrips)); } if (request.q != null) { params.put("q", request.q); } if (request.defaultOperator != null) { params.put("default_operator", request.defaultOperator.jsonValue()); } if (request.keepAlive != null) { params.put("keep_alive", request.keepAlive._toJsonString()); } if (request.requestCache != null) { params.put("request_cache", String.valueOf(request.requestCache)); } if (request.batchedReduceSize != null) { params.put("batched_reduce_size", String.valueOf(request.batchedReduceSize)); } return params; }, SimpleEndpoint.emptyMap(), true, SubmitResponse._DESERIALIZER); /** * Create an "{@code async_search.submit}" endpoint. */ public static Endpoint, ErrorResponse> createSubmitEndpoint( JsonpDeserializer tDocumentDeserializer) { return _ENDPOINT .withResponseDeserializer(SubmitResponse.createSubmitResponseDeserializer(tDocumentDeserializer)); } }
* API name: {@code routing} */ public final Builder routing(@Nullable String value) { this.routing = value; return this; } /** * Defines one or more runtime fields in the search request. These fields take * precedence over mapped fields with the same name. *
* API name: {@code runtime_mappings} *
* Adds all entries of map to runtimeMappings. */ public final Builder runtimeMappings(Map> map) { this.runtimeMappings = _mapPutAll(this.runtimeMappings, map); return this; } /** * Defines one or more runtime fields in the search request. These fields take * precedence over mapped fields with the same name. * * API name: {@code runtime_mappings} * * Adds an entry to runtimeMappings. */ public final Builder runtimeMappings(String key, List value) { this.runtimeMappings = _mapPut(this.runtimeMappings, key, value); return this; } /** * Retrieve a script evaluation (based on different fields) for each hit. * * API name: {@code script_fields} * * Adds all entries of map to scriptFields. */ public final Builder scriptFields(Map map) { this.scriptFields = _mapPutAll(this.scriptFields, map); return this; } /** * Retrieve a script evaluation (based on different fields) for each hit. * * API name: {@code script_fields} * * Adds an entry to scriptFields. */ public final Builder scriptFields(String key, ScriptField value) { this.scriptFields = _mapPut(this.scriptFields, key, value); return this; } /** * Retrieve a script evaluation (based on different fields) for each hit. * * API name: {@code script_fields} * * Adds an entry to scriptFields using a builder lambda. */ public final Builder scriptFields(String key, Function> fn) { return scriptFields(key, fn.apply(new ScriptField.Builder()).build()); } /** * API name: {@code scroll} */ public final Builder scroll(@Nullable Time value) { this.scroll = value; return this; } /** * API name: {@code scroll} */ public final Builder scroll(Function> fn) { return this.scroll(fn.apply(new Time.Builder()).build()); } /** * API name: {@code search_after} * * Adds all elements of list to searchAfter. */ public final Builder searchAfter(List list) { this.searchAfter = _listAddAll(this.searchAfter, list); return this; } /** * API name: {@code search_after} * * Adds one or more values to searchAfter. */ public final Builder searchAfter(String value, String... values) { this.searchAfter = _listAdd(this.searchAfter, value, values); return this; } /** * Search operation type * * API name: {@code search_type} */ public final Builder searchType(@Nullable SearchType value) { this.searchType = value; return this; } /** * If true, returns sequence number and primary term of the last modification of * each hit. See Optimistic concurrency control. * * API name: {@code seq_no_primary_term} */ public final Builder seqNoPrimaryTerm(@Nullable Boolean value) { this.seqNoPrimaryTerm = value; return this; } /** * The number of hits to return. By default, you cannot page through more than * 10,000 hits using the from and size parameters. To page through more hits, * use the search_after parameter. * * API name: {@code size} */ public final Builder size(@Nullable Integer value) { this.size = value; return this; } /** * API name: {@code slice} */ public final Builder slice(@Nullable SlicedScroll value) { this.slice = value; return this; } /** * API name: {@code slice} */ public final Builder slice(Function> fn) { return this.slice(fn.apply(new SlicedScroll.Builder()).build()); } /** * API name: {@code sort} * * Adds all elements of list to sort. */ public final Builder sort(List list) { this.sort = _listAddAll(this.sort, list); return this; } /** * API name: {@code sort} * * Adds one or more values to sort. */ public final Builder sort(SortOptions value, SortOptions... values) { this.sort = _listAdd(this.sort, value, values); return this; } /** * API name: {@code sort} * * Adds a value to sort using a builder lambda. */ public final Builder sort(Function> fn) { return sort(fn.apply(new SortOptions.Builder()).build()); } /** * Stats groups to associate with the search. Each group maintains a statistics * aggregation for its associated searches. You can retrieve these stats using * the indices stats API. * * API name: {@code stats} * * Adds all elements of list to stats. */ public final Builder stats(List list) { this.stats = _listAddAll(this.stats, list); return this; } /** * Stats groups to associate with the search. Each group maintains a statistics * aggregation for its associated searches. You can retrieve these stats using * the indices stats API. * * API name: {@code stats} * * Adds one or more values to stats. */ public final Builder stats(String value, String... values) { this.stats = _listAdd(this.stats, value, values); return this; } /** * List of stored fields to return as part of a hit. If no fields are specified, * no stored fields are included in the response. If this field is specified, * the _source parameter defaults to false. You can pass _source: true to return * both source fields and stored fields in the search response. * * API name: {@code stored_fields} * * Adds all elements of list to storedFields. */ public final Builder storedFields(List list) { this.storedFields = _listAddAll(this.storedFields, list); return this; } /** * List of stored fields to return as part of a hit. If no fields are specified, * no stored fields are included in the response. If this field is specified, * the _source parameter defaults to false. You can pass _source: true to return * both source fields and stored fields in the search response. * * API name: {@code stored_fields} * * Adds one or more values to storedFields. */ public final Builder storedFields(String value, String... values) { this.storedFields = _listAdd(this.storedFields, value, values); return this; } /** * API name: {@code suggest} */ public final Builder suggest(@Nullable Suggester value) { this.suggest = value; return this; } /** * API name: {@code suggest} */ public final Builder suggest(Function> fn) { return this.suggest(fn.apply(new Suggester.Builder()).build()); } /** * Maximum number of documents to collect for each shard. If a query reaches * this limit, Elasticsearch terminates the query early. Elasticsearch collects * documents before sorting. Defaults to 0, which does not terminate query * execution early. * * API name: {@code terminate_after} */ public final Builder terminateAfter(@Nullable Long value) { this.terminateAfter = value; return this; } /** * Specifies the period of time to wait for a response from each shard. If no * response is received before the timeout expires, the request fails and * returns an error. Defaults to no timeout. * * API name: {@code timeout} */ public final Builder timeout(@Nullable String value) { this.timeout = value; return this; } /** * If true, calculate and return document scores, even if the scores are not * used for sorting. * * API name: {@code track_scores} */ public final Builder trackScores(@Nullable Boolean value) { this.trackScores = value; return this; } /** * Number of hits matching the query to count accurately. If true, the exact * number of hits is returned at the cost of some performance. If false, the * response does not include the total number of hits matching the query. * Defaults to 10,000 hits. * * API name: {@code track_total_hits} */ public final Builder trackTotalHits(@Nullable TrackHits value) { this.trackTotalHits = value; return this; } /** * Number of hits matching the query to count accurately. If true, the exact * number of hits is returned at the cost of some performance. If false, the * response does not include the total number of hits matching the query. * Defaults to 10,000 hits. * * API name: {@code track_total_hits} */ public final Builder trackTotalHits(Function> fn) { return this.trackTotalHits(fn.apply(new TrackHits.Builder()).build()); } /** * If true, returns document version as part of a hit. * * API name: {@code version} */ public final Builder version(@Nullable Boolean value) { this.version = value; return this; } /** * Specify the time that the request should block waiting for the final response * * API name: {@code wait_for_completion_timeout} */ public final Builder waitForCompletionTimeout(@Nullable Time value) { this.waitForCompletionTimeout = value; return this; } /** * Specify the time that the request should block waiting for the final response * * API name: {@code wait_for_completion_timeout} */ public final Builder waitForCompletionTimeout(Function> fn) { return this.waitForCompletionTimeout(fn.apply(new Time.Builder()).build()); } @Override protected Builder self() { return this; } /** * Builds a {@link SubmitRequest}. * * @throws NullPointerException * if some of the required fields are null. */ public SubmitRequest build() { _checkSingleUse(); return new SubmitRequest(this); } } // --------------------------------------------------------------------------------------------- /** * Json deserializer for {@link SubmitRequest} */ public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy(Builder::new, SubmitRequest::setupSubmitRequestDeserializer); protected static void setupSubmitRequestDeserializer(ObjectDeserializer op) { op.add(Builder::source, SourceConfig._DESERIALIZER, "_source"); op.add(Builder::aggregations, JsonpDeserializer.stringMapDeserializer(Aggregation._DESERIALIZER), "aggregations", "aggs"); op.add(Builder::collapse, FieldCollapse._DESERIALIZER, "collapse"); op.add(Builder::docvalueFields, JsonpDeserializer.arrayDeserializer(FieldAndFormat._DESERIALIZER), "docvalue_fields"); op.add(Builder::explain, JsonpDeserializer.booleanDeserializer(), "explain"); op.add(Builder::fields, JsonpDeserializer.arrayDeserializer(FieldAndFormat._DESERIALIZER), "fields"); op.add(Builder::from, JsonpDeserializer.integerDeserializer(), "from"); op.add(Builder::highlight, Highlight._DESERIALIZER, "highlight"); op.add(Builder::indicesBoost, JsonpDeserializer.arrayDeserializer( JsonpDeserializer.stringMapDeserializer(JsonpDeserializer.doubleDeserializer())), "indices_boost"); op.add(Builder::minScore, JsonpDeserializer.doubleDeserializer(), "min_score"); op.add(Builder::pit, PointInTimeReference._DESERIALIZER, "pit"); op.add(Builder::postFilter, Query._DESERIALIZER, "post_filter"); op.add(Builder::profile, JsonpDeserializer.booleanDeserializer(), "profile"); op.add(Builder::query, Query._DESERIALIZER, "query"); op.add(Builder::rescore, JsonpDeserializer.arrayDeserializer(Rescore._DESERIALIZER), "rescore"); op.add(Builder::runtimeMappings, JsonpDeserializer.stringMapDeserializer( JsonpDeserializer.arrayDeserializer(RuntimeField._DESERIALIZER)), "runtime_mappings"); op.add(Builder::scriptFields, JsonpDeserializer.stringMapDeserializer(ScriptField._DESERIALIZER), "script_fields"); op.add(Builder::searchAfter, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "search_after"); op.add(Builder::seqNoPrimaryTerm, JsonpDeserializer.booleanDeserializer(), "seq_no_primary_term"); op.add(Builder::size, JsonpDeserializer.integerDeserializer(), "size"); op.add(Builder::slice, SlicedScroll._DESERIALIZER, "slice"); op.add(Builder::sort, JsonpDeserializer.arrayDeserializer(SortOptions._DESERIALIZER), "sort"); op.add(Builder::stats, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "stats"); op.add(Builder::storedFields, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "stored_fields"); op.add(Builder::suggest, Suggester._DESERIALIZER, "suggest"); op.add(Builder::terminateAfter, JsonpDeserializer.longDeserializer(), "terminate_after"); op.add(Builder::timeout, JsonpDeserializer.stringDeserializer(), "timeout"); op.add(Builder::trackScores, JsonpDeserializer.booleanDeserializer(), "track_scores"); op.add(Builder::trackTotalHits, TrackHits._DESERIALIZER, "track_total_hits"); op.add(Builder::version, JsonpDeserializer.booleanDeserializer(), "version"); } // --------------------------------------------------------------------------------------------- /** * Endpoint "{@code async_search.submit}". */ public static final SimpleEndpoint _ENDPOINT = new SimpleEndpoint<>("es/async_search.submit", // Request method request -> { return "POST"; }, // Request path request -> { final int _index = 1 << 0; int propsSet = 0; if (ApiTypeHelper.isDefined(request.index())) propsSet |= _index; if (propsSet == 0) { StringBuilder buf = new StringBuilder(); buf.append("/_async_search"); return buf.toString(); } if (propsSet == (_index)) { StringBuilder buf = new StringBuilder(); buf.append("/"); SimpleEndpoint.pathEncode(request.index.stream().map(v -> v).collect(Collectors.joining(",")), buf); buf.append("/_async_search"); return buf.toString(); } throw SimpleEndpoint.noPathTemplateFound("path"); }, // Request parameters request -> { Map params = new HashMap<>(); params.put("typed_keys", "true"); if (request.df != null) { params.put("df", request.df); } if (request.preFilterShardSize != null) { params.put("pre_filter_shard_size", String.valueOf(request.preFilterShardSize)); } if (request.minCompatibleShardNode != null) { params.put("min_compatible_shard_node", request.minCompatibleShardNode); } if (request.lenient != null) { params.put("lenient", String.valueOf(request.lenient)); } if (request.routing != null) { params.put("routing", request.routing); } if (request.ignoreUnavailable != null) { params.put("ignore_unavailable", String.valueOf(request.ignoreUnavailable)); } if (request.allowNoIndices != null) { params.put("allow_no_indices", String.valueOf(request.allowNoIndices)); } if (request.analyzer != null) { params.put("analyzer", request.analyzer); } if (request.ignoreThrottled != null) { params.put("ignore_throttled", String.valueOf(request.ignoreThrottled)); } if (request.keepOnCompletion != null) { params.put("keep_on_completion", String.valueOf(request.keepOnCompletion)); } if (request.maxConcurrentShardRequests != null) { params.put("max_concurrent_shard_requests", String.valueOf(request.maxConcurrentShardRequests)); } if (request.allowPartialSearchResults != null) { params.put("allow_partial_search_results", String.valueOf(request.allowPartialSearchResults)); } if (ApiTypeHelper.isDefined(request.expandWildcards)) { params.put("expand_wildcards", request.expandWildcards.stream().map(v -> v.jsonValue()).collect(Collectors.joining(","))); } if (request.preference != null) { params.put("preference", request.preference); } if (request.analyzeWildcard != null) { params.put("analyze_wildcard", String.valueOf(request.analyzeWildcard)); } if (request.scroll != null) { params.put("scroll", request.scroll._toJsonString()); } if (request.waitForCompletionTimeout != null) { params.put("wait_for_completion_timeout", request.waitForCompletionTimeout._toJsonString()); } if (request.searchType != null) { params.put("search_type", request.searchType.jsonValue()); } if (request.ccsMinimizeRoundtrips != null) { params.put("ccs_minimize_roundtrips", String.valueOf(request.ccsMinimizeRoundtrips)); } if (request.q != null) { params.put("q", request.q); } if (request.defaultOperator != null) { params.put("default_operator", request.defaultOperator.jsonValue()); } if (request.keepAlive != null) { params.put("keep_alive", request.keepAlive._toJsonString()); } if (request.requestCache != null) { params.put("request_cache", String.valueOf(request.requestCache)); } if (request.batchedReduceSize != null) { params.put("batched_reduce_size", String.valueOf(request.batchedReduceSize)); } return params; }, SimpleEndpoint.emptyMap(), true, SubmitResponse._DESERIALIZER); /** * Create an "{@code async_search.submit}" endpoint. */ public static Endpoint, ErrorResponse> createSubmitEndpoint( JsonpDeserializer tDocumentDeserializer) { return _ENDPOINT .withResponseDeserializer(SubmitResponse.createSubmitResponseDeserializer(tDocumentDeserializer)); } }
runtimeMappings
* Adds an entry to runtimeMappings. */ public final Builder runtimeMappings(String key, List value) { this.runtimeMappings = _mapPut(this.runtimeMappings, key, value); return this; } /** * Retrieve a script evaluation (based on different fields) for each hit. * * API name: {@code script_fields} * * Adds all entries of map to scriptFields. */ public final Builder scriptFields(Map map) { this.scriptFields = _mapPutAll(this.scriptFields, map); return this; } /** * Retrieve a script evaluation (based on different fields) for each hit. * * API name: {@code script_fields} * * Adds an entry to scriptFields. */ public final Builder scriptFields(String key, ScriptField value) { this.scriptFields = _mapPut(this.scriptFields, key, value); return this; } /** * Retrieve a script evaluation (based on different fields) for each hit. * * API name: {@code script_fields} * * Adds an entry to scriptFields using a builder lambda. */ public final Builder scriptFields(String key, Function> fn) { return scriptFields(key, fn.apply(new ScriptField.Builder()).build()); } /** * API name: {@code scroll} */ public final Builder scroll(@Nullable Time value) { this.scroll = value; return this; } /** * API name: {@code scroll} */ public final Builder scroll(Function> fn) { return this.scroll(fn.apply(new Time.Builder()).build()); } /** * API name: {@code search_after} * * Adds all elements of list to searchAfter. */ public final Builder searchAfter(List list) { this.searchAfter = _listAddAll(this.searchAfter, list); return this; } /** * API name: {@code search_after} * * Adds one or more values to searchAfter. */ public final Builder searchAfter(String value, String... values) { this.searchAfter = _listAdd(this.searchAfter, value, values); return this; } /** * Search operation type * * API name: {@code search_type} */ public final Builder searchType(@Nullable SearchType value) { this.searchType = value; return this; } /** * If true, returns sequence number and primary term of the last modification of * each hit. See Optimistic concurrency control. * * API name: {@code seq_no_primary_term} */ public final Builder seqNoPrimaryTerm(@Nullable Boolean value) { this.seqNoPrimaryTerm = value; return this; } /** * The number of hits to return. By default, you cannot page through more than * 10,000 hits using the from and size parameters. To page through more hits, * use the search_after parameter. * * API name: {@code size} */ public final Builder size(@Nullable Integer value) { this.size = value; return this; } /** * API name: {@code slice} */ public final Builder slice(@Nullable SlicedScroll value) { this.slice = value; return this; } /** * API name: {@code slice} */ public final Builder slice(Function> fn) { return this.slice(fn.apply(new SlicedScroll.Builder()).build()); } /** * API name: {@code sort} * * Adds all elements of list to sort. */ public final Builder sort(List list) { this.sort = _listAddAll(this.sort, list); return this; } /** * API name: {@code sort} * * Adds one or more values to sort. */ public final Builder sort(SortOptions value, SortOptions... values) { this.sort = _listAdd(this.sort, value, values); return this; } /** * API name: {@code sort} * * Adds a value to sort using a builder lambda. */ public final Builder sort(Function> fn) { return sort(fn.apply(new SortOptions.Builder()).build()); } /** * Stats groups to associate with the search. Each group maintains a statistics * aggregation for its associated searches. You can retrieve these stats using * the indices stats API. * * API name: {@code stats} * * Adds all elements of list to stats. */ public final Builder stats(List list) { this.stats = _listAddAll(this.stats, list); return this; } /** * Stats groups to associate with the search. Each group maintains a statistics * aggregation for its associated searches. You can retrieve these stats using * the indices stats API. * * API name: {@code stats} * * Adds one or more values to stats. */ public final Builder stats(String value, String... values) { this.stats = _listAdd(this.stats, value, values); return this; } /** * List of stored fields to return as part of a hit. If no fields are specified, * no stored fields are included in the response. If this field is specified, * the _source parameter defaults to false. You can pass _source: true to return * both source fields and stored fields in the search response. * * API name: {@code stored_fields} * * Adds all elements of list to storedFields. */ public final Builder storedFields(List list) { this.storedFields = _listAddAll(this.storedFields, list); return this; } /** * List of stored fields to return as part of a hit. If no fields are specified, * no stored fields are included in the response. If this field is specified, * the _source parameter defaults to false. You can pass _source: true to return * both source fields and stored fields in the search response. * * API name: {@code stored_fields} * * Adds one or more values to storedFields. */ public final Builder storedFields(String value, String... values) { this.storedFields = _listAdd(this.storedFields, value, values); return this; } /** * API name: {@code suggest} */ public final Builder suggest(@Nullable Suggester value) { this.suggest = value; return this; } /** * API name: {@code suggest} */ public final Builder suggest(Function> fn) { return this.suggest(fn.apply(new Suggester.Builder()).build()); } /** * Maximum number of documents to collect for each shard. If a query reaches * this limit, Elasticsearch terminates the query early. Elasticsearch collects * documents before sorting. Defaults to 0, which does not terminate query * execution early. * * API name: {@code terminate_after} */ public final Builder terminateAfter(@Nullable Long value) { this.terminateAfter = value; return this; } /** * Specifies the period of time to wait for a response from each shard. If no * response is received before the timeout expires, the request fails and * returns an error. Defaults to no timeout. * * API name: {@code timeout} */ public final Builder timeout(@Nullable String value) { this.timeout = value; return this; } /** * If true, calculate and return document scores, even if the scores are not * used for sorting. * * API name: {@code track_scores} */ public final Builder trackScores(@Nullable Boolean value) { this.trackScores = value; return this; } /** * Number of hits matching the query to count accurately. If true, the exact * number of hits is returned at the cost of some performance. If false, the * response does not include the total number of hits matching the query. * Defaults to 10,000 hits. * * API name: {@code track_total_hits} */ public final Builder trackTotalHits(@Nullable TrackHits value) { this.trackTotalHits = value; return this; } /** * Number of hits matching the query to count accurately. If true, the exact * number of hits is returned at the cost of some performance. If false, the * response does not include the total number of hits matching the query. * Defaults to 10,000 hits. * * API name: {@code track_total_hits} */ public final Builder trackTotalHits(Function> fn) { return this.trackTotalHits(fn.apply(new TrackHits.Builder()).build()); } /** * If true, returns document version as part of a hit. * * API name: {@code version} */ public final Builder version(@Nullable Boolean value) { this.version = value; return this; } /** * Specify the time that the request should block waiting for the final response * * API name: {@code wait_for_completion_timeout} */ public final Builder waitForCompletionTimeout(@Nullable Time value) { this.waitForCompletionTimeout = value; return this; } /** * Specify the time that the request should block waiting for the final response * * API name: {@code wait_for_completion_timeout} */ public final Builder waitForCompletionTimeout(Function> fn) { return this.waitForCompletionTimeout(fn.apply(new Time.Builder()).build()); } @Override protected Builder self() { return this; } /** * Builds a {@link SubmitRequest}. * * @throws NullPointerException * if some of the required fields are null. */ public SubmitRequest build() { _checkSingleUse(); return new SubmitRequest(this); } } // --------------------------------------------------------------------------------------------- /** * Json deserializer for {@link SubmitRequest} */ public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy(Builder::new, SubmitRequest::setupSubmitRequestDeserializer); protected static void setupSubmitRequestDeserializer(ObjectDeserializer op) { op.add(Builder::source, SourceConfig._DESERIALIZER, "_source"); op.add(Builder::aggregations, JsonpDeserializer.stringMapDeserializer(Aggregation._DESERIALIZER), "aggregations", "aggs"); op.add(Builder::collapse, FieldCollapse._DESERIALIZER, "collapse"); op.add(Builder::docvalueFields, JsonpDeserializer.arrayDeserializer(FieldAndFormat._DESERIALIZER), "docvalue_fields"); op.add(Builder::explain, JsonpDeserializer.booleanDeserializer(), "explain"); op.add(Builder::fields, JsonpDeserializer.arrayDeserializer(FieldAndFormat._DESERIALIZER), "fields"); op.add(Builder::from, JsonpDeserializer.integerDeserializer(), "from"); op.add(Builder::highlight, Highlight._DESERIALIZER, "highlight"); op.add(Builder::indicesBoost, JsonpDeserializer.arrayDeserializer( JsonpDeserializer.stringMapDeserializer(JsonpDeserializer.doubleDeserializer())), "indices_boost"); op.add(Builder::minScore, JsonpDeserializer.doubleDeserializer(), "min_score"); op.add(Builder::pit, PointInTimeReference._DESERIALIZER, "pit"); op.add(Builder::postFilter, Query._DESERIALIZER, "post_filter"); op.add(Builder::profile, JsonpDeserializer.booleanDeserializer(), "profile"); op.add(Builder::query, Query._DESERIALIZER, "query"); op.add(Builder::rescore, JsonpDeserializer.arrayDeserializer(Rescore._DESERIALIZER), "rescore"); op.add(Builder::runtimeMappings, JsonpDeserializer.stringMapDeserializer( JsonpDeserializer.arrayDeserializer(RuntimeField._DESERIALIZER)), "runtime_mappings"); op.add(Builder::scriptFields, JsonpDeserializer.stringMapDeserializer(ScriptField._DESERIALIZER), "script_fields"); op.add(Builder::searchAfter, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "search_after"); op.add(Builder::seqNoPrimaryTerm, JsonpDeserializer.booleanDeserializer(), "seq_no_primary_term"); op.add(Builder::size, JsonpDeserializer.integerDeserializer(), "size"); op.add(Builder::slice, SlicedScroll._DESERIALIZER, "slice"); op.add(Builder::sort, JsonpDeserializer.arrayDeserializer(SortOptions._DESERIALIZER), "sort"); op.add(Builder::stats, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "stats"); op.add(Builder::storedFields, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "stored_fields"); op.add(Builder::suggest, Suggester._DESERIALIZER, "suggest"); op.add(Builder::terminateAfter, JsonpDeserializer.longDeserializer(), "terminate_after"); op.add(Builder::timeout, JsonpDeserializer.stringDeserializer(), "timeout"); op.add(Builder::trackScores, JsonpDeserializer.booleanDeserializer(), "track_scores"); op.add(Builder::trackTotalHits, TrackHits._DESERIALIZER, "track_total_hits"); op.add(Builder::version, JsonpDeserializer.booleanDeserializer(), "version"); } // --------------------------------------------------------------------------------------------- /** * Endpoint "{@code async_search.submit}". */ public static final SimpleEndpoint _ENDPOINT = new SimpleEndpoint<>("es/async_search.submit", // Request method request -> { return "POST"; }, // Request path request -> { final int _index = 1 << 0; int propsSet = 0; if (ApiTypeHelper.isDefined(request.index())) propsSet |= _index; if (propsSet == 0) { StringBuilder buf = new StringBuilder(); buf.append("/_async_search"); return buf.toString(); } if (propsSet == (_index)) { StringBuilder buf = new StringBuilder(); buf.append("/"); SimpleEndpoint.pathEncode(request.index.stream().map(v -> v).collect(Collectors.joining(",")), buf); buf.append("/_async_search"); return buf.toString(); } throw SimpleEndpoint.noPathTemplateFound("path"); }, // Request parameters request -> { Map params = new HashMap<>(); params.put("typed_keys", "true"); if (request.df != null) { params.put("df", request.df); } if (request.preFilterShardSize != null) { params.put("pre_filter_shard_size", String.valueOf(request.preFilterShardSize)); } if (request.minCompatibleShardNode != null) { params.put("min_compatible_shard_node", request.minCompatibleShardNode); } if (request.lenient != null) { params.put("lenient", String.valueOf(request.lenient)); } if (request.routing != null) { params.put("routing", request.routing); } if (request.ignoreUnavailable != null) { params.put("ignore_unavailable", String.valueOf(request.ignoreUnavailable)); } if (request.allowNoIndices != null) { params.put("allow_no_indices", String.valueOf(request.allowNoIndices)); } if (request.analyzer != null) { params.put("analyzer", request.analyzer); } if (request.ignoreThrottled != null) { params.put("ignore_throttled", String.valueOf(request.ignoreThrottled)); } if (request.keepOnCompletion != null) { params.put("keep_on_completion", String.valueOf(request.keepOnCompletion)); } if (request.maxConcurrentShardRequests != null) { params.put("max_concurrent_shard_requests", String.valueOf(request.maxConcurrentShardRequests)); } if (request.allowPartialSearchResults != null) { params.put("allow_partial_search_results", String.valueOf(request.allowPartialSearchResults)); } if (ApiTypeHelper.isDefined(request.expandWildcards)) { params.put("expand_wildcards", request.expandWildcards.stream().map(v -> v.jsonValue()).collect(Collectors.joining(","))); } if (request.preference != null) { params.put("preference", request.preference); } if (request.analyzeWildcard != null) { params.put("analyze_wildcard", String.valueOf(request.analyzeWildcard)); } if (request.scroll != null) { params.put("scroll", request.scroll._toJsonString()); } if (request.waitForCompletionTimeout != null) { params.put("wait_for_completion_timeout", request.waitForCompletionTimeout._toJsonString()); } if (request.searchType != null) { params.put("search_type", request.searchType.jsonValue()); } if (request.ccsMinimizeRoundtrips != null) { params.put("ccs_minimize_roundtrips", String.valueOf(request.ccsMinimizeRoundtrips)); } if (request.q != null) { params.put("q", request.q); } if (request.defaultOperator != null) { params.put("default_operator", request.defaultOperator.jsonValue()); } if (request.keepAlive != null) { params.put("keep_alive", request.keepAlive._toJsonString()); } if (request.requestCache != null) { params.put("request_cache", String.valueOf(request.requestCache)); } if (request.batchedReduceSize != null) { params.put("batched_reduce_size", String.valueOf(request.batchedReduceSize)); } return params; }, SimpleEndpoint.emptyMap(), true, SubmitResponse._DESERIALIZER); /** * Create an "{@code async_search.submit}" endpoint. */ public static Endpoint, ErrorResponse> createSubmitEndpoint( JsonpDeserializer tDocumentDeserializer) { return _ENDPOINT .withResponseDeserializer(SubmitResponse.createSubmitResponseDeserializer(tDocumentDeserializer)); } }
* API name: {@code script_fields} *
* Adds all entries of map to scriptFields. */ public final Builder scriptFields(Map map) { this.scriptFields = _mapPutAll(this.scriptFields, map); return this; } /** * Retrieve a script evaluation (based on different fields) for each hit. * * API name: {@code script_fields} * * Adds an entry to scriptFields. */ public final Builder scriptFields(String key, ScriptField value) { this.scriptFields = _mapPut(this.scriptFields, key, value); return this; } /** * Retrieve a script evaluation (based on different fields) for each hit. * * API name: {@code script_fields} * * Adds an entry to scriptFields using a builder lambda. */ public final Builder scriptFields(String key, Function> fn) { return scriptFields(key, fn.apply(new ScriptField.Builder()).build()); } /** * API name: {@code scroll} */ public final Builder scroll(@Nullable Time value) { this.scroll = value; return this; } /** * API name: {@code scroll} */ public final Builder scroll(Function> fn) { return this.scroll(fn.apply(new Time.Builder()).build()); } /** * API name: {@code search_after} * * Adds all elements of list to searchAfter. */ public final Builder searchAfter(List list) { this.searchAfter = _listAddAll(this.searchAfter, list); return this; } /** * API name: {@code search_after} * * Adds one or more values to searchAfter. */ public final Builder searchAfter(String value, String... values) { this.searchAfter = _listAdd(this.searchAfter, value, values); return this; } /** * Search operation type * * API name: {@code search_type} */ public final Builder searchType(@Nullable SearchType value) { this.searchType = value; return this; } /** * If true, returns sequence number and primary term of the last modification of * each hit. See Optimistic concurrency control. * * API name: {@code seq_no_primary_term} */ public final Builder seqNoPrimaryTerm(@Nullable Boolean value) { this.seqNoPrimaryTerm = value; return this; } /** * The number of hits to return. By default, you cannot page through more than * 10,000 hits using the from and size parameters. To page through more hits, * use the search_after parameter. * * API name: {@code size} */ public final Builder size(@Nullable Integer value) { this.size = value; return this; } /** * API name: {@code slice} */ public final Builder slice(@Nullable SlicedScroll value) { this.slice = value; return this; } /** * API name: {@code slice} */ public final Builder slice(Function> fn) { return this.slice(fn.apply(new SlicedScroll.Builder()).build()); } /** * API name: {@code sort} * * Adds all elements of list to sort. */ public final Builder sort(List list) { this.sort = _listAddAll(this.sort, list); return this; } /** * API name: {@code sort} * * Adds one or more values to sort. */ public final Builder sort(SortOptions value, SortOptions... values) { this.sort = _listAdd(this.sort, value, values); return this; } /** * API name: {@code sort} * * Adds a value to sort using a builder lambda. */ public final Builder sort(Function> fn) { return sort(fn.apply(new SortOptions.Builder()).build()); } /** * Stats groups to associate with the search. Each group maintains a statistics * aggregation for its associated searches. You can retrieve these stats using * the indices stats API. * * API name: {@code stats} * * Adds all elements of list to stats. */ public final Builder stats(List list) { this.stats = _listAddAll(this.stats, list); return this; } /** * Stats groups to associate with the search. Each group maintains a statistics * aggregation for its associated searches. You can retrieve these stats using * the indices stats API. * * API name: {@code stats} * * Adds one or more values to stats. */ public final Builder stats(String value, String... values) { this.stats = _listAdd(this.stats, value, values); return this; } /** * List of stored fields to return as part of a hit. If no fields are specified, * no stored fields are included in the response. If this field is specified, * the _source parameter defaults to false. You can pass _source: true to return * both source fields and stored fields in the search response. * * API name: {@code stored_fields} * * Adds all elements of list to storedFields. */ public final Builder storedFields(List list) { this.storedFields = _listAddAll(this.storedFields, list); return this; } /** * List of stored fields to return as part of a hit. If no fields are specified, * no stored fields are included in the response. If this field is specified, * the _source parameter defaults to false. You can pass _source: true to return * both source fields and stored fields in the search response. * * API name: {@code stored_fields} * * Adds one or more values to storedFields. */ public final Builder storedFields(String value, String... values) { this.storedFields = _listAdd(this.storedFields, value, values); return this; } /** * API name: {@code suggest} */ public final Builder suggest(@Nullable Suggester value) { this.suggest = value; return this; } /** * API name: {@code suggest} */ public final Builder suggest(Function> fn) { return this.suggest(fn.apply(new Suggester.Builder()).build()); } /** * Maximum number of documents to collect for each shard. If a query reaches * this limit, Elasticsearch terminates the query early. Elasticsearch collects * documents before sorting. Defaults to 0, which does not terminate query * execution early. * * API name: {@code terminate_after} */ public final Builder terminateAfter(@Nullable Long value) { this.terminateAfter = value; return this; } /** * Specifies the period of time to wait for a response from each shard. If no * response is received before the timeout expires, the request fails and * returns an error. Defaults to no timeout. * * API name: {@code timeout} */ public final Builder timeout(@Nullable String value) { this.timeout = value; return this; } /** * If true, calculate and return document scores, even if the scores are not * used for sorting. * * API name: {@code track_scores} */ public final Builder trackScores(@Nullable Boolean value) { this.trackScores = value; return this; } /** * Number of hits matching the query to count accurately. If true, the exact * number of hits is returned at the cost of some performance. If false, the * response does not include the total number of hits matching the query. * Defaults to 10,000 hits. * * API name: {@code track_total_hits} */ public final Builder trackTotalHits(@Nullable TrackHits value) { this.trackTotalHits = value; return this; } /** * Number of hits matching the query to count accurately. If true, the exact * number of hits is returned at the cost of some performance. If false, the * response does not include the total number of hits matching the query. * Defaults to 10,000 hits. * * API name: {@code track_total_hits} */ public final Builder trackTotalHits(Function> fn) { return this.trackTotalHits(fn.apply(new TrackHits.Builder()).build()); } /** * If true, returns document version as part of a hit. * * API name: {@code version} */ public final Builder version(@Nullable Boolean value) { this.version = value; return this; } /** * Specify the time that the request should block waiting for the final response * * API name: {@code wait_for_completion_timeout} */ public final Builder waitForCompletionTimeout(@Nullable Time value) { this.waitForCompletionTimeout = value; return this; } /** * Specify the time that the request should block waiting for the final response * * API name: {@code wait_for_completion_timeout} */ public final Builder waitForCompletionTimeout(Function> fn) { return this.waitForCompletionTimeout(fn.apply(new Time.Builder()).build()); } @Override protected Builder self() { return this; } /** * Builds a {@link SubmitRequest}. * * @throws NullPointerException * if some of the required fields are null. */ public SubmitRequest build() { _checkSingleUse(); return new SubmitRequest(this); } } // --------------------------------------------------------------------------------------------- /** * Json deserializer for {@link SubmitRequest} */ public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy(Builder::new, SubmitRequest::setupSubmitRequestDeserializer); protected static void setupSubmitRequestDeserializer(ObjectDeserializer op) { op.add(Builder::source, SourceConfig._DESERIALIZER, "_source"); op.add(Builder::aggregations, JsonpDeserializer.stringMapDeserializer(Aggregation._DESERIALIZER), "aggregations", "aggs"); op.add(Builder::collapse, FieldCollapse._DESERIALIZER, "collapse"); op.add(Builder::docvalueFields, JsonpDeserializer.arrayDeserializer(FieldAndFormat._DESERIALIZER), "docvalue_fields"); op.add(Builder::explain, JsonpDeserializer.booleanDeserializer(), "explain"); op.add(Builder::fields, JsonpDeserializer.arrayDeserializer(FieldAndFormat._DESERIALIZER), "fields"); op.add(Builder::from, JsonpDeserializer.integerDeserializer(), "from"); op.add(Builder::highlight, Highlight._DESERIALIZER, "highlight"); op.add(Builder::indicesBoost, JsonpDeserializer.arrayDeserializer( JsonpDeserializer.stringMapDeserializer(JsonpDeserializer.doubleDeserializer())), "indices_boost"); op.add(Builder::minScore, JsonpDeserializer.doubleDeserializer(), "min_score"); op.add(Builder::pit, PointInTimeReference._DESERIALIZER, "pit"); op.add(Builder::postFilter, Query._DESERIALIZER, "post_filter"); op.add(Builder::profile, JsonpDeserializer.booleanDeserializer(), "profile"); op.add(Builder::query, Query._DESERIALIZER, "query"); op.add(Builder::rescore, JsonpDeserializer.arrayDeserializer(Rescore._DESERIALIZER), "rescore"); op.add(Builder::runtimeMappings, JsonpDeserializer.stringMapDeserializer( JsonpDeserializer.arrayDeserializer(RuntimeField._DESERIALIZER)), "runtime_mappings"); op.add(Builder::scriptFields, JsonpDeserializer.stringMapDeserializer(ScriptField._DESERIALIZER), "script_fields"); op.add(Builder::searchAfter, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "search_after"); op.add(Builder::seqNoPrimaryTerm, JsonpDeserializer.booleanDeserializer(), "seq_no_primary_term"); op.add(Builder::size, JsonpDeserializer.integerDeserializer(), "size"); op.add(Builder::slice, SlicedScroll._DESERIALIZER, "slice"); op.add(Builder::sort, JsonpDeserializer.arrayDeserializer(SortOptions._DESERIALIZER), "sort"); op.add(Builder::stats, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "stats"); op.add(Builder::storedFields, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "stored_fields"); op.add(Builder::suggest, Suggester._DESERIALIZER, "suggest"); op.add(Builder::terminateAfter, JsonpDeserializer.longDeserializer(), "terminate_after"); op.add(Builder::timeout, JsonpDeserializer.stringDeserializer(), "timeout"); op.add(Builder::trackScores, JsonpDeserializer.booleanDeserializer(), "track_scores"); op.add(Builder::trackTotalHits, TrackHits._DESERIALIZER, "track_total_hits"); op.add(Builder::version, JsonpDeserializer.booleanDeserializer(), "version"); } // --------------------------------------------------------------------------------------------- /** * Endpoint "{@code async_search.submit}". */ public static final SimpleEndpoint _ENDPOINT = new SimpleEndpoint<>("es/async_search.submit", // Request method request -> { return "POST"; }, // Request path request -> { final int _index = 1 << 0; int propsSet = 0; if (ApiTypeHelper.isDefined(request.index())) propsSet |= _index; if (propsSet == 0) { StringBuilder buf = new StringBuilder(); buf.append("/_async_search"); return buf.toString(); } if (propsSet == (_index)) { StringBuilder buf = new StringBuilder(); buf.append("/"); SimpleEndpoint.pathEncode(request.index.stream().map(v -> v).collect(Collectors.joining(",")), buf); buf.append("/_async_search"); return buf.toString(); } throw SimpleEndpoint.noPathTemplateFound("path"); }, // Request parameters request -> { Map params = new HashMap<>(); params.put("typed_keys", "true"); if (request.df != null) { params.put("df", request.df); } if (request.preFilterShardSize != null) { params.put("pre_filter_shard_size", String.valueOf(request.preFilterShardSize)); } if (request.minCompatibleShardNode != null) { params.put("min_compatible_shard_node", request.minCompatibleShardNode); } if (request.lenient != null) { params.put("lenient", String.valueOf(request.lenient)); } if (request.routing != null) { params.put("routing", request.routing); } if (request.ignoreUnavailable != null) { params.put("ignore_unavailable", String.valueOf(request.ignoreUnavailable)); } if (request.allowNoIndices != null) { params.put("allow_no_indices", String.valueOf(request.allowNoIndices)); } if (request.analyzer != null) { params.put("analyzer", request.analyzer); } if (request.ignoreThrottled != null) { params.put("ignore_throttled", String.valueOf(request.ignoreThrottled)); } if (request.keepOnCompletion != null) { params.put("keep_on_completion", String.valueOf(request.keepOnCompletion)); } if (request.maxConcurrentShardRequests != null) { params.put("max_concurrent_shard_requests", String.valueOf(request.maxConcurrentShardRequests)); } if (request.allowPartialSearchResults != null) { params.put("allow_partial_search_results", String.valueOf(request.allowPartialSearchResults)); } if (ApiTypeHelper.isDefined(request.expandWildcards)) { params.put("expand_wildcards", request.expandWildcards.stream().map(v -> v.jsonValue()).collect(Collectors.joining(","))); } if (request.preference != null) { params.put("preference", request.preference); } if (request.analyzeWildcard != null) { params.put("analyze_wildcard", String.valueOf(request.analyzeWildcard)); } if (request.scroll != null) { params.put("scroll", request.scroll._toJsonString()); } if (request.waitForCompletionTimeout != null) { params.put("wait_for_completion_timeout", request.waitForCompletionTimeout._toJsonString()); } if (request.searchType != null) { params.put("search_type", request.searchType.jsonValue()); } if (request.ccsMinimizeRoundtrips != null) { params.put("ccs_minimize_roundtrips", String.valueOf(request.ccsMinimizeRoundtrips)); } if (request.q != null) { params.put("q", request.q); } if (request.defaultOperator != null) { params.put("default_operator", request.defaultOperator.jsonValue()); } if (request.keepAlive != null) { params.put("keep_alive", request.keepAlive._toJsonString()); } if (request.requestCache != null) { params.put("request_cache", String.valueOf(request.requestCache)); } if (request.batchedReduceSize != null) { params.put("batched_reduce_size", String.valueOf(request.batchedReduceSize)); } return params; }, SimpleEndpoint.emptyMap(), true, SubmitResponse._DESERIALIZER); /** * Create an "{@code async_search.submit}" endpoint. */ public static Endpoint, ErrorResponse> createSubmitEndpoint( JsonpDeserializer tDocumentDeserializer) { return _ENDPOINT .withResponseDeserializer(SubmitResponse.createSubmitResponseDeserializer(tDocumentDeserializer)); } }
scriptFields
* Adds an entry to scriptFields. */ public final Builder scriptFields(String key, ScriptField value) { this.scriptFields = _mapPut(this.scriptFields, key, value); return this; } /** * Retrieve a script evaluation (based on different fields) for each hit. *
* Adds an entry to scriptFields using a builder lambda. */ public final Builder scriptFields(String key, Function> fn) { return scriptFields(key, fn.apply(new ScriptField.Builder()).build()); } /** * API name: {@code scroll} */ public final Builder scroll(@Nullable Time value) { this.scroll = value; return this; } /** * API name: {@code scroll} */ public final Builder scroll(Function> fn) { return this.scroll(fn.apply(new Time.Builder()).build()); } /** * API name: {@code search_after} * * Adds all elements of list to searchAfter. */ public final Builder searchAfter(List list) { this.searchAfter = _listAddAll(this.searchAfter, list); return this; } /** * API name: {@code search_after} * * Adds one or more values to searchAfter. */ public final Builder searchAfter(String value, String... values) { this.searchAfter = _listAdd(this.searchAfter, value, values); return this; } /** * Search operation type * * API name: {@code search_type} */ public final Builder searchType(@Nullable SearchType value) { this.searchType = value; return this; } /** * If true, returns sequence number and primary term of the last modification of * each hit. See Optimistic concurrency control. * * API name: {@code seq_no_primary_term} */ public final Builder seqNoPrimaryTerm(@Nullable Boolean value) { this.seqNoPrimaryTerm = value; return this; } /** * The number of hits to return. By default, you cannot page through more than * 10,000 hits using the from and size parameters. To page through more hits, * use the search_after parameter. * * API name: {@code size} */ public final Builder size(@Nullable Integer value) { this.size = value; return this; } /** * API name: {@code slice} */ public final Builder slice(@Nullable SlicedScroll value) { this.slice = value; return this; } /** * API name: {@code slice} */ public final Builder slice(Function> fn) { return this.slice(fn.apply(new SlicedScroll.Builder()).build()); } /** * API name: {@code sort} * * Adds all elements of list to sort. */ public final Builder sort(List list) { this.sort = _listAddAll(this.sort, list); return this; } /** * API name: {@code sort} * * Adds one or more values to sort. */ public final Builder sort(SortOptions value, SortOptions... values) { this.sort = _listAdd(this.sort, value, values); return this; } /** * API name: {@code sort} * * Adds a value to sort using a builder lambda. */ public final Builder sort(Function> fn) { return sort(fn.apply(new SortOptions.Builder()).build()); } /** * Stats groups to associate with the search. Each group maintains a statistics * aggregation for its associated searches. You can retrieve these stats using * the indices stats API. * * API name: {@code stats} * * Adds all elements of list to stats. */ public final Builder stats(List list) { this.stats = _listAddAll(this.stats, list); return this; } /** * Stats groups to associate with the search. Each group maintains a statistics * aggregation for its associated searches. You can retrieve these stats using * the indices stats API. * * API name: {@code stats} * * Adds one or more values to stats. */ public final Builder stats(String value, String... values) { this.stats = _listAdd(this.stats, value, values); return this; } /** * List of stored fields to return as part of a hit. If no fields are specified, * no stored fields are included in the response. If this field is specified, * the _source parameter defaults to false. You can pass _source: true to return * both source fields and stored fields in the search response. * * API name: {@code stored_fields} * * Adds all elements of list to storedFields. */ public final Builder storedFields(List list) { this.storedFields = _listAddAll(this.storedFields, list); return this; } /** * List of stored fields to return as part of a hit. If no fields are specified, * no stored fields are included in the response. If this field is specified, * the _source parameter defaults to false. You can pass _source: true to return * both source fields and stored fields in the search response. * * API name: {@code stored_fields} * * Adds one or more values to storedFields. */ public final Builder storedFields(String value, String... values) { this.storedFields = _listAdd(this.storedFields, value, values); return this; } /** * API name: {@code suggest} */ public final Builder suggest(@Nullable Suggester value) { this.suggest = value; return this; } /** * API name: {@code suggest} */ public final Builder suggest(Function> fn) { return this.suggest(fn.apply(new Suggester.Builder()).build()); } /** * Maximum number of documents to collect for each shard. If a query reaches * this limit, Elasticsearch terminates the query early. Elasticsearch collects * documents before sorting. Defaults to 0, which does not terminate query * execution early. * * API name: {@code terminate_after} */ public final Builder terminateAfter(@Nullable Long value) { this.terminateAfter = value; return this; } /** * Specifies the period of time to wait for a response from each shard. If no * response is received before the timeout expires, the request fails and * returns an error. Defaults to no timeout. * * API name: {@code timeout} */ public final Builder timeout(@Nullable String value) { this.timeout = value; return this; } /** * If true, calculate and return document scores, even if the scores are not * used for sorting. * * API name: {@code track_scores} */ public final Builder trackScores(@Nullable Boolean value) { this.trackScores = value; return this; } /** * Number of hits matching the query to count accurately. If true, the exact * number of hits is returned at the cost of some performance. If false, the * response does not include the total number of hits matching the query. * Defaults to 10,000 hits. * * API name: {@code track_total_hits} */ public final Builder trackTotalHits(@Nullable TrackHits value) { this.trackTotalHits = value; return this; } /** * Number of hits matching the query to count accurately. If true, the exact * number of hits is returned at the cost of some performance. If false, the * response does not include the total number of hits matching the query. * Defaults to 10,000 hits. * * API name: {@code track_total_hits} */ public final Builder trackTotalHits(Function> fn) { return this.trackTotalHits(fn.apply(new TrackHits.Builder()).build()); } /** * If true, returns document version as part of a hit. * * API name: {@code version} */ public final Builder version(@Nullable Boolean value) { this.version = value; return this; } /** * Specify the time that the request should block waiting for the final response * * API name: {@code wait_for_completion_timeout} */ public final Builder waitForCompletionTimeout(@Nullable Time value) { this.waitForCompletionTimeout = value; return this; } /** * Specify the time that the request should block waiting for the final response * * API name: {@code wait_for_completion_timeout} */ public final Builder waitForCompletionTimeout(Function> fn) { return this.waitForCompletionTimeout(fn.apply(new Time.Builder()).build()); } @Override protected Builder self() { return this; } /** * Builds a {@link SubmitRequest}. * * @throws NullPointerException * if some of the required fields are null. */ public SubmitRequest build() { _checkSingleUse(); return new SubmitRequest(this); } } // --------------------------------------------------------------------------------------------- /** * Json deserializer for {@link SubmitRequest} */ public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy(Builder::new, SubmitRequest::setupSubmitRequestDeserializer); protected static void setupSubmitRequestDeserializer(ObjectDeserializer op) { op.add(Builder::source, SourceConfig._DESERIALIZER, "_source"); op.add(Builder::aggregations, JsonpDeserializer.stringMapDeserializer(Aggregation._DESERIALIZER), "aggregations", "aggs"); op.add(Builder::collapse, FieldCollapse._DESERIALIZER, "collapse"); op.add(Builder::docvalueFields, JsonpDeserializer.arrayDeserializer(FieldAndFormat._DESERIALIZER), "docvalue_fields"); op.add(Builder::explain, JsonpDeserializer.booleanDeserializer(), "explain"); op.add(Builder::fields, JsonpDeserializer.arrayDeserializer(FieldAndFormat._DESERIALIZER), "fields"); op.add(Builder::from, JsonpDeserializer.integerDeserializer(), "from"); op.add(Builder::highlight, Highlight._DESERIALIZER, "highlight"); op.add(Builder::indicesBoost, JsonpDeserializer.arrayDeserializer( JsonpDeserializer.stringMapDeserializer(JsonpDeserializer.doubleDeserializer())), "indices_boost"); op.add(Builder::minScore, JsonpDeserializer.doubleDeserializer(), "min_score"); op.add(Builder::pit, PointInTimeReference._DESERIALIZER, "pit"); op.add(Builder::postFilter, Query._DESERIALIZER, "post_filter"); op.add(Builder::profile, JsonpDeserializer.booleanDeserializer(), "profile"); op.add(Builder::query, Query._DESERIALIZER, "query"); op.add(Builder::rescore, JsonpDeserializer.arrayDeserializer(Rescore._DESERIALIZER), "rescore"); op.add(Builder::runtimeMappings, JsonpDeserializer.stringMapDeserializer( JsonpDeserializer.arrayDeserializer(RuntimeField._DESERIALIZER)), "runtime_mappings"); op.add(Builder::scriptFields, JsonpDeserializer.stringMapDeserializer(ScriptField._DESERIALIZER), "script_fields"); op.add(Builder::searchAfter, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "search_after"); op.add(Builder::seqNoPrimaryTerm, JsonpDeserializer.booleanDeserializer(), "seq_no_primary_term"); op.add(Builder::size, JsonpDeserializer.integerDeserializer(), "size"); op.add(Builder::slice, SlicedScroll._DESERIALIZER, "slice"); op.add(Builder::sort, JsonpDeserializer.arrayDeserializer(SortOptions._DESERIALIZER), "sort"); op.add(Builder::stats, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "stats"); op.add(Builder::storedFields, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "stored_fields"); op.add(Builder::suggest, Suggester._DESERIALIZER, "suggest"); op.add(Builder::terminateAfter, JsonpDeserializer.longDeserializer(), "terminate_after"); op.add(Builder::timeout, JsonpDeserializer.stringDeserializer(), "timeout"); op.add(Builder::trackScores, JsonpDeserializer.booleanDeserializer(), "track_scores"); op.add(Builder::trackTotalHits, TrackHits._DESERIALIZER, "track_total_hits"); op.add(Builder::version, JsonpDeserializer.booleanDeserializer(), "version"); } // --------------------------------------------------------------------------------------------- /** * Endpoint "{@code async_search.submit}". */ public static final SimpleEndpoint _ENDPOINT = new SimpleEndpoint<>("es/async_search.submit", // Request method request -> { return "POST"; }, // Request path request -> { final int _index = 1 << 0; int propsSet = 0; if (ApiTypeHelper.isDefined(request.index())) propsSet |= _index; if (propsSet == 0) { StringBuilder buf = new StringBuilder(); buf.append("/_async_search"); return buf.toString(); } if (propsSet == (_index)) { StringBuilder buf = new StringBuilder(); buf.append("/"); SimpleEndpoint.pathEncode(request.index.stream().map(v -> v).collect(Collectors.joining(",")), buf); buf.append("/_async_search"); return buf.toString(); } throw SimpleEndpoint.noPathTemplateFound("path"); }, // Request parameters request -> { Map params = new HashMap<>(); params.put("typed_keys", "true"); if (request.df != null) { params.put("df", request.df); } if (request.preFilterShardSize != null) { params.put("pre_filter_shard_size", String.valueOf(request.preFilterShardSize)); } if (request.minCompatibleShardNode != null) { params.put("min_compatible_shard_node", request.minCompatibleShardNode); } if (request.lenient != null) { params.put("lenient", String.valueOf(request.lenient)); } if (request.routing != null) { params.put("routing", request.routing); } if (request.ignoreUnavailable != null) { params.put("ignore_unavailable", String.valueOf(request.ignoreUnavailable)); } if (request.allowNoIndices != null) { params.put("allow_no_indices", String.valueOf(request.allowNoIndices)); } if (request.analyzer != null) { params.put("analyzer", request.analyzer); } if (request.ignoreThrottled != null) { params.put("ignore_throttled", String.valueOf(request.ignoreThrottled)); } if (request.keepOnCompletion != null) { params.put("keep_on_completion", String.valueOf(request.keepOnCompletion)); } if (request.maxConcurrentShardRequests != null) { params.put("max_concurrent_shard_requests", String.valueOf(request.maxConcurrentShardRequests)); } if (request.allowPartialSearchResults != null) { params.put("allow_partial_search_results", String.valueOf(request.allowPartialSearchResults)); } if (ApiTypeHelper.isDefined(request.expandWildcards)) { params.put("expand_wildcards", request.expandWildcards.stream().map(v -> v.jsonValue()).collect(Collectors.joining(","))); } if (request.preference != null) { params.put("preference", request.preference); } if (request.analyzeWildcard != null) { params.put("analyze_wildcard", String.valueOf(request.analyzeWildcard)); } if (request.scroll != null) { params.put("scroll", request.scroll._toJsonString()); } if (request.waitForCompletionTimeout != null) { params.put("wait_for_completion_timeout", request.waitForCompletionTimeout._toJsonString()); } if (request.searchType != null) { params.put("search_type", request.searchType.jsonValue()); } if (request.ccsMinimizeRoundtrips != null) { params.put("ccs_minimize_roundtrips", String.valueOf(request.ccsMinimizeRoundtrips)); } if (request.q != null) { params.put("q", request.q); } if (request.defaultOperator != null) { params.put("default_operator", request.defaultOperator.jsonValue()); } if (request.keepAlive != null) { params.put("keep_alive", request.keepAlive._toJsonString()); } if (request.requestCache != null) { params.put("request_cache", String.valueOf(request.requestCache)); } if (request.batchedReduceSize != null) { params.put("batched_reduce_size", String.valueOf(request.batchedReduceSize)); } return params; }, SimpleEndpoint.emptyMap(), true, SubmitResponse._DESERIALIZER); /** * Create an "{@code async_search.submit}" endpoint. */ public static Endpoint, ErrorResponse> createSubmitEndpoint( JsonpDeserializer tDocumentDeserializer) { return _ENDPOINT .withResponseDeserializer(SubmitResponse.createSubmitResponseDeserializer(tDocumentDeserializer)); } }
* Adds all elements of list to searchAfter. */ public final Builder searchAfter(List list) { this.searchAfter = _listAddAll(this.searchAfter, list); return this; } /** * API name: {@code search_after} * * Adds one or more values to searchAfter. */ public final Builder searchAfter(String value, String... values) { this.searchAfter = _listAdd(this.searchAfter, value, values); return this; } /** * Search operation type * * API name: {@code search_type} */ public final Builder searchType(@Nullable SearchType value) { this.searchType = value; return this; } /** * If true, returns sequence number and primary term of the last modification of * each hit. See Optimistic concurrency control. * * API name: {@code seq_no_primary_term} */ public final Builder seqNoPrimaryTerm(@Nullable Boolean value) { this.seqNoPrimaryTerm = value; return this; } /** * The number of hits to return. By default, you cannot page through more than * 10,000 hits using the from and size parameters. To page through more hits, * use the search_after parameter. * * API name: {@code size} */ public final Builder size(@Nullable Integer value) { this.size = value; return this; } /** * API name: {@code slice} */ public final Builder slice(@Nullable SlicedScroll value) { this.slice = value; return this; } /** * API name: {@code slice} */ public final Builder slice(Function> fn) { return this.slice(fn.apply(new SlicedScroll.Builder()).build()); } /** * API name: {@code sort} * * Adds all elements of list to sort. */ public final Builder sort(List list) { this.sort = _listAddAll(this.sort, list); return this; } /** * API name: {@code sort} * * Adds one or more values to sort. */ public final Builder sort(SortOptions value, SortOptions... values) { this.sort = _listAdd(this.sort, value, values); return this; } /** * API name: {@code sort} * * Adds a value to sort using a builder lambda. */ public final Builder sort(Function> fn) { return sort(fn.apply(new SortOptions.Builder()).build()); } /** * Stats groups to associate with the search. Each group maintains a statistics * aggregation for its associated searches. You can retrieve these stats using * the indices stats API. * * API name: {@code stats} * * Adds all elements of list to stats. */ public final Builder stats(List list) { this.stats = _listAddAll(this.stats, list); return this; } /** * Stats groups to associate with the search. Each group maintains a statistics * aggregation for its associated searches. You can retrieve these stats using * the indices stats API. * * API name: {@code stats} * * Adds one or more values to stats. */ public final Builder stats(String value, String... values) { this.stats = _listAdd(this.stats, value, values); return this; } /** * List of stored fields to return as part of a hit. If no fields are specified, * no stored fields are included in the response. If this field is specified, * the _source parameter defaults to false. You can pass _source: true to return * both source fields and stored fields in the search response. * * API name: {@code stored_fields} * * Adds all elements of list to storedFields. */ public final Builder storedFields(List list) { this.storedFields = _listAddAll(this.storedFields, list); return this; } /** * List of stored fields to return as part of a hit. If no fields are specified, * no stored fields are included in the response. If this field is specified, * the _source parameter defaults to false. You can pass _source: true to return * both source fields and stored fields in the search response. * * API name: {@code stored_fields} * * Adds one or more values to storedFields. */ public final Builder storedFields(String value, String... values) { this.storedFields = _listAdd(this.storedFields, value, values); return this; } /** * API name: {@code suggest} */ public final Builder suggest(@Nullable Suggester value) { this.suggest = value; return this; } /** * API name: {@code suggest} */ public final Builder suggest(Function> fn) { return this.suggest(fn.apply(new Suggester.Builder()).build()); } /** * Maximum number of documents to collect for each shard. If a query reaches * this limit, Elasticsearch terminates the query early. Elasticsearch collects * documents before sorting. Defaults to 0, which does not terminate query * execution early. * * API name: {@code terminate_after} */ public final Builder terminateAfter(@Nullable Long value) { this.terminateAfter = value; return this; } /** * Specifies the period of time to wait for a response from each shard. If no * response is received before the timeout expires, the request fails and * returns an error. Defaults to no timeout. * * API name: {@code timeout} */ public final Builder timeout(@Nullable String value) { this.timeout = value; return this; } /** * If true, calculate and return document scores, even if the scores are not * used for sorting. * * API name: {@code track_scores} */ public final Builder trackScores(@Nullable Boolean value) { this.trackScores = value; return this; } /** * Number of hits matching the query to count accurately. If true, the exact * number of hits is returned at the cost of some performance. If false, the * response does not include the total number of hits matching the query. * Defaults to 10,000 hits. * * API name: {@code track_total_hits} */ public final Builder trackTotalHits(@Nullable TrackHits value) { this.trackTotalHits = value; return this; } /** * Number of hits matching the query to count accurately. If true, the exact * number of hits is returned at the cost of some performance. If false, the * response does not include the total number of hits matching the query. * Defaults to 10,000 hits. * * API name: {@code track_total_hits} */ public final Builder trackTotalHits(Function> fn) { return this.trackTotalHits(fn.apply(new TrackHits.Builder()).build()); } /** * If true, returns document version as part of a hit. * * API name: {@code version} */ public final Builder version(@Nullable Boolean value) { this.version = value; return this; } /** * Specify the time that the request should block waiting for the final response * * API name: {@code wait_for_completion_timeout} */ public final Builder waitForCompletionTimeout(@Nullable Time value) { this.waitForCompletionTimeout = value; return this; } /** * Specify the time that the request should block waiting for the final response * * API name: {@code wait_for_completion_timeout} */ public final Builder waitForCompletionTimeout(Function> fn) { return this.waitForCompletionTimeout(fn.apply(new Time.Builder()).build()); } @Override protected Builder self() { return this; } /** * Builds a {@link SubmitRequest}. * * @throws NullPointerException * if some of the required fields are null. */ public SubmitRequest build() { _checkSingleUse(); return new SubmitRequest(this); } } // --------------------------------------------------------------------------------------------- /** * Json deserializer for {@link SubmitRequest} */ public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy(Builder::new, SubmitRequest::setupSubmitRequestDeserializer); protected static void setupSubmitRequestDeserializer(ObjectDeserializer op) { op.add(Builder::source, SourceConfig._DESERIALIZER, "_source"); op.add(Builder::aggregations, JsonpDeserializer.stringMapDeserializer(Aggregation._DESERIALIZER), "aggregations", "aggs"); op.add(Builder::collapse, FieldCollapse._DESERIALIZER, "collapse"); op.add(Builder::docvalueFields, JsonpDeserializer.arrayDeserializer(FieldAndFormat._DESERIALIZER), "docvalue_fields"); op.add(Builder::explain, JsonpDeserializer.booleanDeserializer(), "explain"); op.add(Builder::fields, JsonpDeserializer.arrayDeserializer(FieldAndFormat._DESERIALIZER), "fields"); op.add(Builder::from, JsonpDeserializer.integerDeserializer(), "from"); op.add(Builder::highlight, Highlight._DESERIALIZER, "highlight"); op.add(Builder::indicesBoost, JsonpDeserializer.arrayDeserializer( JsonpDeserializer.stringMapDeserializer(JsonpDeserializer.doubleDeserializer())), "indices_boost"); op.add(Builder::minScore, JsonpDeserializer.doubleDeserializer(), "min_score"); op.add(Builder::pit, PointInTimeReference._DESERIALIZER, "pit"); op.add(Builder::postFilter, Query._DESERIALIZER, "post_filter"); op.add(Builder::profile, JsonpDeserializer.booleanDeserializer(), "profile"); op.add(Builder::query, Query._DESERIALIZER, "query"); op.add(Builder::rescore, JsonpDeserializer.arrayDeserializer(Rescore._DESERIALIZER), "rescore"); op.add(Builder::runtimeMappings, JsonpDeserializer.stringMapDeserializer( JsonpDeserializer.arrayDeserializer(RuntimeField._DESERIALIZER)), "runtime_mappings"); op.add(Builder::scriptFields, JsonpDeserializer.stringMapDeserializer(ScriptField._DESERIALIZER), "script_fields"); op.add(Builder::searchAfter, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "search_after"); op.add(Builder::seqNoPrimaryTerm, JsonpDeserializer.booleanDeserializer(), "seq_no_primary_term"); op.add(Builder::size, JsonpDeserializer.integerDeserializer(), "size"); op.add(Builder::slice, SlicedScroll._DESERIALIZER, "slice"); op.add(Builder::sort, JsonpDeserializer.arrayDeserializer(SortOptions._DESERIALIZER), "sort"); op.add(Builder::stats, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "stats"); op.add(Builder::storedFields, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "stored_fields"); op.add(Builder::suggest, Suggester._DESERIALIZER, "suggest"); op.add(Builder::terminateAfter, JsonpDeserializer.longDeserializer(), "terminate_after"); op.add(Builder::timeout, JsonpDeserializer.stringDeserializer(), "timeout"); op.add(Builder::trackScores, JsonpDeserializer.booleanDeserializer(), "track_scores"); op.add(Builder::trackTotalHits, TrackHits._DESERIALIZER, "track_total_hits"); op.add(Builder::version, JsonpDeserializer.booleanDeserializer(), "version"); } // --------------------------------------------------------------------------------------------- /** * Endpoint "{@code async_search.submit}". */ public static final SimpleEndpoint _ENDPOINT = new SimpleEndpoint<>("es/async_search.submit", // Request method request -> { return "POST"; }, // Request path request -> { final int _index = 1 << 0; int propsSet = 0; if (ApiTypeHelper.isDefined(request.index())) propsSet |= _index; if (propsSet == 0) { StringBuilder buf = new StringBuilder(); buf.append("/_async_search"); return buf.toString(); } if (propsSet == (_index)) { StringBuilder buf = new StringBuilder(); buf.append("/"); SimpleEndpoint.pathEncode(request.index.stream().map(v -> v).collect(Collectors.joining(",")), buf); buf.append("/_async_search"); return buf.toString(); } throw SimpleEndpoint.noPathTemplateFound("path"); }, // Request parameters request -> { Map params = new HashMap<>(); params.put("typed_keys", "true"); if (request.df != null) { params.put("df", request.df); } if (request.preFilterShardSize != null) { params.put("pre_filter_shard_size", String.valueOf(request.preFilterShardSize)); } if (request.minCompatibleShardNode != null) { params.put("min_compatible_shard_node", request.minCompatibleShardNode); } if (request.lenient != null) { params.put("lenient", String.valueOf(request.lenient)); } if (request.routing != null) { params.put("routing", request.routing); } if (request.ignoreUnavailable != null) { params.put("ignore_unavailable", String.valueOf(request.ignoreUnavailable)); } if (request.allowNoIndices != null) { params.put("allow_no_indices", String.valueOf(request.allowNoIndices)); } if (request.analyzer != null) { params.put("analyzer", request.analyzer); } if (request.ignoreThrottled != null) { params.put("ignore_throttled", String.valueOf(request.ignoreThrottled)); } if (request.keepOnCompletion != null) { params.put("keep_on_completion", String.valueOf(request.keepOnCompletion)); } if (request.maxConcurrentShardRequests != null) { params.put("max_concurrent_shard_requests", String.valueOf(request.maxConcurrentShardRequests)); } if (request.allowPartialSearchResults != null) { params.put("allow_partial_search_results", String.valueOf(request.allowPartialSearchResults)); } if (ApiTypeHelper.isDefined(request.expandWildcards)) { params.put("expand_wildcards", request.expandWildcards.stream().map(v -> v.jsonValue()).collect(Collectors.joining(","))); } if (request.preference != null) { params.put("preference", request.preference); } if (request.analyzeWildcard != null) { params.put("analyze_wildcard", String.valueOf(request.analyzeWildcard)); } if (request.scroll != null) { params.put("scroll", request.scroll._toJsonString()); } if (request.waitForCompletionTimeout != null) { params.put("wait_for_completion_timeout", request.waitForCompletionTimeout._toJsonString()); } if (request.searchType != null) { params.put("search_type", request.searchType.jsonValue()); } if (request.ccsMinimizeRoundtrips != null) { params.put("ccs_minimize_roundtrips", String.valueOf(request.ccsMinimizeRoundtrips)); } if (request.q != null) { params.put("q", request.q); } if (request.defaultOperator != null) { params.put("default_operator", request.defaultOperator.jsonValue()); } if (request.keepAlive != null) { params.put("keep_alive", request.keepAlive._toJsonString()); } if (request.requestCache != null) { params.put("request_cache", String.valueOf(request.requestCache)); } if (request.batchedReduceSize != null) { params.put("batched_reduce_size", String.valueOf(request.batchedReduceSize)); } return params; }, SimpleEndpoint.emptyMap(), true, SubmitResponse._DESERIALIZER); /** * Create an "{@code async_search.submit}" endpoint. */ public static Endpoint, ErrorResponse> createSubmitEndpoint( JsonpDeserializer tDocumentDeserializer) { return _ENDPOINT .withResponseDeserializer(SubmitResponse.createSubmitResponseDeserializer(tDocumentDeserializer)); } }
searchAfter
* Adds one or more values to searchAfter. */ public final Builder searchAfter(String value, String... values) { this.searchAfter = _listAdd(this.searchAfter, value, values); return this; } /** * Search operation type *
* API name: {@code search_type} */ public final Builder searchType(@Nullable SearchType value) { this.searchType = value; return this; } /** * If true, returns sequence number and primary term of the last modification of * each hit. See Optimistic concurrency control. *
* API name: {@code seq_no_primary_term} */ public final Builder seqNoPrimaryTerm(@Nullable Boolean value) { this.seqNoPrimaryTerm = value; return this; } /** * The number of hits to return. By default, you cannot page through more than * 10,000 hits using the from and size parameters. To page through more hits, * use the search_after parameter. *
* API name: {@code size} */ public final Builder size(@Nullable Integer value) { this.size = value; return this; } /** * API name: {@code slice} */ public final Builder slice(@Nullable SlicedScroll value) { this.slice = value; return this; } /** * API name: {@code slice} */ public final Builder slice(Function> fn) { return this.slice(fn.apply(new SlicedScroll.Builder()).build()); } /** * API name: {@code sort} * * Adds all elements of list to sort. */ public final Builder sort(List list) { this.sort = _listAddAll(this.sort, list); return this; } /** * API name: {@code sort} * * Adds one or more values to sort. */ public final Builder sort(SortOptions value, SortOptions... values) { this.sort = _listAdd(this.sort, value, values); return this; } /** * API name: {@code sort} * * Adds a value to sort using a builder lambda. */ public final Builder sort(Function> fn) { return sort(fn.apply(new SortOptions.Builder()).build()); } /** * Stats groups to associate with the search. Each group maintains a statistics * aggregation for its associated searches. You can retrieve these stats using * the indices stats API. * * API name: {@code stats} * * Adds all elements of list to stats. */ public final Builder stats(List list) { this.stats = _listAddAll(this.stats, list); return this; } /** * Stats groups to associate with the search. Each group maintains a statistics * aggregation for its associated searches. You can retrieve these stats using * the indices stats API. * * API name: {@code stats} * * Adds one or more values to stats. */ public final Builder stats(String value, String... values) { this.stats = _listAdd(this.stats, value, values); return this; } /** * List of stored fields to return as part of a hit. If no fields are specified, * no stored fields are included in the response. If this field is specified, * the _source parameter defaults to false. You can pass _source: true to return * both source fields and stored fields in the search response. * * API name: {@code stored_fields} * * Adds all elements of list to storedFields. */ public final Builder storedFields(List list) { this.storedFields = _listAddAll(this.storedFields, list); return this; } /** * List of stored fields to return as part of a hit. If no fields are specified, * no stored fields are included in the response. If this field is specified, * the _source parameter defaults to false. You can pass _source: true to return * both source fields and stored fields in the search response. * * API name: {@code stored_fields} * * Adds one or more values to storedFields. */ public final Builder storedFields(String value, String... values) { this.storedFields = _listAdd(this.storedFields, value, values); return this; } /** * API name: {@code suggest} */ public final Builder suggest(@Nullable Suggester value) { this.suggest = value; return this; } /** * API name: {@code suggest} */ public final Builder suggest(Function> fn) { return this.suggest(fn.apply(new Suggester.Builder()).build()); } /** * Maximum number of documents to collect for each shard. If a query reaches * this limit, Elasticsearch terminates the query early. Elasticsearch collects * documents before sorting. Defaults to 0, which does not terminate query * execution early. * * API name: {@code terminate_after} */ public final Builder terminateAfter(@Nullable Long value) { this.terminateAfter = value; return this; } /** * Specifies the period of time to wait for a response from each shard. If no * response is received before the timeout expires, the request fails and * returns an error. Defaults to no timeout. * * API name: {@code timeout} */ public final Builder timeout(@Nullable String value) { this.timeout = value; return this; } /** * If true, calculate and return document scores, even if the scores are not * used for sorting. * * API name: {@code track_scores} */ public final Builder trackScores(@Nullable Boolean value) { this.trackScores = value; return this; } /** * Number of hits matching the query to count accurately. If true, the exact * number of hits is returned at the cost of some performance. If false, the * response does not include the total number of hits matching the query. * Defaults to 10,000 hits. * * API name: {@code track_total_hits} */ public final Builder trackTotalHits(@Nullable TrackHits value) { this.trackTotalHits = value; return this; } /** * Number of hits matching the query to count accurately. If true, the exact * number of hits is returned at the cost of some performance. If false, the * response does not include the total number of hits matching the query. * Defaults to 10,000 hits. * * API name: {@code track_total_hits} */ public final Builder trackTotalHits(Function> fn) { return this.trackTotalHits(fn.apply(new TrackHits.Builder()).build()); } /** * If true, returns document version as part of a hit. * * API name: {@code version} */ public final Builder version(@Nullable Boolean value) { this.version = value; return this; } /** * Specify the time that the request should block waiting for the final response * * API name: {@code wait_for_completion_timeout} */ public final Builder waitForCompletionTimeout(@Nullable Time value) { this.waitForCompletionTimeout = value; return this; } /** * Specify the time that the request should block waiting for the final response * * API name: {@code wait_for_completion_timeout} */ public final Builder waitForCompletionTimeout(Function> fn) { return this.waitForCompletionTimeout(fn.apply(new Time.Builder()).build()); } @Override protected Builder self() { return this; } /** * Builds a {@link SubmitRequest}. * * @throws NullPointerException * if some of the required fields are null. */ public SubmitRequest build() { _checkSingleUse(); return new SubmitRequest(this); } } // --------------------------------------------------------------------------------------------- /** * Json deserializer for {@link SubmitRequest} */ public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy(Builder::new, SubmitRequest::setupSubmitRequestDeserializer); protected static void setupSubmitRequestDeserializer(ObjectDeserializer op) { op.add(Builder::source, SourceConfig._DESERIALIZER, "_source"); op.add(Builder::aggregations, JsonpDeserializer.stringMapDeserializer(Aggregation._DESERIALIZER), "aggregations", "aggs"); op.add(Builder::collapse, FieldCollapse._DESERIALIZER, "collapse"); op.add(Builder::docvalueFields, JsonpDeserializer.arrayDeserializer(FieldAndFormat._DESERIALIZER), "docvalue_fields"); op.add(Builder::explain, JsonpDeserializer.booleanDeserializer(), "explain"); op.add(Builder::fields, JsonpDeserializer.arrayDeserializer(FieldAndFormat._DESERIALIZER), "fields"); op.add(Builder::from, JsonpDeserializer.integerDeserializer(), "from"); op.add(Builder::highlight, Highlight._DESERIALIZER, "highlight"); op.add(Builder::indicesBoost, JsonpDeserializer.arrayDeserializer( JsonpDeserializer.stringMapDeserializer(JsonpDeserializer.doubleDeserializer())), "indices_boost"); op.add(Builder::minScore, JsonpDeserializer.doubleDeserializer(), "min_score"); op.add(Builder::pit, PointInTimeReference._DESERIALIZER, "pit"); op.add(Builder::postFilter, Query._DESERIALIZER, "post_filter"); op.add(Builder::profile, JsonpDeserializer.booleanDeserializer(), "profile"); op.add(Builder::query, Query._DESERIALIZER, "query"); op.add(Builder::rescore, JsonpDeserializer.arrayDeserializer(Rescore._DESERIALIZER), "rescore"); op.add(Builder::runtimeMappings, JsonpDeserializer.stringMapDeserializer( JsonpDeserializer.arrayDeserializer(RuntimeField._DESERIALIZER)), "runtime_mappings"); op.add(Builder::scriptFields, JsonpDeserializer.stringMapDeserializer(ScriptField._DESERIALIZER), "script_fields"); op.add(Builder::searchAfter, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "search_after"); op.add(Builder::seqNoPrimaryTerm, JsonpDeserializer.booleanDeserializer(), "seq_no_primary_term"); op.add(Builder::size, JsonpDeserializer.integerDeserializer(), "size"); op.add(Builder::slice, SlicedScroll._DESERIALIZER, "slice"); op.add(Builder::sort, JsonpDeserializer.arrayDeserializer(SortOptions._DESERIALIZER), "sort"); op.add(Builder::stats, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "stats"); op.add(Builder::storedFields, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "stored_fields"); op.add(Builder::suggest, Suggester._DESERIALIZER, "suggest"); op.add(Builder::terminateAfter, JsonpDeserializer.longDeserializer(), "terminate_after"); op.add(Builder::timeout, JsonpDeserializer.stringDeserializer(), "timeout"); op.add(Builder::trackScores, JsonpDeserializer.booleanDeserializer(), "track_scores"); op.add(Builder::trackTotalHits, TrackHits._DESERIALIZER, "track_total_hits"); op.add(Builder::version, JsonpDeserializer.booleanDeserializer(), "version"); } // --------------------------------------------------------------------------------------------- /** * Endpoint "{@code async_search.submit}". */ public static final SimpleEndpoint _ENDPOINT = new SimpleEndpoint<>("es/async_search.submit", // Request method request -> { return "POST"; }, // Request path request -> { final int _index = 1 << 0; int propsSet = 0; if (ApiTypeHelper.isDefined(request.index())) propsSet |= _index; if (propsSet == 0) { StringBuilder buf = new StringBuilder(); buf.append("/_async_search"); return buf.toString(); } if (propsSet == (_index)) { StringBuilder buf = new StringBuilder(); buf.append("/"); SimpleEndpoint.pathEncode(request.index.stream().map(v -> v).collect(Collectors.joining(",")), buf); buf.append("/_async_search"); return buf.toString(); } throw SimpleEndpoint.noPathTemplateFound("path"); }, // Request parameters request -> { Map params = new HashMap<>(); params.put("typed_keys", "true"); if (request.df != null) { params.put("df", request.df); } if (request.preFilterShardSize != null) { params.put("pre_filter_shard_size", String.valueOf(request.preFilterShardSize)); } if (request.minCompatibleShardNode != null) { params.put("min_compatible_shard_node", request.minCompatibleShardNode); } if (request.lenient != null) { params.put("lenient", String.valueOf(request.lenient)); } if (request.routing != null) { params.put("routing", request.routing); } if (request.ignoreUnavailable != null) { params.put("ignore_unavailable", String.valueOf(request.ignoreUnavailable)); } if (request.allowNoIndices != null) { params.put("allow_no_indices", String.valueOf(request.allowNoIndices)); } if (request.analyzer != null) { params.put("analyzer", request.analyzer); } if (request.ignoreThrottled != null) { params.put("ignore_throttled", String.valueOf(request.ignoreThrottled)); } if (request.keepOnCompletion != null) { params.put("keep_on_completion", String.valueOf(request.keepOnCompletion)); } if (request.maxConcurrentShardRequests != null) { params.put("max_concurrent_shard_requests", String.valueOf(request.maxConcurrentShardRequests)); } if (request.allowPartialSearchResults != null) { params.put("allow_partial_search_results", String.valueOf(request.allowPartialSearchResults)); } if (ApiTypeHelper.isDefined(request.expandWildcards)) { params.put("expand_wildcards", request.expandWildcards.stream().map(v -> v.jsonValue()).collect(Collectors.joining(","))); } if (request.preference != null) { params.put("preference", request.preference); } if (request.analyzeWildcard != null) { params.put("analyze_wildcard", String.valueOf(request.analyzeWildcard)); } if (request.scroll != null) { params.put("scroll", request.scroll._toJsonString()); } if (request.waitForCompletionTimeout != null) { params.put("wait_for_completion_timeout", request.waitForCompletionTimeout._toJsonString()); } if (request.searchType != null) { params.put("search_type", request.searchType.jsonValue()); } if (request.ccsMinimizeRoundtrips != null) { params.put("ccs_minimize_roundtrips", String.valueOf(request.ccsMinimizeRoundtrips)); } if (request.q != null) { params.put("q", request.q); } if (request.defaultOperator != null) { params.put("default_operator", request.defaultOperator.jsonValue()); } if (request.keepAlive != null) { params.put("keep_alive", request.keepAlive._toJsonString()); } if (request.requestCache != null) { params.put("request_cache", String.valueOf(request.requestCache)); } if (request.batchedReduceSize != null) { params.put("batched_reduce_size", String.valueOf(request.batchedReduceSize)); } return params; }, SimpleEndpoint.emptyMap(), true, SubmitResponse._DESERIALIZER); /** * Create an "{@code async_search.submit}" endpoint. */ public static Endpoint, ErrorResponse> createSubmitEndpoint( JsonpDeserializer tDocumentDeserializer) { return _ENDPOINT .withResponseDeserializer(SubmitResponse.createSubmitResponseDeserializer(tDocumentDeserializer)); } }
* Adds all elements of list to sort. */ public final Builder sort(List list) { this.sort = _listAddAll(this.sort, list); return this; } /** * API name: {@code sort} * * Adds one or more values to sort. */ public final Builder sort(SortOptions value, SortOptions... values) { this.sort = _listAdd(this.sort, value, values); return this; } /** * API name: {@code sort} * * Adds a value to sort using a builder lambda. */ public final Builder sort(Function> fn) { return sort(fn.apply(new SortOptions.Builder()).build()); } /** * Stats groups to associate with the search. Each group maintains a statistics * aggregation for its associated searches. You can retrieve these stats using * the indices stats API. * * API name: {@code stats} * * Adds all elements of list to stats. */ public final Builder stats(List list) { this.stats = _listAddAll(this.stats, list); return this; } /** * Stats groups to associate with the search. Each group maintains a statistics * aggregation for its associated searches. You can retrieve these stats using * the indices stats API. * * API name: {@code stats} * * Adds one or more values to stats. */ public final Builder stats(String value, String... values) { this.stats = _listAdd(this.stats, value, values); return this; } /** * List of stored fields to return as part of a hit. If no fields are specified, * no stored fields are included in the response. If this field is specified, * the _source parameter defaults to false. You can pass _source: true to return * both source fields and stored fields in the search response. * * API name: {@code stored_fields} * * Adds all elements of list to storedFields. */ public final Builder storedFields(List list) { this.storedFields = _listAddAll(this.storedFields, list); return this; } /** * List of stored fields to return as part of a hit. If no fields are specified, * no stored fields are included in the response. If this field is specified, * the _source parameter defaults to false. You can pass _source: true to return * both source fields and stored fields in the search response. * * API name: {@code stored_fields} * * Adds one or more values to storedFields. */ public final Builder storedFields(String value, String... values) { this.storedFields = _listAdd(this.storedFields, value, values); return this; } /** * API name: {@code suggest} */ public final Builder suggest(@Nullable Suggester value) { this.suggest = value; return this; } /** * API name: {@code suggest} */ public final Builder suggest(Function> fn) { return this.suggest(fn.apply(new Suggester.Builder()).build()); } /** * Maximum number of documents to collect for each shard. If a query reaches * this limit, Elasticsearch terminates the query early. Elasticsearch collects * documents before sorting. Defaults to 0, which does not terminate query * execution early. * * API name: {@code terminate_after} */ public final Builder terminateAfter(@Nullable Long value) { this.terminateAfter = value; return this; } /** * Specifies the period of time to wait for a response from each shard. If no * response is received before the timeout expires, the request fails and * returns an error. Defaults to no timeout. * * API name: {@code timeout} */ public final Builder timeout(@Nullable String value) { this.timeout = value; return this; } /** * If true, calculate and return document scores, even if the scores are not * used for sorting. * * API name: {@code track_scores} */ public final Builder trackScores(@Nullable Boolean value) { this.trackScores = value; return this; } /** * Number of hits matching the query to count accurately. If true, the exact * number of hits is returned at the cost of some performance. If false, the * response does not include the total number of hits matching the query. * Defaults to 10,000 hits. * * API name: {@code track_total_hits} */ public final Builder trackTotalHits(@Nullable TrackHits value) { this.trackTotalHits = value; return this; } /** * Number of hits matching the query to count accurately. If true, the exact * number of hits is returned at the cost of some performance. If false, the * response does not include the total number of hits matching the query. * Defaults to 10,000 hits. * * API name: {@code track_total_hits} */ public final Builder trackTotalHits(Function> fn) { return this.trackTotalHits(fn.apply(new TrackHits.Builder()).build()); } /** * If true, returns document version as part of a hit. * * API name: {@code version} */ public final Builder version(@Nullable Boolean value) { this.version = value; return this; } /** * Specify the time that the request should block waiting for the final response * * API name: {@code wait_for_completion_timeout} */ public final Builder waitForCompletionTimeout(@Nullable Time value) { this.waitForCompletionTimeout = value; return this; } /** * Specify the time that the request should block waiting for the final response * * API name: {@code wait_for_completion_timeout} */ public final Builder waitForCompletionTimeout(Function> fn) { return this.waitForCompletionTimeout(fn.apply(new Time.Builder()).build()); } @Override protected Builder self() { return this; } /** * Builds a {@link SubmitRequest}. * * @throws NullPointerException * if some of the required fields are null. */ public SubmitRequest build() { _checkSingleUse(); return new SubmitRequest(this); } } // --------------------------------------------------------------------------------------------- /** * Json deserializer for {@link SubmitRequest} */ public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy(Builder::new, SubmitRequest::setupSubmitRequestDeserializer); protected static void setupSubmitRequestDeserializer(ObjectDeserializer op) { op.add(Builder::source, SourceConfig._DESERIALIZER, "_source"); op.add(Builder::aggregations, JsonpDeserializer.stringMapDeserializer(Aggregation._DESERIALIZER), "aggregations", "aggs"); op.add(Builder::collapse, FieldCollapse._DESERIALIZER, "collapse"); op.add(Builder::docvalueFields, JsonpDeserializer.arrayDeserializer(FieldAndFormat._DESERIALIZER), "docvalue_fields"); op.add(Builder::explain, JsonpDeserializer.booleanDeserializer(), "explain"); op.add(Builder::fields, JsonpDeserializer.arrayDeserializer(FieldAndFormat._DESERIALIZER), "fields"); op.add(Builder::from, JsonpDeserializer.integerDeserializer(), "from"); op.add(Builder::highlight, Highlight._DESERIALIZER, "highlight"); op.add(Builder::indicesBoost, JsonpDeserializer.arrayDeserializer( JsonpDeserializer.stringMapDeserializer(JsonpDeserializer.doubleDeserializer())), "indices_boost"); op.add(Builder::minScore, JsonpDeserializer.doubleDeserializer(), "min_score"); op.add(Builder::pit, PointInTimeReference._DESERIALIZER, "pit"); op.add(Builder::postFilter, Query._DESERIALIZER, "post_filter"); op.add(Builder::profile, JsonpDeserializer.booleanDeserializer(), "profile"); op.add(Builder::query, Query._DESERIALIZER, "query"); op.add(Builder::rescore, JsonpDeserializer.arrayDeserializer(Rescore._DESERIALIZER), "rescore"); op.add(Builder::runtimeMappings, JsonpDeserializer.stringMapDeserializer( JsonpDeserializer.arrayDeserializer(RuntimeField._DESERIALIZER)), "runtime_mappings"); op.add(Builder::scriptFields, JsonpDeserializer.stringMapDeserializer(ScriptField._DESERIALIZER), "script_fields"); op.add(Builder::searchAfter, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "search_after"); op.add(Builder::seqNoPrimaryTerm, JsonpDeserializer.booleanDeserializer(), "seq_no_primary_term"); op.add(Builder::size, JsonpDeserializer.integerDeserializer(), "size"); op.add(Builder::slice, SlicedScroll._DESERIALIZER, "slice"); op.add(Builder::sort, JsonpDeserializer.arrayDeserializer(SortOptions._DESERIALIZER), "sort"); op.add(Builder::stats, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "stats"); op.add(Builder::storedFields, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "stored_fields"); op.add(Builder::suggest, Suggester._DESERIALIZER, "suggest"); op.add(Builder::terminateAfter, JsonpDeserializer.longDeserializer(), "terminate_after"); op.add(Builder::timeout, JsonpDeserializer.stringDeserializer(), "timeout"); op.add(Builder::trackScores, JsonpDeserializer.booleanDeserializer(), "track_scores"); op.add(Builder::trackTotalHits, TrackHits._DESERIALIZER, "track_total_hits"); op.add(Builder::version, JsonpDeserializer.booleanDeserializer(), "version"); } // --------------------------------------------------------------------------------------------- /** * Endpoint "{@code async_search.submit}". */ public static final SimpleEndpoint _ENDPOINT = new SimpleEndpoint<>("es/async_search.submit", // Request method request -> { return "POST"; }, // Request path request -> { final int _index = 1 << 0; int propsSet = 0; if (ApiTypeHelper.isDefined(request.index())) propsSet |= _index; if (propsSet == 0) { StringBuilder buf = new StringBuilder(); buf.append("/_async_search"); return buf.toString(); } if (propsSet == (_index)) { StringBuilder buf = new StringBuilder(); buf.append("/"); SimpleEndpoint.pathEncode(request.index.stream().map(v -> v).collect(Collectors.joining(",")), buf); buf.append("/_async_search"); return buf.toString(); } throw SimpleEndpoint.noPathTemplateFound("path"); }, // Request parameters request -> { Map params = new HashMap<>(); params.put("typed_keys", "true"); if (request.df != null) { params.put("df", request.df); } if (request.preFilterShardSize != null) { params.put("pre_filter_shard_size", String.valueOf(request.preFilterShardSize)); } if (request.minCompatibleShardNode != null) { params.put("min_compatible_shard_node", request.minCompatibleShardNode); } if (request.lenient != null) { params.put("lenient", String.valueOf(request.lenient)); } if (request.routing != null) { params.put("routing", request.routing); } if (request.ignoreUnavailable != null) { params.put("ignore_unavailable", String.valueOf(request.ignoreUnavailable)); } if (request.allowNoIndices != null) { params.put("allow_no_indices", String.valueOf(request.allowNoIndices)); } if (request.analyzer != null) { params.put("analyzer", request.analyzer); } if (request.ignoreThrottled != null) { params.put("ignore_throttled", String.valueOf(request.ignoreThrottled)); } if (request.keepOnCompletion != null) { params.put("keep_on_completion", String.valueOf(request.keepOnCompletion)); } if (request.maxConcurrentShardRequests != null) { params.put("max_concurrent_shard_requests", String.valueOf(request.maxConcurrentShardRequests)); } if (request.allowPartialSearchResults != null) { params.put("allow_partial_search_results", String.valueOf(request.allowPartialSearchResults)); } if (ApiTypeHelper.isDefined(request.expandWildcards)) { params.put("expand_wildcards", request.expandWildcards.stream().map(v -> v.jsonValue()).collect(Collectors.joining(","))); } if (request.preference != null) { params.put("preference", request.preference); } if (request.analyzeWildcard != null) { params.put("analyze_wildcard", String.valueOf(request.analyzeWildcard)); } if (request.scroll != null) { params.put("scroll", request.scroll._toJsonString()); } if (request.waitForCompletionTimeout != null) { params.put("wait_for_completion_timeout", request.waitForCompletionTimeout._toJsonString()); } if (request.searchType != null) { params.put("search_type", request.searchType.jsonValue()); } if (request.ccsMinimizeRoundtrips != null) { params.put("ccs_minimize_roundtrips", String.valueOf(request.ccsMinimizeRoundtrips)); } if (request.q != null) { params.put("q", request.q); } if (request.defaultOperator != null) { params.put("default_operator", request.defaultOperator.jsonValue()); } if (request.keepAlive != null) { params.put("keep_alive", request.keepAlive._toJsonString()); } if (request.requestCache != null) { params.put("request_cache", String.valueOf(request.requestCache)); } if (request.batchedReduceSize != null) { params.put("batched_reduce_size", String.valueOf(request.batchedReduceSize)); } return params; }, SimpleEndpoint.emptyMap(), true, SubmitResponse._DESERIALIZER); /** * Create an "{@code async_search.submit}" endpoint. */ public static Endpoint, ErrorResponse> createSubmitEndpoint( JsonpDeserializer tDocumentDeserializer) { return _ENDPOINT .withResponseDeserializer(SubmitResponse.createSubmitResponseDeserializer(tDocumentDeserializer)); } }
sort
* Adds one or more values to sort. */ public final Builder sort(SortOptions value, SortOptions... values) { this.sort = _listAdd(this.sort, value, values); return this; } /** * API name: {@code sort} *
* Adds a value to sort using a builder lambda. */ public final Builder sort(Function> fn) { return sort(fn.apply(new SortOptions.Builder()).build()); } /** * Stats groups to associate with the search. Each group maintains a statistics * aggregation for its associated searches. You can retrieve these stats using * the indices stats API. * * API name: {@code stats} * * Adds all elements of list to stats. */ public final Builder stats(List list) { this.stats = _listAddAll(this.stats, list); return this; } /** * Stats groups to associate with the search. Each group maintains a statistics * aggregation for its associated searches. You can retrieve these stats using * the indices stats API. * * API name: {@code stats} * * Adds one or more values to stats. */ public final Builder stats(String value, String... values) { this.stats = _listAdd(this.stats, value, values); return this; } /** * List of stored fields to return as part of a hit. If no fields are specified, * no stored fields are included in the response. If this field is specified, * the _source parameter defaults to false. You can pass _source: true to return * both source fields and stored fields in the search response. * * API name: {@code stored_fields} * * Adds all elements of list to storedFields. */ public final Builder storedFields(List list) { this.storedFields = _listAddAll(this.storedFields, list); return this; } /** * List of stored fields to return as part of a hit. If no fields are specified, * no stored fields are included in the response. If this field is specified, * the _source parameter defaults to false. You can pass _source: true to return * both source fields and stored fields in the search response. * * API name: {@code stored_fields} * * Adds one or more values to storedFields. */ public final Builder storedFields(String value, String... values) { this.storedFields = _listAdd(this.storedFields, value, values); return this; } /** * API name: {@code suggest} */ public final Builder suggest(@Nullable Suggester value) { this.suggest = value; return this; } /** * API name: {@code suggest} */ public final Builder suggest(Function> fn) { return this.suggest(fn.apply(new Suggester.Builder()).build()); } /** * Maximum number of documents to collect for each shard. If a query reaches * this limit, Elasticsearch terminates the query early. Elasticsearch collects * documents before sorting. Defaults to 0, which does not terminate query * execution early. * * API name: {@code terminate_after} */ public final Builder terminateAfter(@Nullable Long value) { this.terminateAfter = value; return this; } /** * Specifies the period of time to wait for a response from each shard. If no * response is received before the timeout expires, the request fails and * returns an error. Defaults to no timeout. * * API name: {@code timeout} */ public final Builder timeout(@Nullable String value) { this.timeout = value; return this; } /** * If true, calculate and return document scores, even if the scores are not * used for sorting. * * API name: {@code track_scores} */ public final Builder trackScores(@Nullable Boolean value) { this.trackScores = value; return this; } /** * Number of hits matching the query to count accurately. If true, the exact * number of hits is returned at the cost of some performance. If false, the * response does not include the total number of hits matching the query. * Defaults to 10,000 hits. * * API name: {@code track_total_hits} */ public final Builder trackTotalHits(@Nullable TrackHits value) { this.trackTotalHits = value; return this; } /** * Number of hits matching the query to count accurately. If true, the exact * number of hits is returned at the cost of some performance. If false, the * response does not include the total number of hits matching the query. * Defaults to 10,000 hits. * * API name: {@code track_total_hits} */ public final Builder trackTotalHits(Function> fn) { return this.trackTotalHits(fn.apply(new TrackHits.Builder()).build()); } /** * If true, returns document version as part of a hit. * * API name: {@code version} */ public final Builder version(@Nullable Boolean value) { this.version = value; return this; } /** * Specify the time that the request should block waiting for the final response * * API name: {@code wait_for_completion_timeout} */ public final Builder waitForCompletionTimeout(@Nullable Time value) { this.waitForCompletionTimeout = value; return this; } /** * Specify the time that the request should block waiting for the final response * * API name: {@code wait_for_completion_timeout} */ public final Builder waitForCompletionTimeout(Function> fn) { return this.waitForCompletionTimeout(fn.apply(new Time.Builder()).build()); } @Override protected Builder self() { return this; } /** * Builds a {@link SubmitRequest}. * * @throws NullPointerException * if some of the required fields are null. */ public SubmitRequest build() { _checkSingleUse(); return new SubmitRequest(this); } } // --------------------------------------------------------------------------------------------- /** * Json deserializer for {@link SubmitRequest} */ public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy(Builder::new, SubmitRequest::setupSubmitRequestDeserializer); protected static void setupSubmitRequestDeserializer(ObjectDeserializer op) { op.add(Builder::source, SourceConfig._DESERIALIZER, "_source"); op.add(Builder::aggregations, JsonpDeserializer.stringMapDeserializer(Aggregation._DESERIALIZER), "aggregations", "aggs"); op.add(Builder::collapse, FieldCollapse._DESERIALIZER, "collapse"); op.add(Builder::docvalueFields, JsonpDeserializer.arrayDeserializer(FieldAndFormat._DESERIALIZER), "docvalue_fields"); op.add(Builder::explain, JsonpDeserializer.booleanDeserializer(), "explain"); op.add(Builder::fields, JsonpDeserializer.arrayDeserializer(FieldAndFormat._DESERIALIZER), "fields"); op.add(Builder::from, JsonpDeserializer.integerDeserializer(), "from"); op.add(Builder::highlight, Highlight._DESERIALIZER, "highlight"); op.add(Builder::indicesBoost, JsonpDeserializer.arrayDeserializer( JsonpDeserializer.stringMapDeserializer(JsonpDeserializer.doubleDeserializer())), "indices_boost"); op.add(Builder::minScore, JsonpDeserializer.doubleDeserializer(), "min_score"); op.add(Builder::pit, PointInTimeReference._DESERIALIZER, "pit"); op.add(Builder::postFilter, Query._DESERIALIZER, "post_filter"); op.add(Builder::profile, JsonpDeserializer.booleanDeserializer(), "profile"); op.add(Builder::query, Query._DESERIALIZER, "query"); op.add(Builder::rescore, JsonpDeserializer.arrayDeserializer(Rescore._DESERIALIZER), "rescore"); op.add(Builder::runtimeMappings, JsonpDeserializer.stringMapDeserializer( JsonpDeserializer.arrayDeserializer(RuntimeField._DESERIALIZER)), "runtime_mappings"); op.add(Builder::scriptFields, JsonpDeserializer.stringMapDeserializer(ScriptField._DESERIALIZER), "script_fields"); op.add(Builder::searchAfter, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "search_after"); op.add(Builder::seqNoPrimaryTerm, JsonpDeserializer.booleanDeserializer(), "seq_no_primary_term"); op.add(Builder::size, JsonpDeserializer.integerDeserializer(), "size"); op.add(Builder::slice, SlicedScroll._DESERIALIZER, "slice"); op.add(Builder::sort, JsonpDeserializer.arrayDeserializer(SortOptions._DESERIALIZER), "sort"); op.add(Builder::stats, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "stats"); op.add(Builder::storedFields, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "stored_fields"); op.add(Builder::suggest, Suggester._DESERIALIZER, "suggest"); op.add(Builder::terminateAfter, JsonpDeserializer.longDeserializer(), "terminate_after"); op.add(Builder::timeout, JsonpDeserializer.stringDeserializer(), "timeout"); op.add(Builder::trackScores, JsonpDeserializer.booleanDeserializer(), "track_scores"); op.add(Builder::trackTotalHits, TrackHits._DESERIALIZER, "track_total_hits"); op.add(Builder::version, JsonpDeserializer.booleanDeserializer(), "version"); } // --------------------------------------------------------------------------------------------- /** * Endpoint "{@code async_search.submit}". */ public static final SimpleEndpoint _ENDPOINT = new SimpleEndpoint<>("es/async_search.submit", // Request method request -> { return "POST"; }, // Request path request -> { final int _index = 1 << 0; int propsSet = 0; if (ApiTypeHelper.isDefined(request.index())) propsSet |= _index; if (propsSet == 0) { StringBuilder buf = new StringBuilder(); buf.append("/_async_search"); return buf.toString(); } if (propsSet == (_index)) { StringBuilder buf = new StringBuilder(); buf.append("/"); SimpleEndpoint.pathEncode(request.index.stream().map(v -> v).collect(Collectors.joining(",")), buf); buf.append("/_async_search"); return buf.toString(); } throw SimpleEndpoint.noPathTemplateFound("path"); }, // Request parameters request -> { Map params = new HashMap<>(); params.put("typed_keys", "true"); if (request.df != null) { params.put("df", request.df); } if (request.preFilterShardSize != null) { params.put("pre_filter_shard_size", String.valueOf(request.preFilterShardSize)); } if (request.minCompatibleShardNode != null) { params.put("min_compatible_shard_node", request.minCompatibleShardNode); } if (request.lenient != null) { params.put("lenient", String.valueOf(request.lenient)); } if (request.routing != null) { params.put("routing", request.routing); } if (request.ignoreUnavailable != null) { params.put("ignore_unavailable", String.valueOf(request.ignoreUnavailable)); } if (request.allowNoIndices != null) { params.put("allow_no_indices", String.valueOf(request.allowNoIndices)); } if (request.analyzer != null) { params.put("analyzer", request.analyzer); } if (request.ignoreThrottled != null) { params.put("ignore_throttled", String.valueOf(request.ignoreThrottled)); } if (request.keepOnCompletion != null) { params.put("keep_on_completion", String.valueOf(request.keepOnCompletion)); } if (request.maxConcurrentShardRequests != null) { params.put("max_concurrent_shard_requests", String.valueOf(request.maxConcurrentShardRequests)); } if (request.allowPartialSearchResults != null) { params.put("allow_partial_search_results", String.valueOf(request.allowPartialSearchResults)); } if (ApiTypeHelper.isDefined(request.expandWildcards)) { params.put("expand_wildcards", request.expandWildcards.stream().map(v -> v.jsonValue()).collect(Collectors.joining(","))); } if (request.preference != null) { params.put("preference", request.preference); } if (request.analyzeWildcard != null) { params.put("analyze_wildcard", String.valueOf(request.analyzeWildcard)); } if (request.scroll != null) { params.put("scroll", request.scroll._toJsonString()); } if (request.waitForCompletionTimeout != null) { params.put("wait_for_completion_timeout", request.waitForCompletionTimeout._toJsonString()); } if (request.searchType != null) { params.put("search_type", request.searchType.jsonValue()); } if (request.ccsMinimizeRoundtrips != null) { params.put("ccs_minimize_roundtrips", String.valueOf(request.ccsMinimizeRoundtrips)); } if (request.q != null) { params.put("q", request.q); } if (request.defaultOperator != null) { params.put("default_operator", request.defaultOperator.jsonValue()); } if (request.keepAlive != null) { params.put("keep_alive", request.keepAlive._toJsonString()); } if (request.requestCache != null) { params.put("request_cache", String.valueOf(request.requestCache)); } if (request.batchedReduceSize != null) { params.put("batched_reduce_size", String.valueOf(request.batchedReduceSize)); } return params; }, SimpleEndpoint.emptyMap(), true, SubmitResponse._DESERIALIZER); /** * Create an "{@code async_search.submit}" endpoint. */ public static Endpoint, ErrorResponse> createSubmitEndpoint( JsonpDeserializer tDocumentDeserializer) { return _ENDPOINT .withResponseDeserializer(SubmitResponse.createSubmitResponseDeserializer(tDocumentDeserializer)); } }
* API name: {@code stats} *
* Adds all elements of list to stats. */ public final Builder stats(List list) { this.stats = _listAddAll(this.stats, list); return this; } /** * Stats groups to associate with the search. Each group maintains a statistics * aggregation for its associated searches. You can retrieve these stats using * the indices stats API. * * API name: {@code stats} * * Adds one or more values to stats. */ public final Builder stats(String value, String... values) { this.stats = _listAdd(this.stats, value, values); return this; } /** * List of stored fields to return as part of a hit. If no fields are specified, * no stored fields are included in the response. If this field is specified, * the _source parameter defaults to false. You can pass _source: true to return * both source fields and stored fields in the search response. * * API name: {@code stored_fields} * * Adds all elements of list to storedFields. */ public final Builder storedFields(List list) { this.storedFields = _listAddAll(this.storedFields, list); return this; } /** * List of stored fields to return as part of a hit. If no fields are specified, * no stored fields are included in the response. If this field is specified, * the _source parameter defaults to false. You can pass _source: true to return * both source fields and stored fields in the search response. * * API name: {@code stored_fields} * * Adds one or more values to storedFields. */ public final Builder storedFields(String value, String... values) { this.storedFields = _listAdd(this.storedFields, value, values); return this; } /** * API name: {@code suggest} */ public final Builder suggest(@Nullable Suggester value) { this.suggest = value; return this; } /** * API name: {@code suggest} */ public final Builder suggest(Function> fn) { return this.suggest(fn.apply(new Suggester.Builder()).build()); } /** * Maximum number of documents to collect for each shard. If a query reaches * this limit, Elasticsearch terminates the query early. Elasticsearch collects * documents before sorting. Defaults to 0, which does not terminate query * execution early. * * API name: {@code terminate_after} */ public final Builder terminateAfter(@Nullable Long value) { this.terminateAfter = value; return this; } /** * Specifies the period of time to wait for a response from each shard. If no * response is received before the timeout expires, the request fails and * returns an error. Defaults to no timeout. * * API name: {@code timeout} */ public final Builder timeout(@Nullable String value) { this.timeout = value; return this; } /** * If true, calculate and return document scores, even if the scores are not * used for sorting. * * API name: {@code track_scores} */ public final Builder trackScores(@Nullable Boolean value) { this.trackScores = value; return this; } /** * Number of hits matching the query to count accurately. If true, the exact * number of hits is returned at the cost of some performance. If false, the * response does not include the total number of hits matching the query. * Defaults to 10,000 hits. * * API name: {@code track_total_hits} */ public final Builder trackTotalHits(@Nullable TrackHits value) { this.trackTotalHits = value; return this; } /** * Number of hits matching the query to count accurately. If true, the exact * number of hits is returned at the cost of some performance. If false, the * response does not include the total number of hits matching the query. * Defaults to 10,000 hits. * * API name: {@code track_total_hits} */ public final Builder trackTotalHits(Function> fn) { return this.trackTotalHits(fn.apply(new TrackHits.Builder()).build()); } /** * If true, returns document version as part of a hit. * * API name: {@code version} */ public final Builder version(@Nullable Boolean value) { this.version = value; return this; } /** * Specify the time that the request should block waiting for the final response * * API name: {@code wait_for_completion_timeout} */ public final Builder waitForCompletionTimeout(@Nullable Time value) { this.waitForCompletionTimeout = value; return this; } /** * Specify the time that the request should block waiting for the final response * * API name: {@code wait_for_completion_timeout} */ public final Builder waitForCompletionTimeout(Function> fn) { return this.waitForCompletionTimeout(fn.apply(new Time.Builder()).build()); } @Override protected Builder self() { return this; } /** * Builds a {@link SubmitRequest}. * * @throws NullPointerException * if some of the required fields are null. */ public SubmitRequest build() { _checkSingleUse(); return new SubmitRequest(this); } } // --------------------------------------------------------------------------------------------- /** * Json deserializer for {@link SubmitRequest} */ public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy(Builder::new, SubmitRequest::setupSubmitRequestDeserializer); protected static void setupSubmitRequestDeserializer(ObjectDeserializer op) { op.add(Builder::source, SourceConfig._DESERIALIZER, "_source"); op.add(Builder::aggregations, JsonpDeserializer.stringMapDeserializer(Aggregation._DESERIALIZER), "aggregations", "aggs"); op.add(Builder::collapse, FieldCollapse._DESERIALIZER, "collapse"); op.add(Builder::docvalueFields, JsonpDeserializer.arrayDeserializer(FieldAndFormat._DESERIALIZER), "docvalue_fields"); op.add(Builder::explain, JsonpDeserializer.booleanDeserializer(), "explain"); op.add(Builder::fields, JsonpDeserializer.arrayDeserializer(FieldAndFormat._DESERIALIZER), "fields"); op.add(Builder::from, JsonpDeserializer.integerDeserializer(), "from"); op.add(Builder::highlight, Highlight._DESERIALIZER, "highlight"); op.add(Builder::indicesBoost, JsonpDeserializer.arrayDeserializer( JsonpDeserializer.stringMapDeserializer(JsonpDeserializer.doubleDeserializer())), "indices_boost"); op.add(Builder::minScore, JsonpDeserializer.doubleDeserializer(), "min_score"); op.add(Builder::pit, PointInTimeReference._DESERIALIZER, "pit"); op.add(Builder::postFilter, Query._DESERIALIZER, "post_filter"); op.add(Builder::profile, JsonpDeserializer.booleanDeserializer(), "profile"); op.add(Builder::query, Query._DESERIALIZER, "query"); op.add(Builder::rescore, JsonpDeserializer.arrayDeserializer(Rescore._DESERIALIZER), "rescore"); op.add(Builder::runtimeMappings, JsonpDeserializer.stringMapDeserializer( JsonpDeserializer.arrayDeserializer(RuntimeField._DESERIALIZER)), "runtime_mappings"); op.add(Builder::scriptFields, JsonpDeserializer.stringMapDeserializer(ScriptField._DESERIALIZER), "script_fields"); op.add(Builder::searchAfter, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "search_after"); op.add(Builder::seqNoPrimaryTerm, JsonpDeserializer.booleanDeserializer(), "seq_no_primary_term"); op.add(Builder::size, JsonpDeserializer.integerDeserializer(), "size"); op.add(Builder::slice, SlicedScroll._DESERIALIZER, "slice"); op.add(Builder::sort, JsonpDeserializer.arrayDeserializer(SortOptions._DESERIALIZER), "sort"); op.add(Builder::stats, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "stats"); op.add(Builder::storedFields, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "stored_fields"); op.add(Builder::suggest, Suggester._DESERIALIZER, "suggest"); op.add(Builder::terminateAfter, JsonpDeserializer.longDeserializer(), "terminate_after"); op.add(Builder::timeout, JsonpDeserializer.stringDeserializer(), "timeout"); op.add(Builder::trackScores, JsonpDeserializer.booleanDeserializer(), "track_scores"); op.add(Builder::trackTotalHits, TrackHits._DESERIALIZER, "track_total_hits"); op.add(Builder::version, JsonpDeserializer.booleanDeserializer(), "version"); } // --------------------------------------------------------------------------------------------- /** * Endpoint "{@code async_search.submit}". */ public static final SimpleEndpoint _ENDPOINT = new SimpleEndpoint<>("es/async_search.submit", // Request method request -> { return "POST"; }, // Request path request -> { final int _index = 1 << 0; int propsSet = 0; if (ApiTypeHelper.isDefined(request.index())) propsSet |= _index; if (propsSet == 0) { StringBuilder buf = new StringBuilder(); buf.append("/_async_search"); return buf.toString(); } if (propsSet == (_index)) { StringBuilder buf = new StringBuilder(); buf.append("/"); SimpleEndpoint.pathEncode(request.index.stream().map(v -> v).collect(Collectors.joining(",")), buf); buf.append("/_async_search"); return buf.toString(); } throw SimpleEndpoint.noPathTemplateFound("path"); }, // Request parameters request -> { Map params = new HashMap<>(); params.put("typed_keys", "true"); if (request.df != null) { params.put("df", request.df); } if (request.preFilterShardSize != null) { params.put("pre_filter_shard_size", String.valueOf(request.preFilterShardSize)); } if (request.minCompatibleShardNode != null) { params.put("min_compatible_shard_node", request.minCompatibleShardNode); } if (request.lenient != null) { params.put("lenient", String.valueOf(request.lenient)); } if (request.routing != null) { params.put("routing", request.routing); } if (request.ignoreUnavailable != null) { params.put("ignore_unavailable", String.valueOf(request.ignoreUnavailable)); } if (request.allowNoIndices != null) { params.put("allow_no_indices", String.valueOf(request.allowNoIndices)); } if (request.analyzer != null) { params.put("analyzer", request.analyzer); } if (request.ignoreThrottled != null) { params.put("ignore_throttled", String.valueOf(request.ignoreThrottled)); } if (request.keepOnCompletion != null) { params.put("keep_on_completion", String.valueOf(request.keepOnCompletion)); } if (request.maxConcurrentShardRequests != null) { params.put("max_concurrent_shard_requests", String.valueOf(request.maxConcurrentShardRequests)); } if (request.allowPartialSearchResults != null) { params.put("allow_partial_search_results", String.valueOf(request.allowPartialSearchResults)); } if (ApiTypeHelper.isDefined(request.expandWildcards)) { params.put("expand_wildcards", request.expandWildcards.stream().map(v -> v.jsonValue()).collect(Collectors.joining(","))); } if (request.preference != null) { params.put("preference", request.preference); } if (request.analyzeWildcard != null) { params.put("analyze_wildcard", String.valueOf(request.analyzeWildcard)); } if (request.scroll != null) { params.put("scroll", request.scroll._toJsonString()); } if (request.waitForCompletionTimeout != null) { params.put("wait_for_completion_timeout", request.waitForCompletionTimeout._toJsonString()); } if (request.searchType != null) { params.put("search_type", request.searchType.jsonValue()); } if (request.ccsMinimizeRoundtrips != null) { params.put("ccs_minimize_roundtrips", String.valueOf(request.ccsMinimizeRoundtrips)); } if (request.q != null) { params.put("q", request.q); } if (request.defaultOperator != null) { params.put("default_operator", request.defaultOperator.jsonValue()); } if (request.keepAlive != null) { params.put("keep_alive", request.keepAlive._toJsonString()); } if (request.requestCache != null) { params.put("request_cache", String.valueOf(request.requestCache)); } if (request.batchedReduceSize != null) { params.put("batched_reduce_size", String.valueOf(request.batchedReduceSize)); } return params; }, SimpleEndpoint.emptyMap(), true, SubmitResponse._DESERIALIZER); /** * Create an "{@code async_search.submit}" endpoint. */ public static Endpoint, ErrorResponse> createSubmitEndpoint( JsonpDeserializer tDocumentDeserializer) { return _ENDPOINT .withResponseDeserializer(SubmitResponse.createSubmitResponseDeserializer(tDocumentDeserializer)); } }
stats
* Adds one or more values to stats. */ public final Builder stats(String value, String... values) { this.stats = _listAdd(this.stats, value, values); return this; } /** * List of stored fields to return as part of a hit. If no fields are specified, * no stored fields are included in the response. If this field is specified, * the _source parameter defaults to false. You can pass _source: true to return * both source fields and stored fields in the search response. *
* API name: {@code stored_fields} *
* Adds all elements of list to storedFields. */ public final Builder storedFields(List list) { this.storedFields = _listAddAll(this.storedFields, list); return this; } /** * List of stored fields to return as part of a hit. If no fields are specified, * no stored fields are included in the response. If this field is specified, * the _source parameter defaults to false. You can pass _source: true to return * both source fields and stored fields in the search response. * * API name: {@code stored_fields} * * Adds one or more values to storedFields. */ public final Builder storedFields(String value, String... values) { this.storedFields = _listAdd(this.storedFields, value, values); return this; } /** * API name: {@code suggest} */ public final Builder suggest(@Nullable Suggester value) { this.suggest = value; return this; } /** * API name: {@code suggest} */ public final Builder suggest(Function> fn) { return this.suggest(fn.apply(new Suggester.Builder()).build()); } /** * Maximum number of documents to collect for each shard. If a query reaches * this limit, Elasticsearch terminates the query early. Elasticsearch collects * documents before sorting. Defaults to 0, which does not terminate query * execution early. * * API name: {@code terminate_after} */ public final Builder terminateAfter(@Nullable Long value) { this.terminateAfter = value; return this; } /** * Specifies the period of time to wait for a response from each shard. If no * response is received before the timeout expires, the request fails and * returns an error. Defaults to no timeout. * * API name: {@code timeout} */ public final Builder timeout(@Nullable String value) { this.timeout = value; return this; } /** * If true, calculate and return document scores, even if the scores are not * used for sorting. * * API name: {@code track_scores} */ public final Builder trackScores(@Nullable Boolean value) { this.trackScores = value; return this; } /** * Number of hits matching the query to count accurately. If true, the exact * number of hits is returned at the cost of some performance. If false, the * response does not include the total number of hits matching the query. * Defaults to 10,000 hits. * * API name: {@code track_total_hits} */ public final Builder trackTotalHits(@Nullable TrackHits value) { this.trackTotalHits = value; return this; } /** * Number of hits matching the query to count accurately. If true, the exact * number of hits is returned at the cost of some performance. If false, the * response does not include the total number of hits matching the query. * Defaults to 10,000 hits. * * API name: {@code track_total_hits} */ public final Builder trackTotalHits(Function> fn) { return this.trackTotalHits(fn.apply(new TrackHits.Builder()).build()); } /** * If true, returns document version as part of a hit. * * API name: {@code version} */ public final Builder version(@Nullable Boolean value) { this.version = value; return this; } /** * Specify the time that the request should block waiting for the final response * * API name: {@code wait_for_completion_timeout} */ public final Builder waitForCompletionTimeout(@Nullable Time value) { this.waitForCompletionTimeout = value; return this; } /** * Specify the time that the request should block waiting for the final response * * API name: {@code wait_for_completion_timeout} */ public final Builder waitForCompletionTimeout(Function> fn) { return this.waitForCompletionTimeout(fn.apply(new Time.Builder()).build()); } @Override protected Builder self() { return this; } /** * Builds a {@link SubmitRequest}. * * @throws NullPointerException * if some of the required fields are null. */ public SubmitRequest build() { _checkSingleUse(); return new SubmitRequest(this); } } // --------------------------------------------------------------------------------------------- /** * Json deserializer for {@link SubmitRequest} */ public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy(Builder::new, SubmitRequest::setupSubmitRequestDeserializer); protected static void setupSubmitRequestDeserializer(ObjectDeserializer op) { op.add(Builder::source, SourceConfig._DESERIALIZER, "_source"); op.add(Builder::aggregations, JsonpDeserializer.stringMapDeserializer(Aggregation._DESERIALIZER), "aggregations", "aggs"); op.add(Builder::collapse, FieldCollapse._DESERIALIZER, "collapse"); op.add(Builder::docvalueFields, JsonpDeserializer.arrayDeserializer(FieldAndFormat._DESERIALIZER), "docvalue_fields"); op.add(Builder::explain, JsonpDeserializer.booleanDeserializer(), "explain"); op.add(Builder::fields, JsonpDeserializer.arrayDeserializer(FieldAndFormat._DESERIALIZER), "fields"); op.add(Builder::from, JsonpDeserializer.integerDeserializer(), "from"); op.add(Builder::highlight, Highlight._DESERIALIZER, "highlight"); op.add(Builder::indicesBoost, JsonpDeserializer.arrayDeserializer( JsonpDeserializer.stringMapDeserializer(JsonpDeserializer.doubleDeserializer())), "indices_boost"); op.add(Builder::minScore, JsonpDeserializer.doubleDeserializer(), "min_score"); op.add(Builder::pit, PointInTimeReference._DESERIALIZER, "pit"); op.add(Builder::postFilter, Query._DESERIALIZER, "post_filter"); op.add(Builder::profile, JsonpDeserializer.booleanDeserializer(), "profile"); op.add(Builder::query, Query._DESERIALIZER, "query"); op.add(Builder::rescore, JsonpDeserializer.arrayDeserializer(Rescore._DESERIALIZER), "rescore"); op.add(Builder::runtimeMappings, JsonpDeserializer.stringMapDeserializer( JsonpDeserializer.arrayDeserializer(RuntimeField._DESERIALIZER)), "runtime_mappings"); op.add(Builder::scriptFields, JsonpDeserializer.stringMapDeserializer(ScriptField._DESERIALIZER), "script_fields"); op.add(Builder::searchAfter, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "search_after"); op.add(Builder::seqNoPrimaryTerm, JsonpDeserializer.booleanDeserializer(), "seq_no_primary_term"); op.add(Builder::size, JsonpDeserializer.integerDeserializer(), "size"); op.add(Builder::slice, SlicedScroll._DESERIALIZER, "slice"); op.add(Builder::sort, JsonpDeserializer.arrayDeserializer(SortOptions._DESERIALIZER), "sort"); op.add(Builder::stats, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "stats"); op.add(Builder::storedFields, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "stored_fields"); op.add(Builder::suggest, Suggester._DESERIALIZER, "suggest"); op.add(Builder::terminateAfter, JsonpDeserializer.longDeserializer(), "terminate_after"); op.add(Builder::timeout, JsonpDeserializer.stringDeserializer(), "timeout"); op.add(Builder::trackScores, JsonpDeserializer.booleanDeserializer(), "track_scores"); op.add(Builder::trackTotalHits, TrackHits._DESERIALIZER, "track_total_hits"); op.add(Builder::version, JsonpDeserializer.booleanDeserializer(), "version"); } // --------------------------------------------------------------------------------------------- /** * Endpoint "{@code async_search.submit}". */ public static final SimpleEndpoint _ENDPOINT = new SimpleEndpoint<>("es/async_search.submit", // Request method request -> { return "POST"; }, // Request path request -> { final int _index = 1 << 0; int propsSet = 0; if (ApiTypeHelper.isDefined(request.index())) propsSet |= _index; if (propsSet == 0) { StringBuilder buf = new StringBuilder(); buf.append("/_async_search"); return buf.toString(); } if (propsSet == (_index)) { StringBuilder buf = new StringBuilder(); buf.append("/"); SimpleEndpoint.pathEncode(request.index.stream().map(v -> v).collect(Collectors.joining(",")), buf); buf.append("/_async_search"); return buf.toString(); } throw SimpleEndpoint.noPathTemplateFound("path"); }, // Request parameters request -> { Map params = new HashMap<>(); params.put("typed_keys", "true"); if (request.df != null) { params.put("df", request.df); } if (request.preFilterShardSize != null) { params.put("pre_filter_shard_size", String.valueOf(request.preFilterShardSize)); } if (request.minCompatibleShardNode != null) { params.put("min_compatible_shard_node", request.minCompatibleShardNode); } if (request.lenient != null) { params.put("lenient", String.valueOf(request.lenient)); } if (request.routing != null) { params.put("routing", request.routing); } if (request.ignoreUnavailable != null) { params.put("ignore_unavailable", String.valueOf(request.ignoreUnavailable)); } if (request.allowNoIndices != null) { params.put("allow_no_indices", String.valueOf(request.allowNoIndices)); } if (request.analyzer != null) { params.put("analyzer", request.analyzer); } if (request.ignoreThrottled != null) { params.put("ignore_throttled", String.valueOf(request.ignoreThrottled)); } if (request.keepOnCompletion != null) { params.put("keep_on_completion", String.valueOf(request.keepOnCompletion)); } if (request.maxConcurrentShardRequests != null) { params.put("max_concurrent_shard_requests", String.valueOf(request.maxConcurrentShardRequests)); } if (request.allowPartialSearchResults != null) { params.put("allow_partial_search_results", String.valueOf(request.allowPartialSearchResults)); } if (ApiTypeHelper.isDefined(request.expandWildcards)) { params.put("expand_wildcards", request.expandWildcards.stream().map(v -> v.jsonValue()).collect(Collectors.joining(","))); } if (request.preference != null) { params.put("preference", request.preference); } if (request.analyzeWildcard != null) { params.put("analyze_wildcard", String.valueOf(request.analyzeWildcard)); } if (request.scroll != null) { params.put("scroll", request.scroll._toJsonString()); } if (request.waitForCompletionTimeout != null) { params.put("wait_for_completion_timeout", request.waitForCompletionTimeout._toJsonString()); } if (request.searchType != null) { params.put("search_type", request.searchType.jsonValue()); } if (request.ccsMinimizeRoundtrips != null) { params.put("ccs_minimize_roundtrips", String.valueOf(request.ccsMinimizeRoundtrips)); } if (request.q != null) { params.put("q", request.q); } if (request.defaultOperator != null) { params.put("default_operator", request.defaultOperator.jsonValue()); } if (request.keepAlive != null) { params.put("keep_alive", request.keepAlive._toJsonString()); } if (request.requestCache != null) { params.put("request_cache", String.valueOf(request.requestCache)); } if (request.batchedReduceSize != null) { params.put("batched_reduce_size", String.valueOf(request.batchedReduceSize)); } return params; }, SimpleEndpoint.emptyMap(), true, SubmitResponse._DESERIALIZER); /** * Create an "{@code async_search.submit}" endpoint. */ public static Endpoint, ErrorResponse> createSubmitEndpoint( JsonpDeserializer tDocumentDeserializer) { return _ENDPOINT .withResponseDeserializer(SubmitResponse.createSubmitResponseDeserializer(tDocumentDeserializer)); } }
storedFields
* Adds one or more values to storedFields. */ public final Builder storedFields(String value, String... values) { this.storedFields = _listAdd(this.storedFields, value, values); return this; } /** * API name: {@code suggest} */ public final Builder suggest(@Nullable Suggester value) { this.suggest = value; return this; } /** * API name: {@code suggest} */ public final Builder suggest(Function> fn) { return this.suggest(fn.apply(new Suggester.Builder()).build()); } /** * Maximum number of documents to collect for each shard. If a query reaches * this limit, Elasticsearch terminates the query early. Elasticsearch collects * documents before sorting. Defaults to 0, which does not terminate query * execution early. * * API name: {@code terminate_after} */ public final Builder terminateAfter(@Nullable Long value) { this.terminateAfter = value; return this; } /** * Specifies the period of time to wait for a response from each shard. If no * response is received before the timeout expires, the request fails and * returns an error. Defaults to no timeout. * * API name: {@code timeout} */ public final Builder timeout(@Nullable String value) { this.timeout = value; return this; } /** * If true, calculate and return document scores, even if the scores are not * used for sorting. * * API name: {@code track_scores} */ public final Builder trackScores(@Nullable Boolean value) { this.trackScores = value; return this; } /** * Number of hits matching the query to count accurately. If true, the exact * number of hits is returned at the cost of some performance. If false, the * response does not include the total number of hits matching the query. * Defaults to 10,000 hits. * * API name: {@code track_total_hits} */ public final Builder trackTotalHits(@Nullable TrackHits value) { this.trackTotalHits = value; return this; } /** * Number of hits matching the query to count accurately. If true, the exact * number of hits is returned at the cost of some performance. If false, the * response does not include the total number of hits matching the query. * Defaults to 10,000 hits. * * API name: {@code track_total_hits} */ public final Builder trackTotalHits(Function> fn) { return this.trackTotalHits(fn.apply(new TrackHits.Builder()).build()); } /** * If true, returns document version as part of a hit. * * API name: {@code version} */ public final Builder version(@Nullable Boolean value) { this.version = value; return this; } /** * Specify the time that the request should block waiting for the final response * * API name: {@code wait_for_completion_timeout} */ public final Builder waitForCompletionTimeout(@Nullable Time value) { this.waitForCompletionTimeout = value; return this; } /** * Specify the time that the request should block waiting for the final response * * API name: {@code wait_for_completion_timeout} */ public final Builder waitForCompletionTimeout(Function> fn) { return this.waitForCompletionTimeout(fn.apply(new Time.Builder()).build()); } @Override protected Builder self() { return this; } /** * Builds a {@link SubmitRequest}. * * @throws NullPointerException * if some of the required fields are null. */ public SubmitRequest build() { _checkSingleUse(); return new SubmitRequest(this); } } // --------------------------------------------------------------------------------------------- /** * Json deserializer for {@link SubmitRequest} */ public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy(Builder::new, SubmitRequest::setupSubmitRequestDeserializer); protected static void setupSubmitRequestDeserializer(ObjectDeserializer op) { op.add(Builder::source, SourceConfig._DESERIALIZER, "_source"); op.add(Builder::aggregations, JsonpDeserializer.stringMapDeserializer(Aggregation._DESERIALIZER), "aggregations", "aggs"); op.add(Builder::collapse, FieldCollapse._DESERIALIZER, "collapse"); op.add(Builder::docvalueFields, JsonpDeserializer.arrayDeserializer(FieldAndFormat._DESERIALIZER), "docvalue_fields"); op.add(Builder::explain, JsonpDeserializer.booleanDeserializer(), "explain"); op.add(Builder::fields, JsonpDeserializer.arrayDeserializer(FieldAndFormat._DESERIALIZER), "fields"); op.add(Builder::from, JsonpDeserializer.integerDeserializer(), "from"); op.add(Builder::highlight, Highlight._DESERIALIZER, "highlight"); op.add(Builder::indicesBoost, JsonpDeserializer.arrayDeserializer( JsonpDeserializer.stringMapDeserializer(JsonpDeserializer.doubleDeserializer())), "indices_boost"); op.add(Builder::minScore, JsonpDeserializer.doubleDeserializer(), "min_score"); op.add(Builder::pit, PointInTimeReference._DESERIALIZER, "pit"); op.add(Builder::postFilter, Query._DESERIALIZER, "post_filter"); op.add(Builder::profile, JsonpDeserializer.booleanDeserializer(), "profile"); op.add(Builder::query, Query._DESERIALIZER, "query"); op.add(Builder::rescore, JsonpDeserializer.arrayDeserializer(Rescore._DESERIALIZER), "rescore"); op.add(Builder::runtimeMappings, JsonpDeserializer.stringMapDeserializer( JsonpDeserializer.arrayDeserializer(RuntimeField._DESERIALIZER)), "runtime_mappings"); op.add(Builder::scriptFields, JsonpDeserializer.stringMapDeserializer(ScriptField._DESERIALIZER), "script_fields"); op.add(Builder::searchAfter, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "search_after"); op.add(Builder::seqNoPrimaryTerm, JsonpDeserializer.booleanDeserializer(), "seq_no_primary_term"); op.add(Builder::size, JsonpDeserializer.integerDeserializer(), "size"); op.add(Builder::slice, SlicedScroll._DESERIALIZER, "slice"); op.add(Builder::sort, JsonpDeserializer.arrayDeserializer(SortOptions._DESERIALIZER), "sort"); op.add(Builder::stats, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "stats"); op.add(Builder::storedFields, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "stored_fields"); op.add(Builder::suggest, Suggester._DESERIALIZER, "suggest"); op.add(Builder::terminateAfter, JsonpDeserializer.longDeserializer(), "terminate_after"); op.add(Builder::timeout, JsonpDeserializer.stringDeserializer(), "timeout"); op.add(Builder::trackScores, JsonpDeserializer.booleanDeserializer(), "track_scores"); op.add(Builder::trackTotalHits, TrackHits._DESERIALIZER, "track_total_hits"); op.add(Builder::version, JsonpDeserializer.booleanDeserializer(), "version"); } // --------------------------------------------------------------------------------------------- /** * Endpoint "{@code async_search.submit}". */ public static final SimpleEndpoint _ENDPOINT = new SimpleEndpoint<>("es/async_search.submit", // Request method request -> { return "POST"; }, // Request path request -> { final int _index = 1 << 0; int propsSet = 0; if (ApiTypeHelper.isDefined(request.index())) propsSet |= _index; if (propsSet == 0) { StringBuilder buf = new StringBuilder(); buf.append("/_async_search"); return buf.toString(); } if (propsSet == (_index)) { StringBuilder buf = new StringBuilder(); buf.append("/"); SimpleEndpoint.pathEncode(request.index.stream().map(v -> v).collect(Collectors.joining(",")), buf); buf.append("/_async_search"); return buf.toString(); } throw SimpleEndpoint.noPathTemplateFound("path"); }, // Request parameters request -> { Map params = new HashMap<>(); params.put("typed_keys", "true"); if (request.df != null) { params.put("df", request.df); } if (request.preFilterShardSize != null) { params.put("pre_filter_shard_size", String.valueOf(request.preFilterShardSize)); } if (request.minCompatibleShardNode != null) { params.put("min_compatible_shard_node", request.minCompatibleShardNode); } if (request.lenient != null) { params.put("lenient", String.valueOf(request.lenient)); } if (request.routing != null) { params.put("routing", request.routing); } if (request.ignoreUnavailable != null) { params.put("ignore_unavailable", String.valueOf(request.ignoreUnavailable)); } if (request.allowNoIndices != null) { params.put("allow_no_indices", String.valueOf(request.allowNoIndices)); } if (request.analyzer != null) { params.put("analyzer", request.analyzer); } if (request.ignoreThrottled != null) { params.put("ignore_throttled", String.valueOf(request.ignoreThrottled)); } if (request.keepOnCompletion != null) { params.put("keep_on_completion", String.valueOf(request.keepOnCompletion)); } if (request.maxConcurrentShardRequests != null) { params.put("max_concurrent_shard_requests", String.valueOf(request.maxConcurrentShardRequests)); } if (request.allowPartialSearchResults != null) { params.put("allow_partial_search_results", String.valueOf(request.allowPartialSearchResults)); } if (ApiTypeHelper.isDefined(request.expandWildcards)) { params.put("expand_wildcards", request.expandWildcards.stream().map(v -> v.jsonValue()).collect(Collectors.joining(","))); } if (request.preference != null) { params.put("preference", request.preference); } if (request.analyzeWildcard != null) { params.put("analyze_wildcard", String.valueOf(request.analyzeWildcard)); } if (request.scroll != null) { params.put("scroll", request.scroll._toJsonString()); } if (request.waitForCompletionTimeout != null) { params.put("wait_for_completion_timeout", request.waitForCompletionTimeout._toJsonString()); } if (request.searchType != null) { params.put("search_type", request.searchType.jsonValue()); } if (request.ccsMinimizeRoundtrips != null) { params.put("ccs_minimize_roundtrips", String.valueOf(request.ccsMinimizeRoundtrips)); } if (request.q != null) { params.put("q", request.q); } if (request.defaultOperator != null) { params.put("default_operator", request.defaultOperator.jsonValue()); } if (request.keepAlive != null) { params.put("keep_alive", request.keepAlive._toJsonString()); } if (request.requestCache != null) { params.put("request_cache", String.valueOf(request.requestCache)); } if (request.batchedReduceSize != null) { params.put("batched_reduce_size", String.valueOf(request.batchedReduceSize)); } return params; }, SimpleEndpoint.emptyMap(), true, SubmitResponse._DESERIALIZER); /** * Create an "{@code async_search.submit}" endpoint. */ public static Endpoint, ErrorResponse> createSubmitEndpoint( JsonpDeserializer tDocumentDeserializer) { return _ENDPOINT .withResponseDeserializer(SubmitResponse.createSubmitResponseDeserializer(tDocumentDeserializer)); } }
* API name: {@code terminate_after} */ public final Builder terminateAfter(@Nullable Long value) { this.terminateAfter = value; return this; } /** * Specifies the period of time to wait for a response from each shard. If no * response is received before the timeout expires, the request fails and * returns an error. Defaults to no timeout. *
* API name: {@code timeout} */ public final Builder timeout(@Nullable String value) { this.timeout = value; return this; } /** * If true, calculate and return document scores, even if the scores are not * used for sorting. *
* API name: {@code track_scores} */ public final Builder trackScores(@Nullable Boolean value) { this.trackScores = value; return this; } /** * Number of hits matching the query to count accurately. If true, the exact * number of hits is returned at the cost of some performance. If false, the * response does not include the total number of hits matching the query. * Defaults to 10,000 hits. *
* API name: {@code track_total_hits} */ public final Builder trackTotalHits(@Nullable TrackHits value) { this.trackTotalHits = value; return this; } /** * Number of hits matching the query to count accurately. If true, the exact * number of hits is returned at the cost of some performance. If false, the * response does not include the total number of hits matching the query. * Defaults to 10,000 hits. *
* API name: {@code track_total_hits} */ public final Builder trackTotalHits(Function> fn) { return this.trackTotalHits(fn.apply(new TrackHits.Builder()).build()); } /** * If true, returns document version as part of a hit. * * API name: {@code version} */ public final Builder version(@Nullable Boolean value) { this.version = value; return this; } /** * Specify the time that the request should block waiting for the final response * * API name: {@code wait_for_completion_timeout} */ public final Builder waitForCompletionTimeout(@Nullable Time value) { this.waitForCompletionTimeout = value; return this; } /** * Specify the time that the request should block waiting for the final response * * API name: {@code wait_for_completion_timeout} */ public final Builder waitForCompletionTimeout(Function> fn) { return this.waitForCompletionTimeout(fn.apply(new Time.Builder()).build()); } @Override protected Builder self() { return this; } /** * Builds a {@link SubmitRequest}. * * @throws NullPointerException * if some of the required fields are null. */ public SubmitRequest build() { _checkSingleUse(); return new SubmitRequest(this); } } // --------------------------------------------------------------------------------------------- /** * Json deserializer for {@link SubmitRequest} */ public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy(Builder::new, SubmitRequest::setupSubmitRequestDeserializer); protected static void setupSubmitRequestDeserializer(ObjectDeserializer op) { op.add(Builder::source, SourceConfig._DESERIALIZER, "_source"); op.add(Builder::aggregations, JsonpDeserializer.stringMapDeserializer(Aggregation._DESERIALIZER), "aggregations", "aggs"); op.add(Builder::collapse, FieldCollapse._DESERIALIZER, "collapse"); op.add(Builder::docvalueFields, JsonpDeserializer.arrayDeserializer(FieldAndFormat._DESERIALIZER), "docvalue_fields"); op.add(Builder::explain, JsonpDeserializer.booleanDeserializer(), "explain"); op.add(Builder::fields, JsonpDeserializer.arrayDeserializer(FieldAndFormat._DESERIALIZER), "fields"); op.add(Builder::from, JsonpDeserializer.integerDeserializer(), "from"); op.add(Builder::highlight, Highlight._DESERIALIZER, "highlight"); op.add(Builder::indicesBoost, JsonpDeserializer.arrayDeserializer( JsonpDeserializer.stringMapDeserializer(JsonpDeserializer.doubleDeserializer())), "indices_boost"); op.add(Builder::minScore, JsonpDeserializer.doubleDeserializer(), "min_score"); op.add(Builder::pit, PointInTimeReference._DESERIALIZER, "pit"); op.add(Builder::postFilter, Query._DESERIALIZER, "post_filter"); op.add(Builder::profile, JsonpDeserializer.booleanDeserializer(), "profile"); op.add(Builder::query, Query._DESERIALIZER, "query"); op.add(Builder::rescore, JsonpDeserializer.arrayDeserializer(Rescore._DESERIALIZER), "rescore"); op.add(Builder::runtimeMappings, JsonpDeserializer.stringMapDeserializer( JsonpDeserializer.arrayDeserializer(RuntimeField._DESERIALIZER)), "runtime_mappings"); op.add(Builder::scriptFields, JsonpDeserializer.stringMapDeserializer(ScriptField._DESERIALIZER), "script_fields"); op.add(Builder::searchAfter, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "search_after"); op.add(Builder::seqNoPrimaryTerm, JsonpDeserializer.booleanDeserializer(), "seq_no_primary_term"); op.add(Builder::size, JsonpDeserializer.integerDeserializer(), "size"); op.add(Builder::slice, SlicedScroll._DESERIALIZER, "slice"); op.add(Builder::sort, JsonpDeserializer.arrayDeserializer(SortOptions._DESERIALIZER), "sort"); op.add(Builder::stats, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "stats"); op.add(Builder::storedFields, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "stored_fields"); op.add(Builder::suggest, Suggester._DESERIALIZER, "suggest"); op.add(Builder::terminateAfter, JsonpDeserializer.longDeserializer(), "terminate_after"); op.add(Builder::timeout, JsonpDeserializer.stringDeserializer(), "timeout"); op.add(Builder::trackScores, JsonpDeserializer.booleanDeserializer(), "track_scores"); op.add(Builder::trackTotalHits, TrackHits._DESERIALIZER, "track_total_hits"); op.add(Builder::version, JsonpDeserializer.booleanDeserializer(), "version"); } // --------------------------------------------------------------------------------------------- /** * Endpoint "{@code async_search.submit}". */ public static final SimpleEndpoint _ENDPOINT = new SimpleEndpoint<>("es/async_search.submit", // Request method request -> { return "POST"; }, // Request path request -> { final int _index = 1 << 0; int propsSet = 0; if (ApiTypeHelper.isDefined(request.index())) propsSet |= _index; if (propsSet == 0) { StringBuilder buf = new StringBuilder(); buf.append("/_async_search"); return buf.toString(); } if (propsSet == (_index)) { StringBuilder buf = new StringBuilder(); buf.append("/"); SimpleEndpoint.pathEncode(request.index.stream().map(v -> v).collect(Collectors.joining(",")), buf); buf.append("/_async_search"); return buf.toString(); } throw SimpleEndpoint.noPathTemplateFound("path"); }, // Request parameters request -> { Map params = new HashMap<>(); params.put("typed_keys", "true"); if (request.df != null) { params.put("df", request.df); } if (request.preFilterShardSize != null) { params.put("pre_filter_shard_size", String.valueOf(request.preFilterShardSize)); } if (request.minCompatibleShardNode != null) { params.put("min_compatible_shard_node", request.minCompatibleShardNode); } if (request.lenient != null) { params.put("lenient", String.valueOf(request.lenient)); } if (request.routing != null) { params.put("routing", request.routing); } if (request.ignoreUnavailable != null) { params.put("ignore_unavailable", String.valueOf(request.ignoreUnavailable)); } if (request.allowNoIndices != null) { params.put("allow_no_indices", String.valueOf(request.allowNoIndices)); } if (request.analyzer != null) { params.put("analyzer", request.analyzer); } if (request.ignoreThrottled != null) { params.put("ignore_throttled", String.valueOf(request.ignoreThrottled)); } if (request.keepOnCompletion != null) { params.put("keep_on_completion", String.valueOf(request.keepOnCompletion)); } if (request.maxConcurrentShardRequests != null) { params.put("max_concurrent_shard_requests", String.valueOf(request.maxConcurrentShardRequests)); } if (request.allowPartialSearchResults != null) { params.put("allow_partial_search_results", String.valueOf(request.allowPartialSearchResults)); } if (ApiTypeHelper.isDefined(request.expandWildcards)) { params.put("expand_wildcards", request.expandWildcards.stream().map(v -> v.jsonValue()).collect(Collectors.joining(","))); } if (request.preference != null) { params.put("preference", request.preference); } if (request.analyzeWildcard != null) { params.put("analyze_wildcard", String.valueOf(request.analyzeWildcard)); } if (request.scroll != null) { params.put("scroll", request.scroll._toJsonString()); } if (request.waitForCompletionTimeout != null) { params.put("wait_for_completion_timeout", request.waitForCompletionTimeout._toJsonString()); } if (request.searchType != null) { params.put("search_type", request.searchType.jsonValue()); } if (request.ccsMinimizeRoundtrips != null) { params.put("ccs_minimize_roundtrips", String.valueOf(request.ccsMinimizeRoundtrips)); } if (request.q != null) { params.put("q", request.q); } if (request.defaultOperator != null) { params.put("default_operator", request.defaultOperator.jsonValue()); } if (request.keepAlive != null) { params.put("keep_alive", request.keepAlive._toJsonString()); } if (request.requestCache != null) { params.put("request_cache", String.valueOf(request.requestCache)); } if (request.batchedReduceSize != null) { params.put("batched_reduce_size", String.valueOf(request.batchedReduceSize)); } return params; }, SimpleEndpoint.emptyMap(), true, SubmitResponse._DESERIALIZER); /** * Create an "{@code async_search.submit}" endpoint. */ public static Endpoint, ErrorResponse> createSubmitEndpoint( JsonpDeserializer tDocumentDeserializer) { return _ENDPOINT .withResponseDeserializer(SubmitResponse.createSubmitResponseDeserializer(tDocumentDeserializer)); } }
* API name: {@code version} */ public final Builder version(@Nullable Boolean value) { this.version = value; return this; } /** * Specify the time that the request should block waiting for the final response *
* API name: {@code wait_for_completion_timeout} */ public final Builder waitForCompletionTimeout(@Nullable Time value) { this.waitForCompletionTimeout = value; return this; } /** * Specify the time that the request should block waiting for the final response *
* API name: {@code wait_for_completion_timeout} */ public final Builder waitForCompletionTimeout(Function> fn) { return this.waitForCompletionTimeout(fn.apply(new Time.Builder()).build()); } @Override protected Builder self() { return this; } /** * Builds a {@link SubmitRequest}. * * @throws NullPointerException * if some of the required fields are null. */ public SubmitRequest build() { _checkSingleUse(); return new SubmitRequest(this); } } // --------------------------------------------------------------------------------------------- /** * Json deserializer for {@link SubmitRequest} */ public static final JsonpDeserializer _DESERIALIZER = ObjectBuilderDeserializer.lazy(Builder::new, SubmitRequest::setupSubmitRequestDeserializer); protected static void setupSubmitRequestDeserializer(ObjectDeserializer op) { op.add(Builder::source, SourceConfig._DESERIALIZER, "_source"); op.add(Builder::aggregations, JsonpDeserializer.stringMapDeserializer(Aggregation._DESERIALIZER), "aggregations", "aggs"); op.add(Builder::collapse, FieldCollapse._DESERIALIZER, "collapse"); op.add(Builder::docvalueFields, JsonpDeserializer.arrayDeserializer(FieldAndFormat._DESERIALIZER), "docvalue_fields"); op.add(Builder::explain, JsonpDeserializer.booleanDeserializer(), "explain"); op.add(Builder::fields, JsonpDeserializer.arrayDeserializer(FieldAndFormat._DESERIALIZER), "fields"); op.add(Builder::from, JsonpDeserializer.integerDeserializer(), "from"); op.add(Builder::highlight, Highlight._DESERIALIZER, "highlight"); op.add(Builder::indicesBoost, JsonpDeserializer.arrayDeserializer( JsonpDeserializer.stringMapDeserializer(JsonpDeserializer.doubleDeserializer())), "indices_boost"); op.add(Builder::minScore, JsonpDeserializer.doubleDeserializer(), "min_score"); op.add(Builder::pit, PointInTimeReference._DESERIALIZER, "pit"); op.add(Builder::postFilter, Query._DESERIALIZER, "post_filter"); op.add(Builder::profile, JsonpDeserializer.booleanDeserializer(), "profile"); op.add(Builder::query, Query._DESERIALIZER, "query"); op.add(Builder::rescore, JsonpDeserializer.arrayDeserializer(Rescore._DESERIALIZER), "rescore"); op.add(Builder::runtimeMappings, JsonpDeserializer.stringMapDeserializer( JsonpDeserializer.arrayDeserializer(RuntimeField._DESERIALIZER)), "runtime_mappings"); op.add(Builder::scriptFields, JsonpDeserializer.stringMapDeserializer(ScriptField._DESERIALIZER), "script_fields"); op.add(Builder::searchAfter, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "search_after"); op.add(Builder::seqNoPrimaryTerm, JsonpDeserializer.booleanDeserializer(), "seq_no_primary_term"); op.add(Builder::size, JsonpDeserializer.integerDeserializer(), "size"); op.add(Builder::slice, SlicedScroll._DESERIALIZER, "slice"); op.add(Builder::sort, JsonpDeserializer.arrayDeserializer(SortOptions._DESERIALIZER), "sort"); op.add(Builder::stats, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "stats"); op.add(Builder::storedFields, JsonpDeserializer.arrayDeserializer(JsonpDeserializer.stringDeserializer()), "stored_fields"); op.add(Builder::suggest, Suggester._DESERIALIZER, "suggest"); op.add(Builder::terminateAfter, JsonpDeserializer.longDeserializer(), "terminate_after"); op.add(Builder::timeout, JsonpDeserializer.stringDeserializer(), "timeout"); op.add(Builder::trackScores, JsonpDeserializer.booleanDeserializer(), "track_scores"); op.add(Builder::trackTotalHits, TrackHits._DESERIALIZER, "track_total_hits"); op.add(Builder::version, JsonpDeserializer.booleanDeserializer(), "version"); } // --------------------------------------------------------------------------------------------- /** * Endpoint "{@code async_search.submit}". */ public static final SimpleEndpoint _ENDPOINT = new SimpleEndpoint<>("es/async_search.submit", // Request method request -> { return "POST"; }, // Request path request -> { final int _index = 1 << 0; int propsSet = 0; if (ApiTypeHelper.isDefined(request.index())) propsSet |= _index; if (propsSet == 0) { StringBuilder buf = new StringBuilder(); buf.append("/_async_search"); return buf.toString(); } if (propsSet == (_index)) { StringBuilder buf = new StringBuilder(); buf.append("/"); SimpleEndpoint.pathEncode(request.index.stream().map(v -> v).collect(Collectors.joining(",")), buf); buf.append("/_async_search"); return buf.toString(); } throw SimpleEndpoint.noPathTemplateFound("path"); }, // Request parameters request -> { Map params = new HashMap<>(); params.put("typed_keys", "true"); if (request.df != null) { params.put("df", request.df); } if (request.preFilterShardSize != null) { params.put("pre_filter_shard_size", String.valueOf(request.preFilterShardSize)); } if (request.minCompatibleShardNode != null) { params.put("min_compatible_shard_node", request.minCompatibleShardNode); } if (request.lenient != null) { params.put("lenient", String.valueOf(request.lenient)); } if (request.routing != null) { params.put("routing", request.routing); } if (request.ignoreUnavailable != null) { params.put("ignore_unavailable", String.valueOf(request.ignoreUnavailable)); } if (request.allowNoIndices != null) { params.put("allow_no_indices", String.valueOf(request.allowNoIndices)); } if (request.analyzer != null) { params.put("analyzer", request.analyzer); } if (request.ignoreThrottled != null) { params.put("ignore_throttled", String.valueOf(request.ignoreThrottled)); } if (request.keepOnCompletion != null) { params.put("keep_on_completion", String.valueOf(request.keepOnCompletion)); } if (request.maxConcurrentShardRequests != null) { params.put("max_concurrent_shard_requests", String.valueOf(request.maxConcurrentShardRequests)); } if (request.allowPartialSearchResults != null) { params.put("allow_partial_search_results", String.valueOf(request.allowPartialSearchResults)); } if (ApiTypeHelper.isDefined(request.expandWildcards)) { params.put("expand_wildcards", request.expandWildcards.stream().map(v -> v.jsonValue()).collect(Collectors.joining(","))); } if (request.preference != null) { params.put("preference", request.preference); } if (request.analyzeWildcard != null) { params.put("analyze_wildcard", String.valueOf(request.analyzeWildcard)); } if (request.scroll != null) { params.put("scroll", request.scroll._toJsonString()); } if (request.waitForCompletionTimeout != null) { params.put("wait_for_completion_timeout", request.waitForCompletionTimeout._toJsonString()); } if (request.searchType != null) { params.put("search_type", request.searchType.jsonValue()); } if (request.ccsMinimizeRoundtrips != null) { params.put("ccs_minimize_roundtrips", String.valueOf(request.ccsMinimizeRoundtrips)); } if (request.q != null) { params.put("q", request.q); } if (request.defaultOperator != null) { params.put("default_operator", request.defaultOperator.jsonValue()); } if (request.keepAlive != null) { params.put("keep_alive", request.keepAlive._toJsonString()); } if (request.requestCache != null) { params.put("request_cache", String.valueOf(request.requestCache)); } if (request.batchedReduceSize != null) { params.put("batched_reduce_size", String.valueOf(request.batchedReduceSize)); } return params; }, SimpleEndpoint.emptyMap(), true, SubmitResponse._DESERIALIZER); /** * Create an "{@code async_search.submit}" endpoint. */ public static Endpoint, ErrorResponse> createSubmitEndpoint( JsonpDeserializer tDocumentDeserializer) { return _ENDPOINT .withResponseDeserializer(SubmitResponse.createSubmitResponseDeserializer(tDocumentDeserializer)); } }