Polishing.

This commit is contained in:
Peter-Josef Meisch 2024-03-26 19:53:14 +01:00
parent 496b8d62a4
commit c96423d5ba
No known key found for this signature in database
GPG Key ID: DE108246970C7708
11 changed files with 1263 additions and 1331 deletions

View File

@ -51,15 +51,7 @@ import org.springframework.data.elasticsearch.core.convert.ElasticsearchConverte
import org.springframework.data.elasticsearch.core.document.Document;
import org.springframework.data.elasticsearch.core.document.SearchDocumentResponse;
import org.springframework.data.elasticsearch.core.mapping.IndexCoordinates;
import org.springframework.data.elasticsearch.core.query.BaseQueryBuilder;
import org.springframework.data.elasticsearch.core.query.BulkOptions;
import org.springframework.data.elasticsearch.core.query.ByQueryResponse;
import org.springframework.data.elasticsearch.core.query.DeleteQuery;
import org.springframework.data.elasticsearch.core.query.IndexQuery;
import org.springframework.data.elasticsearch.core.query.MoreLikeThisQuery;
import org.springframework.data.elasticsearch.core.query.Query;
import org.springframework.data.elasticsearch.core.query.SearchTemplateQuery;
import org.springframework.data.elasticsearch.core.query.UpdateQuery;
import org.springframework.data.elasticsearch.core.query.*;
import org.springframework.data.elasticsearch.core.query.UpdateResponse;
import org.springframework.data.elasticsearch.core.reindex.ReindexRequest;
import org.springframework.data.elasticsearch.core.reindex.ReindexResponse;
@ -517,18 +509,19 @@ public class ElasticsearchTemplate extends AbstractElasticsearchTemplate {
private List<SearchHits<?>> multiSearch(List<MultiSearchQueryParameter> multiSearchQueryParameters,
boolean isSearchTemplateQuery) {
return isSearchTemplateQuery ?
doMultiTemplateSearch(multiSearchQueryParameters.stream()
return isSearchTemplateQuery ? doMultiTemplateSearch(multiSearchQueryParameters.stream()
.map(p -> new MultiSearchTemplateQueryParameter((SearchTemplateQuery) p.query, p.clazz, p.index))
.toList())
: doMultiSearch(multiSearchQueryParameters);
}
private List<SearchHits<?>> doMultiTemplateSearch(List<MultiSearchTemplateQueryParameter> mSearchTemplateQueryParameters) {
private List<SearchHits<?>> doMultiTemplateSearch(
List<MultiSearchTemplateQueryParameter> mSearchTemplateQueryParameters) {
MsearchTemplateRequest request = requestConverter.searchMsearchTemplateRequest(mSearchTemplateQueryParameters,
routingResolver.getRouting());
MsearchTemplateResponse<EntityAsMap> response = execute(client -> client.msearchTemplate(request, EntityAsMap.class));
MsearchTemplateResponse<EntityAsMap> response = execute(
client -> client.msearchTemplate(request, EntityAsMap.class));
List<MultiSearchResponseItem<EntityAsMap>> responseItems = response.responses();
Assert.isTrue(mSearchTemplateQueryParameters.size() == responseItems.size(),

View File

@ -25,7 +25,6 @@ import co.elastic.clients.elasticsearch.core.search.ResponseBody;
import co.elastic.clients.json.JsonpMapper;
import co.elastic.clients.transport.Version;
import co.elastic.clients.transport.endpoints.BooleanResponse;
import org.springframework.data.elasticsearch.core.query.DeleteQuery;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
import reactor.util.function.Tuple2;
@ -62,6 +61,7 @@ import org.springframework.data.elasticsearch.core.query.BaseQuery;
import org.springframework.data.elasticsearch.core.query.BaseQueryBuilder;
import org.springframework.data.elasticsearch.core.query.BulkOptions;
import org.springframework.data.elasticsearch.core.query.ByQueryResponse;
import org.springframework.data.elasticsearch.core.query.DeleteQuery;
import org.springframework.data.elasticsearch.core.query.Query;
import org.springframework.data.elasticsearch.core.query.SearchTemplateQuery;
import org.springframework.data.elasticsearch.core.query.UpdateQuery;
@ -437,8 +437,7 @@ public class ReactiveElasticsearchTemplate extends AbstractReactiveElasticsearch
static private class PitSearchAfter {
private final BaseQuery baseQuery;
@Nullable
private final Sort sort;
@Nullable private final Sort sort;
private final String pit;
PitSearchAfter(BaseQuery baseQuery, String pit) {

View File

@ -1022,8 +1022,7 @@ class RequestConverter {
return sortField.field() + ":" + order;
})
.collect(Collectors.toList())
);
.collect(Collectors.toList()));
}
}
dqb.allowNoIndices(query.getAllowNoIndices())

View File

@ -509,6 +509,7 @@ final class TypeUtils {
*
* @param operator spring-data-elasticsearch operator.
* @return an Elasticsearch Operator.
* @since 5.3
*/
@Nullable
static Operator operator(@Nullable OperatorType operator) {
@ -520,6 +521,7 @@ final class TypeUtils {
*
* @param conflicts spring-data-elasticsearch {@literal conflicts}.
* @return an Elasticsearch {@literal conflicts}.
* @since 5.3
*/
@Nullable
static Conflicts conflicts(@Nullable ConflictsType conflicts) {

View File

@ -15,7 +15,6 @@
*/
package org.springframework.data.elasticsearch.core;
import org.springframework.data.elasticsearch.core.query.DeleteQuery;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
import reactor.core.publisher.Sinks;
@ -47,6 +46,7 @@ import org.springframework.data.elasticsearch.core.mapping.ElasticsearchPersiste
import org.springframework.data.elasticsearch.core.mapping.IndexCoordinates;
import org.springframework.data.elasticsearch.core.mapping.SimpleElasticsearchMappingContext;
import org.springframework.data.elasticsearch.core.query.ByQueryResponse;
import org.springframework.data.elasticsearch.core.query.DeleteQuery;
import org.springframework.data.elasticsearch.core.query.IndexQuery;
import org.springframework.data.elasticsearch.core.query.Query;
import org.springframework.data.elasticsearch.core.query.SeqNoPrimaryTerm;

View File

@ -15,7 +15,6 @@
*/
package org.springframework.data.elasticsearch.core;
import org.springframework.data.elasticsearch.core.query.DeleteQuery;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
@ -26,6 +25,7 @@ import java.util.List;
import org.springframework.data.elasticsearch.core.mapping.IndexCoordinates;
import org.springframework.data.elasticsearch.core.query.BulkOptions;
import org.springframework.data.elasticsearch.core.query.ByQueryResponse;
import org.springframework.data.elasticsearch.core.query.DeleteQuery;
import org.springframework.data.elasticsearch.core.query.Query;
import org.springframework.data.elasticsearch.core.query.UpdateQuery;
import org.springframework.data.elasticsearch.core.query.UpdateResponse;

View File

@ -15,6 +15,10 @@
*/
package org.springframework.data.elasticsearch.core.query;
import java.time.Duration;
import java.util.EnumSet;
import java.util.List;
import org.springframework.data.domain.Sort;
import org.springframework.data.elasticsearch.core.query.Query.SearchType;
import org.springframework.data.elasticsearch.core.query.types.ConflictsType;
@ -22,196 +26,161 @@ import org.springframework.data.elasticsearch.core.query.types.OperatorType;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import java.time.Duration;
import java.util.EnumSet;
import java.util.List;
/**
* Defines a delete request.
*
* @author Aouichaoui Youssef
* @see <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-delete-by-query.html">docs</a>
* @since 5.3
*/
public class DeleteQuery {
// For Lucene query
/**
* Query in the Lucene query string syntax.
*/
@Nullable
private final String q;
@Nullable private final String q;
/**
* If true, wildcard and prefix queries are analyzed. Defaults to false.
* This parameter can only be used when the lucene query {@code q} parameter is specified.
* If true, wildcard and prefix queries are analyzed. Defaults to false. This parameter can only be used when the
* lucene query {@code q} parameter is specified.
*/
@Nullable
private final Boolean analyzeWildcard;
@Nullable private final Boolean analyzeWildcard;
/**
* Analyzer to use for the query string.
* This parameter can only be used when the lucene query {@code q} parameter is specified.
* Analyzer to use for the query string. This parameter can only be used when the lucene query {@code q} parameter is
* specified.
*/
@Nullable
private final String analyzer;
@Nullable private final String analyzer;
/**
* The default operator for a query string query: {@literal AND} or {@literal OR}. Defaults to {@literal OR}.
* This parameter can only be used when the lucene query {@code q} parameter is specified.
* The default operator for a query string query: {@literal AND} or {@literal OR}. Defaults to {@literal OR}. This
* parameter can only be used when the lucene query {@code q} parameter is specified.
*/
@Nullable
private final OperatorType defaultOperator;
@Nullable private final OperatorType defaultOperator;
/**
* Field to be used as the default when no field prefix is specified in the query string.
* This parameter can only be used when the lucene query {@code q} parameter is specified.
* Field to be used as the default when no field prefix is specified in the query string. This parameter can only be
* used when the lucene query {@code q} parameter is specified.
* <p>
* e.g: {@code {"query":{"prefix":{"user.name":{"value":"es"}}}} }
*/
@Nullable
private final String df;
@Nullable private final String df;
/**
* If a query contains errors related to the format of the data being entered, they will be disregarded unless specified otherwise.
* By default, this feature is turned off.
* If a query contains errors related to the format of the data being entered, they will be disregarded unless
* specified otherwise. By default, this feature is turned off.
*/
@Nullable
private final Boolean lenient;
@Nullable private final Boolean lenient;
// For ES query
/**
* An error will occur if the condition is {@code false} and any of the following are true: a wildcard expression,
* an index alias, or the {@literal _all value} only targets missing or closed indices.
* By default, this is set to {@code true}.
* An error will occur if the condition is {@code false} and any of the following are true: a wildcard expression, an
* index alias, or the {@literal _all value} only targets missing or closed indices. By default, this is set to
* {@code true}.
*/
@Nullable
private final Boolean allowNoIndices;
@Nullable private final Boolean allowNoIndices;
/**
* Define the types of conflicts that occur when a query encounters version conflicts: abort or proceed.
* Defaults to abort.
* Define the types of conflicts that occur when a query encounters version conflicts: abort or proceed. Defaults to
* abort.
*/
@Nullable
private final ConflictsType conflicts;
@Nullable private final ConflictsType conflicts;
/**
* Type of index that wildcard patterns can match.
* Defaults to {@literal open}.
* Type of index that wildcard patterns can match. Defaults to {@literal open}.
*/
@Nullable
private final EnumSet<IndicesOptions.WildcardStates> expandWildcards;
@Nullable private final EnumSet<IndicesOptions.WildcardStates> expandWildcards;
/**
* An error occurs if it is directed at an index that is missing or closed when it is {@code false}.
* By default, this is set to {@code false}.
* An error occurs if it is directed at an index that is missing or closed when it is {@code false}. By default, this
* is set to {@code false}.
*/
@Nullable
private final Boolean ignoreUnavailable;
@Nullable private final Boolean ignoreUnavailable;
/**
* Maximum number of documents to process.
* Defaults to all documents.
* Maximum number of documents to process. Defaults to all documents.
*/
@Nullable
private final Long maxDocs;
@Nullable private final Long maxDocs;
/**
* Specifies the node or shard the operation should be performed on.
*/
@Nullable
private final String preference;
@Nullable private final String preference;
/**
* Use the request cache when it is {@code true}.
* By default, use the index-level setting.
* Use the request cache when it is {@code true}. By default, use the index-level setting.
*/
@Nullable
private final Boolean requestCache;
@Nullable private final Boolean requestCache;
/**
* Refreshes all shards involved in the deleting by query after the request completes when it is {@code true}.
* By default, this is set to {@code false}.
* Refreshes all shards involved in the deleting by query after the request completes when it is {@code true}. By
* default, this is set to {@code false}.
*/
@Nullable
private final Boolean refresh;
@Nullable private final Boolean refresh;
/**
* Limited this request to a certain number of sub-requests per second.
* By default, this is set to {@code -1} (no throttle).
* Limited this request to a certain number of sub-requests per second. By default, this is set to {@code -1} (no
* throttle).
*/
@Nullable
private final Float requestsPerSecond;
@Nullable private final Float requestsPerSecond;
/**
* Custom value used to route operations to a specific shard.
*/
@Nullable
private final String routing;
@Nullable private final String routing;
/**
* Period to retain the search context for scrolling.
*/
@Nullable
private final Duration scroll;
@Nullable private final Duration scroll;
/**
* Size of the scroll request that powers the operation.
* By default, this is set to {@code 1000}.
* Size of the scroll request that powers the operation. By default, this is set to {@code 1000}.
*/
@Nullable
private final Long scrollSize;
@Nullable private final Long scrollSize;
/**
* The type of the search operation.
*/
@Nullable
private final SearchType searchType;
@Nullable private final SearchType searchType;
/**
* Explicit timeout for each search request.
* By default, this is set to no timeout.
* Explicit timeout for each search request. By default, this is set to no timeout.
*/
@Nullable
private final Duration searchTimeout;
@Nullable private final Duration searchTimeout;
/**
* The number of slices this task should be divided into.
* By default, this is set to {@code 1} meaning the task isnt sliced into subtasks.
* The number of slices this task should be divided into. By default, this is set to {@code 1} meaning the task isnt
* sliced into subtasks.
*/
@Nullable
private final Integer slices;
@Nullable private final Integer slices;
/**
* Sort search results in a specific order.
*/
@Nullable
private final Sort sort;
@Nullable private final Sort sort;
/**
* Specific {@code tag} of the request for logging and statistical purposes.
*/
@Nullable
private final List<String> stats;
@Nullable private final List<String> stats;
/**
* The Maximum number of documents that can be collected for each shard.
* If a query exceeds this limit, Elasticsearch will stop the query.
* The Maximum number of documents that can be collected for each shard. If a query exceeds this limit, Elasticsearch
* will stop the query.
*/
@Nullable
private final Long terminateAfter;
@Nullable private final Long terminateAfter;
/**
* Period each deletion request waits for active shards.
* By default, this is set to {@code 1m} (one minute).
* Period each deletion request waits for active shards. By default, this is set to {@code 1m} (one minute).
*/
@Nullable
private final Duration timeout;
@Nullable private final Duration timeout;
/**
* Returns the document version as part of a hit.
*/
@Nullable
private final Boolean version;
@Nullable private final Boolean version;
// Body
/**
@ -392,60 +361,34 @@ public class DeleteQuery {
public static final class Builder {
// For Lucene query
@Nullable
private String luceneQuery;
@Nullable
private Boolean analyzeWildcard;
@Nullable
private String analyzer;
@Nullable
private OperatorType defaultOperator;
@Nullable
private String defaultField;
@Nullable
private Boolean lenient;
@Nullable private String luceneQuery;
@Nullable private Boolean analyzeWildcard;
@Nullable private String analyzer;
@Nullable private OperatorType defaultOperator;
@Nullable private String defaultField;
@Nullable private Boolean lenient;
// For ES query
@Nullable
private Boolean allowNoIndices;
@Nullable
private ConflictsType conflicts;
@Nullable
private EnumSet<IndicesOptions.WildcardStates> expandWildcards;
@Nullable
private Boolean ignoreUnavailable;
@Nullable
private Long maxDocs;
@Nullable
private String preference;
@Nullable
private Boolean requestCache;
@Nullable
private Boolean refresh;
@Nullable
private Float requestsPerSecond;
@Nullable
private String routing;
@Nullable
private Duration scrollTime;
@Nullable
private Long scrollSize;
@Nullable
private SearchType searchType;
@Nullable
private Duration searchTimeout;
@Nullable
private Integer slices;
@Nullable
private Sort sort;
@Nullable
private List<String> stats;
@Nullable
private Long terminateAfter;
@Nullable
private Duration timeout;
@Nullable
private Boolean version;
@Nullable private Boolean allowNoIndices;
@Nullable private ConflictsType conflicts;
@Nullable private EnumSet<IndicesOptions.WildcardStates> expandWildcards;
@Nullable private Boolean ignoreUnavailable;
@Nullable private Long maxDocs;
@Nullable private String preference;
@Nullable private Boolean requestCache;
@Nullable private Boolean refresh;
@Nullable private Float requestsPerSecond;
@Nullable private String routing;
@Nullable private Duration scrollTime;
@Nullable private Long scrollSize;
@Nullable private SearchType searchType;
@Nullable private Duration searchTimeout;
@Nullable private Integer slices;
@Nullable private Sort sort;
@Nullable private List<String> stats;
@Nullable private Long terminateAfter;
@Nullable private Duration timeout;
@Nullable private Boolean version;
// Body
private final Query query;
@ -466,8 +409,8 @@ public class DeleteQuery {
}
/**
* If true, wildcard and prefix queries are analyzed. Defaults to false.
* This parameter can only be used when the lucene query {@code q} parameter is specified.
* If true, wildcard and prefix queries are analyzed. Defaults to false. This parameter can only be used when the
* lucene query {@code q} parameter is specified.
*/
public Builder withAnalyzeWildcard(@Nullable Boolean analyzeWildcard) {
this.analyzeWildcard = analyzeWildcard;
@ -476,8 +419,8 @@ public class DeleteQuery {
}
/**
* Analyzer to use for the query string.
* This parameter can only be used when the lucene query {@code q} parameter is specified.
* Analyzer to use for the query string. This parameter can only be used when the lucene query {@code q} parameter
* is specified.
*/
public Builder withAnalyzer(@Nullable String analyzer) {
this.analyzer = analyzer;
@ -486,8 +429,8 @@ public class DeleteQuery {
}
/**
* The default operator for a query string query: {@literal AND} or {@literal OR}. Defaults to {@literal OR}.
* This parameter can only be used when the lucene query {@code q} parameter is specified.
* The default operator for a query string query: {@literal AND} or {@literal OR}. Defaults to {@literal OR}. This
* parameter can only be used when the lucene query {@code q} parameter is specified.
*/
public Builder withDefaultOperator(@Nullable OperatorType defaultOperator) {
this.defaultOperator = defaultOperator;
@ -496,8 +439,8 @@ public class DeleteQuery {
}
/**
* Field to be used as the default when no field prefix is specified in the query string.
* This parameter can only be used when the lucene query {@code q} parameter is specified.
* Field to be used as the default when no field prefix is specified in the query string. This parameter can only be
* used when the lucene query {@code q} parameter is specified.
* <p>
* e.g: {@code {"query":{"prefix":{"user.name":{"value":"es"}}}} }
*/
@ -508,8 +451,8 @@ public class DeleteQuery {
}
/**
* If a query contains errors related to the format of the data being entered, they will be disregarded unless specified otherwise.
* By default, this feature is turned off.
* If a query contains errors related to the format of the data being entered, they will be disregarded unless
* specified otherwise. By default, this feature is turned off.
*/
public Builder withLenient(@Nullable Boolean lenient) {
this.lenient = lenient;
@ -519,8 +462,8 @@ public class DeleteQuery {
/**
* An error will occur if the condition is {@code false} and any of the following are true: a wildcard expression,
* an index alias, or the {@literal _all value} only targets missing or closed indices.
* By default, this is set to {@code true}.
* an index alias, or the {@literal _all value} only targets missing or closed indices. By default, this is set to
* {@code true}.
*/
public Builder withAllowNoIndices(@Nullable Boolean allowNoIndices) {
this.allowNoIndices = allowNoIndices;
@ -529,8 +472,8 @@ public class DeleteQuery {
}
/**
* Define the types of conflicts that occur when a query encounters version conflicts: abort or proceed.
* Defaults to abort.
* Define the types of conflicts that occur when a query encounters version conflicts: abort or proceed. Defaults to
* abort.
*/
public Builder withConflicts(@Nullable ConflictsType conflicts) {
this.conflicts = conflicts;
@ -539,8 +482,7 @@ public class DeleteQuery {
}
/**
* Type of index that wildcard patterns can match.
* Defaults to {@literal open}.
* Type of index that wildcard patterns can match. Defaults to {@literal open}.
*/
public Builder setExpandWildcards(@Nullable EnumSet<IndicesOptions.WildcardStates> expandWildcards) {
this.expandWildcards = expandWildcards;
@ -549,8 +491,8 @@ public class DeleteQuery {
}
/**
* An error occurs if it is directed at an index that is missing or closed when it is {@code false}.
* By default, this is set to {@code false}.
* An error occurs if it is directed at an index that is missing or closed when it is {@code false}. By default,
* this is set to {@code false}.
*/
public Builder withIgnoreUnavailable(@Nullable Boolean ignoreUnavailable) {
this.ignoreUnavailable = ignoreUnavailable;
@ -559,8 +501,7 @@ public class DeleteQuery {
}
/**
* Maximum number of documents to process.
* Defaults to all documents.
* Maximum number of documents to process. Defaults to all documents.
*/
public Builder withMaxDocs(@Nullable Long maxDocs) {
this.maxDocs = maxDocs;
@ -578,8 +519,7 @@ public class DeleteQuery {
}
/**
* Use the request cache when it is {@code true}.
* By default, use the index-level setting.
* Use the request cache when it is {@code true}. By default, use the index-level setting.
*/
public Builder withRequestCache(@Nullable Boolean requestCache) {
this.requestCache = requestCache;
@ -588,8 +528,8 @@ public class DeleteQuery {
}
/**
* Refreshes all shards involved in the deleting by query after the request completes when it is {@code true}.
* By default, this is set to {@code false}.
* Refreshes all shards involved in the deleting by query after the request completes when it is {@code true}. By
* default, this is set to {@code false}.
*/
public Builder withRefresh(@Nullable Boolean refresh) {
this.refresh = refresh;
@ -598,8 +538,8 @@ public class DeleteQuery {
}
/**
* Limited this request to a certain number of sub-requests per second.
* By default, this is set to {@code -1} (no throttle).
* Limited this request to a certain number of sub-requests per second. By default, this is set to {@code -1} (no
* throttle).
*/
public Builder withRequestsPerSecond(@Nullable Float requestsPerSecond) {
this.requestsPerSecond = requestsPerSecond;
@ -626,8 +566,7 @@ public class DeleteQuery {
}
/**
* Size of the scroll request that powers the operation.
* By default, this is set to {@code 1000}.
* Size of the scroll request that powers the operation. By default, this is set to {@code 1000}.
*/
public Builder withScrollSize(@Nullable Long scrollSize) {
this.scrollSize = scrollSize;
@ -645,8 +584,7 @@ public class DeleteQuery {
}
/**
* Explicit timeout for each search request.
* By default, this is set to no timeout.
* Explicit timeout for each search request. By default, this is set to no timeout.
*/
public Builder withSearchTimeout(@Nullable Duration searchTimeout) {
this.searchTimeout = searchTimeout;
@ -655,8 +593,8 @@ public class DeleteQuery {
}
/**
* The number of slices this task should be divided into.
* By default, this is set to {@code 1} meaning the task isnt sliced into subtasks.
* The number of slices this task should be divided into. By default, this is set to {@code 1} meaning the task
* isnt sliced into subtasks.
*/
public Builder withSlices(@Nullable Integer slices) {
this.slices = slices;
@ -683,8 +621,8 @@ public class DeleteQuery {
}
/**
* The Maximum number of documents that can be collected for each shard.
* If a query exceeds this limit, Elasticsearch will stop the query.
* The Maximum number of documents that can be collected for each shard. If a query exceeds this limit,
* Elasticsearch will stop the query.
*/
public Builder withTerminateAfter(@Nullable Long terminateAfter) {
this.terminateAfter = terminateAfter;
@ -693,8 +631,7 @@ public class DeleteQuery {
}
/**
* Period each deletion request waits for active shards.
* By default, this is set to {@code 1m} (one minute).
* Period each deletion request waits for active shards. By default, this is set to {@code 1m} (one minute).
*/
public Builder withTimeout(@Nullable Duration timeout) {
this.timeout = timeout;
@ -717,13 +654,16 @@ public class DeleteQuery {
throw new IllegalArgumentException("When defining the df parameter, you must include the Lucene query.");
}
if (analyzer != null) {
throw new IllegalArgumentException("When defining the analyzer parameter, you must include the Lucene query.");
throw new IllegalArgumentException(
"When defining the analyzer parameter, you must include the Lucene query.");
}
if (analyzeWildcard != null) {
throw new IllegalArgumentException("When defining the analyzeWildcard parameter, you must include the Lucene query.");
throw new IllegalArgumentException(
"When defining the analyzeWildcard parameter, you must include the Lucene query.");
}
if (defaultOperator != null) {
throw new IllegalArgumentException("When defining the defaultOperator parameter, you must include the Lucene query.");
throw new IllegalArgumentException(
"When defining the defaultOperator parameter, you must include the Lucene query.");
}
if (lenient != null) {
throw new IllegalArgumentException("When defining the lenient parameter, you must include the Lucene query.");

View File

@ -19,6 +19,7 @@ package org.springframework.data.elasticsearch.core.query.types;
* Define the types of conflicts that occur when a query encounters version conflicts.
*
* @author Aouichaoui Youssef
* @since 5.3
*/
public enum ConflictsType {
Abort, Proceed

View File

@ -19,6 +19,7 @@ package org.springframework.data.elasticsearch.core.query.types;
* Define the default operator for a query string query.
*
* @author Aouichaoui Youssef
* @since 5.3
*/
public enum OperatorType {
And, Or

View File

@ -19,16 +19,11 @@ import static java.util.Collections.*;
import static org.assertj.core.api.Assertions.*;
import static org.springframework.data.elasticsearch.annotations.Document.VersionType.*;
import static org.springframework.data.elasticsearch.annotations.FieldType.*;
import static org.springframework.data.elasticsearch.annotations.FieldType.Integer;
import static org.springframework.data.elasticsearch.core.document.Document.*;
import static org.springframework.data.elasticsearch.core.query.StringQuery.*;
import static org.springframework.data.elasticsearch.utils.IdGenerator.*;
import static org.springframework.data.elasticsearch.utils.IndexBuilder.*;
import java.lang.Double;
import java.lang.Integer;
import java.lang.Long;
import java.lang.Object;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
@ -2976,8 +2971,8 @@ public abstract class ElasticsearchIntegrationTests {
.build();
Query query = getBuilderWithTermQuery("message", "message") //
.withHighlightQuery(
new HighlightQuery(new Highlight(singletonList(new HighlightField("message", sameHighlightQuery))), HighlightEntity.class)
)
new HighlightQuery(new Highlight(singletonList(new HighlightField("message", sameHighlightQuery))),
HighlightEntity.class))
.build();
SearchHits<HighlightEntity> searchHits = operations.search(query, HighlightEntity.class, index);
@ -3002,8 +2997,9 @@ public abstract class ElasticsearchIntegrationTests {
// highlight_query in field
Query highlightQueryInField = getBuilderWithTermQuery("message", "message") //
.withHighlightQuery(
new HighlightQuery(new Highlight(singletonList(new HighlightField("message", differentHighlightQueryInField))), HighlightEntity.class)
)
new HighlightQuery(
new Highlight(singletonList(new HighlightField("message", differentHighlightQueryInField))),
HighlightEntity.class))
.build();
assertThatHighlightFieldsIsDifferentFromHighlightQuery(highlightQueryInField, index);
}
@ -3019,8 +3015,9 @@ public abstract class ElasticsearchIntegrationTests {
// highlight_query in param
Query highlightQueryInParam = getBuilderWithTermQuery("message", "message") //
.withHighlightQuery(
new HighlightQuery(new Highlight(differentHighlightQueryInParam, singletonList(new HighlightField("message"))), HighlightEntity.class)
)
new HighlightQuery(
new Highlight(differentHighlightQueryInParam, singletonList(new HighlightField("message"))),
HighlightEntity.class))
.build();
assertThatHighlightFieldsIsDifferentFromHighlightQuery(highlightQueryInParam, index);
}
@ -3035,8 +3032,9 @@ public abstract class ElasticsearchIntegrationTests {
// highlight_query in param
Query differentHighlightQueryUsingCriteria = getBuilderWithTermQuery("message", "message") //
.withHighlightQuery(
new HighlightQuery(new Highlight(criteriaHighlightQueryInParam, singletonList(new HighlightField("message"))), HighlightEntity.class)
)
new HighlightQuery(
new Highlight(criteriaHighlightQueryInParam, singletonList(new HighlightField("message"))),
HighlightEntity.class))
.build();
assertThatHighlightFieldsIsDifferentFromHighlightQuery(differentHighlightQueryUsingCriteria, index);
}
@ -3055,14 +3053,13 @@ public abstract class ElasticsearchIntegrationTests {
}
}
}
"""
))
"""))
.build();
// highlight_query in param
Query differentHighlightQueryUsingStringQuery = getBuilderWithTermQuery("message", "message") //
.withHighlightQuery(
new HighlightQuery(new Highlight(stringHighlightQueryInParam, singletonList(new HighlightField("message"))), HighlightEntity.class)
)
new HighlightQuery(new Highlight(stringHighlightQueryInParam, singletonList(new HighlightField("message"))),
HighlightEntity.class))
.build();
assertThatHighlightFieldsIsDifferentFromHighlightQuery(differentHighlightQueryUsingStringQuery, index);
}