mirror of
https://github.com/spring-projects/spring-data-elasticsearch.git
synced 2025-06-23 04:22:12 +00:00
DATAES-739 - Introduce nullable annotations for API validation.
Original PR: #387
This commit is contained in:
parent
4fc4d91b74
commit
936de20421
@ -17,15 +17,18 @@ package org.springframework.data.elasticsearch;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* ElasticsearchException
|
||||
*
|
||||
* @author Rizwan Idrees
|
||||
* @author Mohsin Husen
|
||||
* @author Peter-Josef Meisch
|
||||
*/
|
||||
public class ElasticsearchException extends RuntimeException {
|
||||
|
||||
private Map<String, String> failedDocuments;
|
||||
@Nullable private Map<String, String> failedDocuments;
|
||||
|
||||
public ElasticsearchException(String message) {
|
||||
super(message);
|
||||
@ -45,6 +48,7 @@ public class ElasticsearchException extends RuntimeException {
|
||||
this.failedDocuments = failedDocuments;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Map<String, String> getFailedDocuments() {
|
||||
return failedDocuments;
|
||||
}
|
||||
|
@ -0,0 +1,3 @@
|
||||
@org.springframework.lang.NonNullApi
|
||||
@org.springframework.lang.NonNullFields
|
||||
package org.springframework.data.elasticsearch.annotations;
|
@ -54,11 +54,11 @@ class ClientConfigurationBuilder
|
||||
private @Nullable HostnameVerifier hostnameVerifier;
|
||||
private Duration connectTimeout = Duration.ofSeconds(10);
|
||||
private Duration soTimeout = Duration.ofSeconds(5);
|
||||
private String username;
|
||||
private String password;
|
||||
private String pathPrefix;
|
||||
private String proxy;
|
||||
private Function<WebClient, WebClient> webClientConfigurer;
|
||||
private @Nullable String username;
|
||||
private @Nullable String password;
|
||||
private @Nullable String pathPrefix;
|
||||
private @Nullable String proxy;
|
||||
private @Nullable Function<WebClient, WebClient> webClientConfigurer;
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
|
@ -32,7 +32,9 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.DisposableBean;
|
||||
import org.springframework.beans.factory.FactoryBean;
|
||||
import org.springframework.beans.factory.FactoryBeanNotInitializedException;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
@ -48,12 +50,12 @@ public class NodeClientFactoryBean implements FactoryBean<Client>, InitializingB
|
||||
private static final Logger logger = LoggerFactory.getLogger(NodeClientFactoryBean.class);
|
||||
private boolean local;
|
||||
private boolean enableHttp;
|
||||
private String clusterName;
|
||||
private Node node;
|
||||
private NodeClient nodeClient;
|
||||
private String pathData;
|
||||
private String pathHome;
|
||||
private String pathConfiguration;
|
||||
private @Nullable String clusterName;
|
||||
private @Nullable Node node;
|
||||
private @Nullable NodeClient nodeClient;
|
||||
private @Nullable String pathData;
|
||||
private @Nullable String pathHome;
|
||||
private @Nullable String pathConfiguration;
|
||||
|
||||
public static class TestNode extends Node {
|
||||
|
||||
@ -82,6 +84,11 @@ public class NodeClientFactoryBean implements FactoryBean<Client>, InitializingB
|
||||
|
||||
@Override
|
||||
public NodeClient getObject() {
|
||||
|
||||
if (nodeClient == null) {
|
||||
throw new FactoryBeanNotInitializedException();
|
||||
}
|
||||
|
||||
return nodeClient;
|
||||
}
|
||||
|
||||
|
@ -25,18 +25,21 @@ import org.elasticsearch.client.RestClient;
|
||||
import org.elasticsearch.client.RestHighLevelClient;
|
||||
import org.springframework.beans.factory.DisposableBean;
|
||||
import org.springframework.beans.factory.FactoryBean;
|
||||
import org.springframework.beans.factory.FactoryBeanNotInitializedException;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* RestClientFactoryBean
|
||||
*
|
||||
* @author Don Wellington
|
||||
* @author Peter-Josef Meisch
|
||||
*/
|
||||
@Slf4j
|
||||
public class RestClientFactoryBean implements FactoryBean<RestHighLevelClient>, InitializingBean, DisposableBean {
|
||||
|
||||
private RestHighLevelClient client;
|
||||
private @Nullable RestHighLevelClient client;
|
||||
private String hosts = "http://localhost:9200";
|
||||
static final String COMMA = ",";
|
||||
|
||||
@ -59,6 +62,11 @@ public class RestClientFactoryBean implements FactoryBean<RestHighLevelClient>,
|
||||
|
||||
@Override
|
||||
public RestHighLevelClient getObject() {
|
||||
|
||||
if (client == null) {
|
||||
throw new FactoryBeanNotInitializedException();
|
||||
}
|
||||
|
||||
return client;
|
||||
}
|
||||
|
||||
@ -75,6 +83,7 @@ public class RestClientFactoryBean implements FactoryBean<RestHighLevelClient>,
|
||||
protected void buildClient() throws Exception {
|
||||
|
||||
Assert.hasText(hosts, "[Assertion Failed] At least one host must be set.");
|
||||
|
||||
ArrayList<HttpHost> httpHosts = new ArrayList<>();
|
||||
for (String host : hosts.split(COMMA)) {
|
||||
URL hostUrl = new URL(host);
|
||||
|
@ -24,7 +24,9 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.DisposableBean;
|
||||
import org.springframework.beans.factory.FactoryBean;
|
||||
import org.springframework.beans.factory.FactoryBeanNotInitializedException;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* TransportClientFactoryBean
|
||||
@ -48,8 +50,8 @@ public class TransportClientFactoryBean implements FactoryBean<TransportClient>,
|
||||
private Boolean clientIgnoreClusterName = Boolean.FALSE;
|
||||
private String clientPingTimeout = "5s";
|
||||
private String clientNodesSamplerInterval = "5s";
|
||||
private TransportClient client;
|
||||
private Properties properties;
|
||||
private @Nullable TransportClient client;
|
||||
private @Nullable Properties properties;
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
@ -65,6 +67,10 @@ public class TransportClientFactoryBean implements FactoryBean<TransportClient>,
|
||||
|
||||
@Override
|
||||
public TransportClient getObject() {
|
||||
|
||||
if (clientTransportSniff == null) {
|
||||
throw new FactoryBeanNotInitializedException();
|
||||
}
|
||||
return client;
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,3 @@
|
||||
@org.springframework.lang.NonNullApi
|
||||
@org.springframework.lang.NonNullFields
|
||||
package org.springframework.data.elasticsearch.client;
|
@ -865,8 +865,9 @@ public class DefaultReactiveElasticsearchClient implements ReactiveElasticsearch
|
||||
private final Object lock = new Object();
|
||||
|
||||
private final List<String> pastIds = new ArrayList<>(1);
|
||||
private String scrollId;
|
||||
@Nullable private String scrollId;
|
||||
|
||||
@Nullable
|
||||
String getScrollId() {
|
||||
return scrollId;
|
||||
}
|
||||
|
@ -105,6 +105,7 @@ public interface WebClientProvider {
|
||||
* @return the pathPrefix if set.
|
||||
* @since 4.0
|
||||
*/
|
||||
@Nullable
|
||||
String getPathPrefix();
|
||||
|
||||
/**
|
||||
@ -133,7 +134,9 @@ public interface WebClientProvider {
|
||||
WebClientProvider withPathPrefix(String pathPrefix);
|
||||
|
||||
/**
|
||||
* Create a new instance of {@link WebClientProvider} calling the given {@link Function} to configure the {@link WebClient}.
|
||||
* Create a new instance of {@link WebClientProvider} calling the given {@link Function} to configure the
|
||||
* {@link WebClient}.
|
||||
*
|
||||
* @param webClientConfigurer configuration function
|
||||
* @return new instance of {@link WebClientProvider}
|
||||
* @since 4.0
|
||||
|
@ -1,6 +1,3 @@
|
||||
/**
|
||||
* Everything required for a Reactive Elasticsearch client.
|
||||
*/
|
||||
@org.springframework.lang.NonNullApi
|
||||
@org.springframework.lang.NonNullFields
|
||||
package org.springframework.data.elasticsearch.client.reactive;
|
||||
|
@ -0,0 +1,3 @@
|
||||
@org.springframework.lang.NonNullApi
|
||||
@org.springframework.lang.NonNullFields
|
||||
package org.springframework.data.elasticsearch.client.util;
|
@ -0,0 +1,3 @@
|
||||
@org.springframework.lang.NonNullApi
|
||||
@org.springframework.lang.NonNullFields
|
||||
package org.springframework.data.elasticsearch.config;
|
@ -31,6 +31,7 @@ import org.springframework.data.elasticsearch.core.query.MoreLikeThisQuery;
|
||||
import org.springframework.data.elasticsearch.core.query.NativeSearchQueryBuilder;
|
||||
import org.springframework.data.elasticsearch.core.query.Query;
|
||||
import org.springframework.data.util.CloseableIterator;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
@ -41,9 +42,9 @@ import org.springframework.util.Assert;
|
||||
*/
|
||||
public abstract class AbstractElasticsearchTemplate implements ElasticsearchOperations, ApplicationContextAware {
|
||||
|
||||
protected ElasticsearchConverter elasticsearchConverter;
|
||||
protected RequestFactory requestFactory;
|
||||
protected IndexOperations indexOperations;
|
||||
protected @Nullable ElasticsearchConverter elasticsearchConverter;
|
||||
protected @Nullable RequestFactory requestFactory;
|
||||
protected @Nullable IndexOperations indexOperations;
|
||||
|
||||
// region Initialization
|
||||
protected void initialize(ElasticsearchConverter elasticsearchConverter, IndexOperations indexOperations) {
|
||||
@ -74,6 +75,9 @@ public abstract class AbstractElasticsearchTemplate implements ElasticsearchOper
|
||||
// region getter/setter
|
||||
@Override
|
||||
public IndexOperations getIndexOperations() {
|
||||
|
||||
Assert.notNull("indexOperations are not initialized");
|
||||
|
||||
return indexOperations;
|
||||
}
|
||||
// endregion
|
||||
@ -159,6 +163,9 @@ public abstract class AbstractElasticsearchTemplate implements ElasticsearchOper
|
||||
// region Helper methods
|
||||
@Override
|
||||
public ElasticsearchConverter getElasticsearchConverter() {
|
||||
|
||||
Assert.notNull(elasticsearchConverter, "elasticsearchConverter is not initialized.");
|
||||
|
||||
return elasticsearchConverter;
|
||||
}
|
||||
|
||||
@ -166,6 +173,9 @@ public abstract class AbstractElasticsearchTemplate implements ElasticsearchOper
|
||||
* @since 4.0
|
||||
*/
|
||||
public RequestFactory getRequestFactory() {
|
||||
|
||||
Assert.notNull(requestFactory, "requestfactory not initialized");
|
||||
|
||||
return requestFactory;
|
||||
}
|
||||
|
||||
|
@ -34,6 +34,7 @@ import org.springframework.data.geo.Box;
|
||||
import org.springframework.data.geo.Distance;
|
||||
import org.springframework.data.geo.Metrics;
|
||||
import org.springframework.data.geo.Point;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
@ -100,7 +101,9 @@ class CriteriaFilterProcessor {
|
||||
return filterList;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private QueryBuilder processCriteriaEntry(OperationKey key, Object value, String fieldName) {
|
||||
|
||||
if (value == null) {
|
||||
return null;
|
||||
}
|
||||
|
@ -30,6 +30,7 @@ import org.apache.lucene.queryparser.flexible.standard.QueryParserUtil;
|
||||
import org.elasticsearch.index.query.BoolQueryBuilder;
|
||||
import org.elasticsearch.index.query.QueryBuilder;
|
||||
import org.springframework.data.elasticsearch.core.query.Criteria;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
@ -46,8 +47,8 @@ import org.springframework.util.Assert;
|
||||
class CriteriaQueryProcessor {
|
||||
|
||||
QueryBuilder createQueryFromCriteria(Criteria criteria) {
|
||||
if (criteria == null)
|
||||
return null;
|
||||
|
||||
Assert.notNull(criteria, "criteria must not be null");
|
||||
|
||||
List<QueryBuilder> shouldQueryBuilderList = new LinkedList<>();
|
||||
List<QueryBuilder> mustNotQueryBuilderList = new LinkedList<>();
|
||||
@ -109,6 +110,7 @@ class CriteriaQueryProcessor {
|
||||
return query;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private QueryBuilder createQueryFragmentForCriteria(Criteria chainedCriteria) {
|
||||
if (chainedCriteria.getQueryCriteriaEntries().isEmpty())
|
||||
return null;
|
||||
@ -135,6 +137,7 @@ class CriteriaQueryProcessor {
|
||||
return query;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private QueryBuilder processCriteriaEntry(Criteria.CriteriaEntry entry, String fieldName) {
|
||||
OperationKey key = entry.getKey();
|
||||
Object value = entry.getValue();
|
||||
|
@ -93,10 +93,12 @@ public class ElasticsearchRestTemplate extends AbstractElasticsearchTemplate {
|
||||
|
||||
// region Initialization
|
||||
public ElasticsearchRestTemplate(RestHighLevelClient client) {
|
||||
this.client = client;
|
||||
initialize(client, createElasticsearchConverter());
|
||||
}
|
||||
|
||||
public ElasticsearchRestTemplate(RestHighLevelClient client, ElasticsearchConverter elasticsearchConverter) {
|
||||
this.client = client;
|
||||
initialize(client, elasticsearchConverter);
|
||||
}
|
||||
|
||||
@ -210,7 +212,7 @@ public class ElasticsearchRestTemplate extends AbstractElasticsearchTemplate {
|
||||
|
||||
// region SearchOperations
|
||||
@Override
|
||||
public long count(Query query, Class<?> clazz, IndexCoordinates index) {
|
||||
public long count(Query query,@Nullable Class<?> clazz, IndexCoordinates index) {
|
||||
|
||||
Assert.notNull(query, "query must not be null");
|
||||
Assert.notNull(index, "index must not be null");
|
||||
|
@ -83,14 +83,16 @@ public class ElasticsearchTemplate extends AbstractElasticsearchTemplate {
|
||||
.getLogger("org.springframework.data.elasticsearch.core.QUERY");
|
||||
|
||||
private Client client;
|
||||
private String searchTimeout;
|
||||
@Nullable private String searchTimeout;
|
||||
|
||||
// region Initialization
|
||||
public ElasticsearchTemplate(Client client) {
|
||||
this.client = client;
|
||||
initialize(client, createElasticsearchConverter());
|
||||
}
|
||||
|
||||
public ElasticsearchTemplate(Client client, ElasticsearchConverter elasticsearchConverter) {
|
||||
this.client = client;
|
||||
initialize(client, elasticsearchConverter);
|
||||
}
|
||||
|
||||
@ -102,6 +104,7 @@ public class ElasticsearchTemplate extends AbstractElasticsearchTemplate {
|
||||
// endregion
|
||||
|
||||
// region getter/setter
|
||||
@Nullable
|
||||
public String getSearchTimeout() {
|
||||
return searchTimeout;
|
||||
}
|
||||
|
@ -867,6 +867,7 @@ class RequestFactory {
|
||||
return clazz != null ? elasticsearchConverter.getMappingContext().getPersistentEntity(clazz) : null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private String getPersistentEntityId(Object entity) {
|
||||
|
||||
Object identifier = elasticsearchConverter.getMappingContext() //
|
||||
|
@ -21,6 +21,7 @@ import java.nio.charset.Charset;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.StreamUtils;
|
||||
|
||||
/**
|
||||
@ -40,6 +41,7 @@ public abstract class ResourceUtil {
|
||||
* @param url
|
||||
* @return
|
||||
*/
|
||||
@Nullable
|
||||
public static String readFileFromClasspath(String url) {
|
||||
|
||||
ClassPathResource classPathResource = new ClassPathResource(url);
|
||||
|
@ -2,12 +2,14 @@
|
||||
package org.springframework.data.elasticsearch.core;
|
||||
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* @author Artur Konczak
|
||||
* @author Peter-Josef Meisch
|
||||
*/
|
||||
public interface ScrolledPage<T> extends Page<T> {
|
||||
|
||||
@Nullable
|
||||
String getScrollId();
|
||||
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import org.elasticsearch.search.aggregations.Aggregation;
|
||||
import org.elasticsearch.search.aggregations.Aggregations;
|
||||
import org.springframework.data.elasticsearch.core.ScoredPage;
|
||||
import org.springframework.data.elasticsearch.core.ScrolledPage;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* @author Petar Tahchiev
|
||||
@ -16,7 +17,7 @@ public interface AggregatedPage<T> extends ScrolledPage<T>, ScoredPage<T> {
|
||||
|
||||
boolean hasAggregations();
|
||||
|
||||
Aggregations getAggregations();
|
||||
@Nullable Aggregations getAggregations();
|
||||
|
||||
Aggregation getAggregation(String name);
|
||||
@Nullable Aggregation getAggregation(String name);
|
||||
}
|
||||
|
@ -25,6 +25,7 @@ import org.springframework.data.domain.PageImpl;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.elasticsearch.core.aggregation.AggregatedPage;
|
||||
import org.springframework.data.elasticsearch.core.document.SearchDocumentResponse;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* @author Petar Tahchiev
|
||||
@ -35,8 +36,8 @@ import org.springframework.data.elasticsearch.core.document.SearchDocumentRespon
|
||||
*/
|
||||
public class AggregatedPageImpl<T> extends PageImpl<T> implements AggregatedPage<T> {
|
||||
|
||||
private Aggregations aggregations;
|
||||
private String scrollId;
|
||||
@Nullable private Aggregations aggregations;
|
||||
@Nullable private String scrollId;
|
||||
private float maxScore;
|
||||
|
||||
private static Pageable pageableOrUnpaged(Pageable pageable) {
|
||||
@ -114,15 +115,18 @@ public class AggregatedPageImpl<T> extends PageImpl<T> implements AggregatedPage
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public Aggregations getAggregations() {
|
||||
return aggregations;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public Aggregation getAggregation(String name) {
|
||||
return aggregations == null ? null : aggregations.get(name);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public String getScrollId() {
|
||||
return scrollId;
|
||||
|
@ -0,0 +1,3 @@
|
||||
@org.springframework.lang.NonNullApi
|
||||
@org.springframework.lang.NonNullFields
|
||||
package org.springframework.data.elasticsearch.core.aggregation.impl;
|
@ -0,0 +1,3 @@
|
||||
@org.springframework.lang.NonNullApi
|
||||
@org.springframework.lang.NonNullFields
|
||||
package org.springframework.data.elasticsearch.core.aggregation;
|
@ -0,0 +1,3 @@
|
||||
@org.springframework.lang.NonNullApi
|
||||
@org.springframework.lang.NonNullFields
|
||||
package org.springframework.data.elasticsearch.core.client.support;
|
@ -1,27 +1,23 @@
|
||||
package org.springframework.data.elasticsearch.core.completion;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* Based on the reference doc -
|
||||
* https://www.elastic.co/guide/en/elasticsearch/reference/current/search-suggesters-completion.html
|
||||
*
|
||||
* @author Mewes Kochheim
|
||||
* @author Robert Gruendler
|
||||
* @author Peter-Josef Meisch
|
||||
*/
|
||||
@JsonInclude(value = JsonInclude.Include.NON_NULL)
|
||||
public class Completion {
|
||||
|
||||
private String[] input;
|
||||
private Map<String, List<String>> contexts;
|
||||
private Integer weight;
|
||||
|
||||
private Completion() {
|
||||
// required by mapper to instantiate object
|
||||
}
|
||||
@Nullable private Map<String, List<String>> contexts;
|
||||
@Nullable private Integer weight;
|
||||
|
||||
public Completion(String[] input) {
|
||||
this.input = input;
|
||||
@ -35,6 +31,7 @@ public class Completion {
|
||||
this.input = input;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Integer getWeight() {
|
||||
return weight;
|
||||
}
|
||||
@ -43,6 +40,7 @@ public class Completion {
|
||||
this.weight = weight;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Map<String, List<String>> getContexts() {
|
||||
return contexts;
|
||||
}
|
||||
|
@ -0,0 +1,3 @@
|
||||
@org.springframework.lang.NonNullApi
|
||||
@org.springframework.lang.NonNullFields
|
||||
package org.springframework.data.elasticsearch.core.completion;
|
@ -147,7 +147,7 @@ public class MappingElasticsearchConverter
|
||||
|
||||
@Override
|
||||
public <T> AggregatedPage<SearchHit<T>> mapResults(SearchDocumentResponse response, Class<T> type,
|
||||
Pageable pageable) {
|
||||
@Nullable Pageable pageable) {
|
||||
|
||||
List<SearchHit<T>> results = response.getSearchDocuments().stream() //
|
||||
.map(searchDocument -> read(type, searchDocument)) //
|
||||
@ -653,6 +653,7 @@ public class MappingElasticsearchConverter
|
||||
collectionSource.map(it -> {
|
||||
|
||||
if (it == null) {
|
||||
//noinspection ReturnOfNull
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -1,2 +1,3 @@
|
||||
@org.springframework.lang.NonNullApi
|
||||
@org.springframework.lang.NonNullFields
|
||||
package org.springframework.data.elasticsearch.core.convert;
|
||||
|
@ -124,6 +124,7 @@ public class DocumentAdapters {
|
||||
|
||||
Assert.notNull(source, "MultiGetResponse must not be null");
|
||||
|
||||
//noinspection ReturnOfNull
|
||||
return Arrays.stream(source.getResponses()) //
|
||||
.map(itemResponse -> itemResponse.isFailed() ? null : DocumentAdapters.from(itemResponse.getResponse())) //
|
||||
.filter(Objects::nonNull).collect(Collectors.toList());
|
||||
|
@ -1,5 +1,3 @@
|
||||
/**
|
||||
* interfaces and classes related to the Document representation of Elasticsearch documents.
|
||||
*/
|
||||
@org.springframework.lang.NonNullApi
|
||||
@org.springframework.lang.NonNullFields
|
||||
package org.springframework.data.elasticsearch.core.document;
|
||||
|
@ -0,0 +1,3 @@
|
||||
@org.springframework.lang.NonNullApi
|
||||
@org.springframework.lang.NonNullFields
|
||||
package org.springframework.data.elasticsearch.core.geo;
|
@ -1,5 +1,3 @@
|
||||
/**
|
||||
* infrastructure to define the Elasticsearch mapping for an index.
|
||||
*/
|
||||
@org.springframework.lang.NonNullApi
|
||||
@org.springframework.lang.NonNullFields
|
||||
package org.springframework.data.elasticsearch.core.index;
|
||||
|
@ -41,20 +41,24 @@ public interface ElasticsearchPersistentEntity<T> extends PersistentEntity<T, El
|
||||
|
||||
boolean isUseServerConfiguration();
|
||||
|
||||
@Nullable
|
||||
String getRefreshInterval();
|
||||
|
||||
@Nullable
|
||||
String getIndexStoreType();
|
||||
|
||||
@Override
|
||||
ElasticsearchPersistentProperty getVersionProperty();
|
||||
|
||||
@Nullable
|
||||
String getParentType();
|
||||
|
||||
@Nullable
|
||||
ElasticsearchPersistentProperty getParentIdProperty();
|
||||
|
||||
String settingPath();
|
||||
|
||||
VersionType getVersionType();
|
||||
@Nullable VersionType getVersionType();
|
||||
|
||||
boolean isCreateIndexAndMapping();
|
||||
|
||||
|
@ -71,7 +71,7 @@ public class SimpleElasticsearchPersistentEntity<T> extends BasicPersistentEntit
|
||||
private @Nullable ElasticsearchPersistentProperty parentIdProperty;
|
||||
private @Nullable ElasticsearchPersistentProperty scoreProperty;
|
||||
private @Nullable String settingPath;
|
||||
private VersionType versionType;
|
||||
private @Nullable VersionType versionType;
|
||||
private boolean createIndexAndMapping;
|
||||
private final Map<String, ElasticsearchPersistentProperty> fieldNamePropertyCache = new ConcurrentHashMap<>();
|
||||
|
||||
@ -133,6 +133,7 @@ public class SimpleElasticsearchPersistentEntity<T> extends BasicPersistentEntit
|
||||
return IndexCoordinates.of(getIndexName()).withTypes(getIndexType());
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public String getIndexStoreType() {
|
||||
return indexStoreType;
|
||||
@ -153,21 +154,25 @@ public class SimpleElasticsearchPersistentEntity<T> extends BasicPersistentEntit
|
||||
return useServerConfiguration;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public String getRefreshInterval() {
|
||||
return refreshInterval;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public String getParentType() {
|
||||
return parentType;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public ElasticsearchPersistentProperty getParentIdProperty() {
|
||||
return parentIdProperty;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public VersionType getVersionType() {
|
||||
return versionType;
|
||||
|
@ -53,7 +53,7 @@ public class SimpleElasticsearchPersistentProperty extends
|
||||
private final boolean isParent;
|
||||
private final boolean isId;
|
||||
private final @Nullable String annotatedFieldName;
|
||||
private ElasticsearchPersistentPropertyConverter propertyConverter;
|
||||
@Nullable private ElasticsearchPersistentPropertyConverter propertyConverter;
|
||||
|
||||
public SimpleElasticsearchPersistentProperty(Property property,
|
||||
PersistentEntity<?, ElasticsearchPersistentProperty> owner, SimpleTypeHolder simpleTypeHolder) {
|
||||
@ -86,6 +86,7 @@ public class SimpleElasticsearchPersistentProperty extends
|
||||
return propertyConverter != null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public ElasticsearchPersistentPropertyConverter getPropertyConverter() {
|
||||
return propertyConverter;
|
||||
@ -167,7 +168,7 @@ public class SimpleElasticsearchPersistentProperty extends
|
||||
*/
|
||||
@Override
|
||||
protected Association<ElasticsearchPersistentProperty> createAssociation() {
|
||||
return null;
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1,5 +1,3 @@
|
||||
/**
|
||||
* Infrastructure for the Elasticsearch document-to-object mapping subsystem.
|
||||
*/
|
||||
@org.springframework.lang.NonNullApi
|
||||
@org.springframework.lang.NonNullFields
|
||||
package org.springframework.data.elasticsearch.core.mapping;
|
||||
|
@ -0,0 +1,3 @@
|
||||
@org.springframework.lang.NonNullApi
|
||||
@org.springframework.lang.NonNullFields
|
||||
package org.springframework.data.elasticsearch.core;
|
@ -26,6 +26,7 @@ import org.elasticsearch.action.search.SearchType;
|
||||
import org.elasticsearch.action.support.IndicesOptions;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
@ -42,21 +43,22 @@ import org.springframework.util.Assert;
|
||||
abstract class AbstractQuery implements Query {
|
||||
|
||||
protected Pageable pageable = DEFAULT_PAGE;
|
||||
protected Sort sort;
|
||||
@Nullable protected Sort sort;
|
||||
protected List<String> fields = new ArrayList<>();
|
||||
protected SourceFilter sourceFilter;
|
||||
@Nullable protected SourceFilter sourceFilter;
|
||||
protected float minScore;
|
||||
protected Collection<String> ids;
|
||||
protected String route;
|
||||
@Nullable protected Collection<String> ids;
|
||||
@Nullable protected String route;
|
||||
protected SearchType searchType = SearchType.DFS_QUERY_THEN_FETCH;
|
||||
protected IndicesOptions indicesOptions;
|
||||
@Nullable protected IndicesOptions indicesOptions;
|
||||
protected boolean trackScores;
|
||||
protected String preference;
|
||||
protected Integer maxResults;
|
||||
protected HighlightQuery highlightQuery;
|
||||
@Nullable protected String preference;
|
||||
@Nullable protected Integer maxResults;
|
||||
@Nullable protected HighlightQuery highlightQuery;
|
||||
private boolean trackTotalHits = false;
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public Sort getSort() {
|
||||
return this.sort;
|
||||
}
|
||||
@ -90,6 +92,7 @@ abstract class AbstractQuery implements Query {
|
||||
this.sourceFilter = sourceFilter;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public SourceFilter getSourceFilter() {
|
||||
return sourceFilter;
|
||||
@ -120,6 +123,7 @@ abstract class AbstractQuery implements Query {
|
||||
this.minScore = minScore;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Collection<String> getIds() {
|
||||
return ids;
|
||||
@ -129,6 +133,7 @@ abstract class AbstractQuery implements Query {
|
||||
this.ids = ids;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public String getRoute() {
|
||||
return route;
|
||||
@ -147,6 +152,7 @@ abstract class AbstractQuery implements Query {
|
||||
return searchType;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public IndicesOptions getIndicesOptions() {
|
||||
return indicesOptions;
|
||||
@ -175,6 +181,7 @@ abstract class AbstractQuery implements Query {
|
||||
this.trackScores = trackScores;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public String getPreference() {
|
||||
return preference;
|
||||
@ -190,6 +197,7 @@ abstract class AbstractQuery implements Query {
|
||||
return maxResults != null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Integer getMaxResults() {
|
||||
return maxResults;
|
||||
|
@ -18,6 +18,8 @@ package org.springframework.data.elasticsearch.core.query;
|
||||
import java.util.Map;
|
||||
|
||||
import org.elasticsearch.index.query.QueryBuilder;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* @author Mohsin Husen
|
||||
@ -25,12 +27,12 @@ import org.elasticsearch.index.query.QueryBuilder;
|
||||
*/
|
||||
public class AliasBuilder {
|
||||
|
||||
private String aliasName;
|
||||
private QueryBuilder filterBuilder;
|
||||
private Map<String, Object> filter;
|
||||
private String searchRouting;
|
||||
private String indexRouting;
|
||||
private String routing;
|
||||
@Nullable private String aliasName;
|
||||
@Nullable private QueryBuilder filterBuilder;
|
||||
@Nullable private Map<String, Object> filter;
|
||||
@Nullable private String searchRouting;
|
||||
@Nullable private String indexRouting;
|
||||
@Nullable private String routing;
|
||||
|
||||
public AliasBuilder withAliasName(String aliasName) {
|
||||
this.aliasName = aliasName;
|
||||
@ -63,8 +65,10 @@ public class AliasBuilder {
|
||||
}
|
||||
|
||||
public AliasQuery build() {
|
||||
AliasQuery aliasQuery = new AliasQuery();
|
||||
aliasQuery.setAliasName(aliasName);
|
||||
|
||||
Assert.notNull(aliasName, "aliasName must not be null");
|
||||
|
||||
AliasQuery aliasQuery = new AliasQuery(aliasName);
|
||||
aliasQuery.setFilterBuilder(filterBuilder);
|
||||
aliasQuery.setFilter(filter);
|
||||
aliasQuery.setSearchRouting(searchRouting);
|
||||
|
@ -18,6 +18,8 @@ package org.springframework.data.elasticsearch.core.query;
|
||||
import java.util.Map;
|
||||
|
||||
import org.elasticsearch.index.query.QueryBuilder;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* AliasQuery is useful for creating new alias or deleting existing ones
|
||||
@ -27,21 +29,25 @@ import org.elasticsearch.index.query.QueryBuilder;
|
||||
*/
|
||||
public class AliasQuery {
|
||||
|
||||
public AliasQuery(String aliasName) {
|
||||
|
||||
Assert.notNull(aliasName, "aliasName must not be null");
|
||||
|
||||
this.aliasName = aliasName;
|
||||
}
|
||||
|
||||
private String aliasName;
|
||||
private QueryBuilder filterBuilder;
|
||||
private Map<String, Object> filter;
|
||||
private String searchRouting;
|
||||
private String indexRouting;
|
||||
private String routing;
|
||||
@Nullable private QueryBuilder filterBuilder;
|
||||
@Nullable private Map<String, Object> filter;
|
||||
@Nullable private String searchRouting;
|
||||
@Nullable private String indexRouting;
|
||||
@Nullable private String routing;
|
||||
|
||||
public String getAliasName() {
|
||||
return aliasName;
|
||||
}
|
||||
|
||||
public void setAliasName(String aliasName) {
|
||||
this.aliasName = aliasName;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public QueryBuilder getFilterBuilder() {
|
||||
return filterBuilder;
|
||||
}
|
||||
@ -50,6 +56,7 @@ public class AliasQuery {
|
||||
this.filterBuilder = filterBuilder;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Map<String, Object> getFilter() {
|
||||
return filter;
|
||||
}
|
||||
@ -58,6 +65,7 @@ public class AliasQuery {
|
||||
this.filter = filter;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getSearchRouting() {
|
||||
return searchRouting;
|
||||
}
|
||||
@ -66,6 +74,7 @@ public class AliasQuery {
|
||||
this.searchRouting = searchRouting;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getIndexRouting() {
|
||||
return indexRouting;
|
||||
}
|
||||
@ -74,6 +83,7 @@ public class AliasQuery {
|
||||
this.indexRouting = indexRouting;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getRouting() {
|
||||
return routing;
|
||||
}
|
||||
|
@ -29,6 +29,7 @@ import org.springframework.data.elasticsearch.core.geo.GeoPoint;
|
||||
import org.springframework.data.geo.Box;
|
||||
import org.springframework.data.geo.Distance;
|
||||
import org.springframework.data.geo.Point;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
@ -57,7 +58,7 @@ public class Criteria {
|
||||
private static final String OR_OPERATOR = " OR ";
|
||||
private static final String AND_OPERATOR = " AND ";
|
||||
|
||||
private Field field;
|
||||
private @Nullable Field field;
|
||||
private float boost = Float.NaN;
|
||||
private boolean negating = false;
|
||||
|
||||
@ -84,8 +85,10 @@ public class Criteria {
|
||||
* @param field
|
||||
*/
|
||||
public Criteria(Field field) {
|
||||
|
||||
Assert.notNull(field, "Field for criteria must not be null");
|
||||
Assert.hasText(field.getName(), "Field.name for criteria must not be null/empty");
|
||||
|
||||
this.criteriaChain.add(this);
|
||||
this.field = field;
|
||||
}
|
||||
@ -95,6 +98,7 @@ public class Criteria {
|
||||
}
|
||||
|
||||
protected Criteria(List<Criteria> criteriaChain, Field field) {
|
||||
|
||||
Assert.notNull(criteriaChain, "CriteriaChain must not be null");
|
||||
Assert.notNull(field, "Field for criteria must not be null");
|
||||
Assert.hasText(field.getName(), "Field.name for criteria must not be null/empty");
|
||||
@ -525,6 +529,7 @@ public class Criteria {
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Nullable
|
||||
public Field getField() {
|
||||
return this.field;
|
||||
}
|
||||
|
@ -16,6 +16,7 @@
|
||||
package org.springframework.data.elasticsearch.core.query;
|
||||
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
@ -28,7 +29,7 @@ import org.springframework.util.Assert;
|
||||
*/
|
||||
public class CriteriaQuery extends AbstractQuery {
|
||||
|
||||
private Criteria criteria;
|
||||
private @Nullable Criteria criteria;
|
||||
|
||||
private CriteriaQuery() {}
|
||||
|
||||
@ -51,9 +52,9 @@ public class CriteriaQuery extends AbstractQuery {
|
||||
}
|
||||
|
||||
public static <T extends CriteriaQuery> T fromQuery(CriteriaQuery source, T destination) {
|
||||
if (source == null || destination == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Assert.notNull(source, "source must not be null");
|
||||
Assert.notNull(destination, "destination must not be null");
|
||||
|
||||
if (source.getCriteria() != null) {
|
||||
destination.addCriteria(source.getCriteria());
|
||||
@ -77,6 +78,7 @@ public class CriteriaQuery extends AbstractQuery {
|
||||
return (T) this;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Criteria getCriteria() {
|
||||
return this.criteria;
|
||||
}
|
||||
|
@ -16,6 +16,7 @@
|
||||
package org.springframework.data.elasticsearch.core.query;
|
||||
|
||||
import org.elasticsearch.index.query.QueryBuilder;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* DeleteQuery
|
||||
@ -26,10 +27,11 @@ import org.elasticsearch.index.query.QueryBuilder;
|
||||
*/
|
||||
public class DeleteQuery {
|
||||
|
||||
private QueryBuilder query;
|
||||
private Integer pageSize;
|
||||
private Long scrollTimeInMillis;
|
||||
@Nullable private QueryBuilder query;
|
||||
@Nullable private Integer pageSize;
|
||||
@Nullable private Long scrollTimeInMillis;
|
||||
|
||||
@Nullable
|
||||
public QueryBuilder getQuery() {
|
||||
return query;
|
||||
}
|
||||
@ -38,6 +40,7 @@ public class DeleteQuery {
|
||||
this.query = query;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Integer getPageSize() {
|
||||
return pageSize;
|
||||
}
|
||||
@ -46,6 +49,7 @@ public class DeleteQuery {
|
||||
this.pageSize = pageSize;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Long getScrollTimeInMillis() {
|
||||
return scrollTimeInMillis;
|
||||
}
|
||||
|
@ -15,15 +15,18 @@
|
||||
*/
|
||||
package org.springframework.data.elasticsearch.core.query;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* SourceFilter builder for providing includes and excludes.
|
||||
*
|
||||
* @Author Jon Tsiros
|
||||
* @author Peter-Josef Meisch
|
||||
*/
|
||||
public class FetchSourceFilterBuilder {
|
||||
|
||||
private String[] includes;
|
||||
private String[] excludes;
|
||||
@Nullable private String[] includes;
|
||||
@Nullable private String[] excludes;
|
||||
|
||||
public FetchSourceFilterBuilder withIncludes(String... includes) {
|
||||
this.includes = includes;
|
||||
@ -36,8 +39,10 @@ public class FetchSourceFilterBuilder {
|
||||
}
|
||||
|
||||
public SourceFilter build() {
|
||||
if (includes == null) includes = new String[0];
|
||||
if (excludes == null) excludes = new String[0];
|
||||
if (includes == null)
|
||||
includes = new String[0];
|
||||
if (excludes == null)
|
||||
excludes = new String[0];
|
||||
|
||||
return new FetchSourceFilter(includes, excludes);
|
||||
}
|
||||
|
@ -20,23 +20,21 @@ package org.springframework.data.elasticsearch.core.query;
|
||||
*
|
||||
* @author Rizwan Idrees
|
||||
* @author Mohsin Husen
|
||||
* @author Peter-Josef Meisch
|
||||
*/
|
||||
public class GetQuery {
|
||||
|
||||
public GetQuery(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
private String id;
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public static GetQuery getById(String id) {
|
||||
|
||||
GetQuery query = new GetQuery();
|
||||
query.setId(id);
|
||||
return query;
|
||||
return new GetQuery(id);
|
||||
}
|
||||
}
|
||||
|
@ -15,6 +15,8 @@
|
||||
*/
|
||||
package org.springframework.data.elasticsearch.core.query;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* IndexQuery
|
||||
*
|
||||
@ -25,12 +27,13 @@ package org.springframework.data.elasticsearch.core.query;
|
||||
|
||||
public class IndexQuery {
|
||||
|
||||
private String id;
|
||||
private Object object;
|
||||
private Long version;
|
||||
private String source;
|
||||
private String parentId;
|
||||
@Nullable private String id;
|
||||
@Nullable private Object object;
|
||||
@Nullable private Long version;
|
||||
@Nullable private String source;
|
||||
@Nullable private String parentId;
|
||||
|
||||
@Nullable
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
@ -39,6 +42,7 @@ public class IndexQuery {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Object getObject() {
|
||||
return object;
|
||||
}
|
||||
@ -47,6 +51,7 @@ public class IndexQuery {
|
||||
this.object = object;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Long getVersion() {
|
||||
return version;
|
||||
}
|
||||
@ -55,6 +60,7 @@ public class IndexQuery {
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getSource() {
|
||||
return source;
|
||||
}
|
||||
@ -63,6 +69,7 @@ public class IndexQuery {
|
||||
this.source = source;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getParentId() {
|
||||
return parentId;
|
||||
}
|
||||
|
@ -15,6 +15,8 @@
|
||||
*/
|
||||
package org.springframework.data.elasticsearch.core.query;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* IndexQuery Builder
|
||||
*
|
||||
@ -24,11 +26,11 @@ package org.springframework.data.elasticsearch.core.query;
|
||||
*/
|
||||
public class IndexQueryBuilder {
|
||||
|
||||
private String id;
|
||||
private Object object;
|
||||
private Long version;
|
||||
private String source;
|
||||
private String parentId;
|
||||
@Nullable private String id;
|
||||
@Nullable private Object object;
|
||||
@Nullable private Long version;
|
||||
@Nullable private String source;
|
||||
@Nullable private String parentId;
|
||||
|
||||
public IndexQueryBuilder withId(String id) {
|
||||
this.id = id;
|
||||
|
@ -22,6 +22,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* MoreLikeThisQuery
|
||||
@ -32,22 +33,23 @@ import org.springframework.data.domain.Pageable;
|
||||
*/
|
||||
public class MoreLikeThisQuery {
|
||||
|
||||
private String id;
|
||||
@Nullable private String id;
|
||||
private List<String> searchIndices = new ArrayList<>();
|
||||
private List<String> searchTypes = new ArrayList<>();
|
||||
private List<String> fields = new ArrayList<>();
|
||||
private String routing;
|
||||
private Float percentTermsToMatch;
|
||||
private Integer minTermFreq;
|
||||
private Integer maxQueryTerms;
|
||||
@Nullable private String routing;
|
||||
@Nullable private Float percentTermsToMatch;
|
||||
@Nullable private Integer minTermFreq;
|
||||
@Nullable private Integer maxQueryTerms;
|
||||
private List<String> stopWords = new ArrayList<>();
|
||||
private Integer minDocFreq;
|
||||
private Integer maxDocFreq;
|
||||
private Integer minWordLen;
|
||||
private Integer maxWordLen;
|
||||
private Float boostTerms;
|
||||
@Nullable private Integer minDocFreq;
|
||||
@Nullable private Integer maxDocFreq;
|
||||
@Nullable private Integer minWordLen;
|
||||
@Nullable private Integer maxWordLen;
|
||||
@Nullable private Float boostTerms;
|
||||
private Pageable pageable = DEFAULT_PAGE;
|
||||
|
||||
@Nullable
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
@ -80,6 +82,7 @@ public class MoreLikeThisQuery {
|
||||
addAll(this.fields, fields);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getRouting() {
|
||||
return routing;
|
||||
}
|
||||
@ -88,6 +91,7 @@ public class MoreLikeThisQuery {
|
||||
this.routing = routing;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Float getPercentTermsToMatch() {
|
||||
return percentTermsToMatch;
|
||||
}
|
||||
@ -96,6 +100,7 @@ public class MoreLikeThisQuery {
|
||||
this.percentTermsToMatch = percentTermsToMatch;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Integer getMinTermFreq() {
|
||||
return minTermFreq;
|
||||
}
|
||||
@ -104,6 +109,7 @@ public class MoreLikeThisQuery {
|
||||
this.minTermFreq = minTermFreq;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Integer getMaxQueryTerms() {
|
||||
return maxQueryTerms;
|
||||
}
|
||||
@ -120,6 +126,7 @@ public class MoreLikeThisQuery {
|
||||
addAll(this.stopWords, stopWords);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Integer getMinDocFreq() {
|
||||
return minDocFreq;
|
||||
}
|
||||
@ -128,6 +135,7 @@ public class MoreLikeThisQuery {
|
||||
this.minDocFreq = minDocFreq;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Integer getMaxDocFreq() {
|
||||
return maxDocFreq;
|
||||
}
|
||||
@ -136,6 +144,7 @@ public class MoreLikeThisQuery {
|
||||
this.maxDocFreq = maxDocFreq;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Integer getMinWordLen() {
|
||||
return minWordLen;
|
||||
}
|
||||
@ -144,6 +153,7 @@ public class MoreLikeThisQuery {
|
||||
this.minWordLen = minWordLen;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Integer getMaxWordLen() {
|
||||
return maxWordLen;
|
||||
}
|
||||
@ -152,6 +162,7 @@ public class MoreLikeThisQuery {
|
||||
this.maxWordLen = maxWordLen;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Float getBoostTerms() {
|
||||
return boostTerms;
|
||||
}
|
||||
|
@ -24,6 +24,7 @@ import org.elasticsearch.search.aggregations.AbstractAggregationBuilder;
|
||||
import org.elasticsearch.search.collapse.CollapseBuilder;
|
||||
import org.elasticsearch.search.fetch.subphase.highlight.HighlightBuilder;
|
||||
import org.elasticsearch.search.sort.SortBuilder;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* NativeSearchQuery
|
||||
@ -38,14 +39,14 @@ import org.elasticsearch.search.sort.SortBuilder;
|
||||
public class NativeSearchQuery extends AbstractQuery {
|
||||
|
||||
private QueryBuilder query;
|
||||
private QueryBuilder filter;
|
||||
private List<SortBuilder> sorts;
|
||||
@Nullable private QueryBuilder filter;
|
||||
@Nullable private List<SortBuilder> sorts;
|
||||
private final List<ScriptField> scriptFields = new ArrayList<>();
|
||||
private CollapseBuilder collapseBuilder;
|
||||
private List<AbstractAggregationBuilder> aggregations;
|
||||
private HighlightBuilder highlightBuilder;
|
||||
private HighlightBuilder.Field[] highlightFields;
|
||||
private List<IndexBoost> indicesBoost;
|
||||
@Nullable private CollapseBuilder collapseBuilder;
|
||||
@Nullable private List<AbstractAggregationBuilder> aggregations;
|
||||
@Nullable private HighlightBuilder highlightBuilder;
|
||||
@Nullable private HighlightBuilder.Field[] highlightFields;
|
||||
@Nullable private List<IndexBoost> indicesBoost;
|
||||
|
||||
public NativeSearchQuery(QueryBuilder query) {
|
||||
|
||||
@ -88,6 +89,7 @@ public class NativeSearchQuery extends AbstractQuery {
|
||||
return query;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public QueryBuilder getFilter() {
|
||||
return filter;
|
||||
}
|
||||
@ -96,6 +98,7 @@ public class NativeSearchQuery extends AbstractQuery {
|
||||
return sorts;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public HighlightBuilder getHighlightBuilder() {
|
||||
return highlightBuilder;
|
||||
}
|
||||
@ -116,6 +119,7 @@ public class NativeSearchQuery extends AbstractQuery {
|
||||
scriptFields.addAll(Arrays.asList(scriptField));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public CollapseBuilder getCollapseBuilder() {
|
||||
return collapseBuilder;
|
||||
}
|
||||
@ -124,6 +128,7 @@ public class NativeSearchQuery extends AbstractQuery {
|
||||
this.collapseBuilder = collapseBuilder;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public List<AbstractAggregationBuilder> getAggregations() {
|
||||
return aggregations;
|
||||
}
|
||||
@ -141,6 +146,7 @@ public class NativeSearchQuery extends AbstractQuery {
|
||||
this.aggregations = aggregations;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public List<IndexBoost> getIndicesBoost() {
|
||||
return indicesBoost;
|
||||
}
|
||||
|
@ -29,6 +29,7 @@ import org.elasticsearch.search.collapse.CollapseBuilder;
|
||||
import org.elasticsearch.search.fetch.subphase.highlight.HighlightBuilder;
|
||||
import org.elasticsearch.search.sort.SortBuilder;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* NativeSearchQuery
|
||||
@ -46,25 +47,25 @@ import org.springframework.data.domain.Pageable;
|
||||
*/
|
||||
public class NativeSearchQueryBuilder {
|
||||
|
||||
private QueryBuilder queryBuilder;
|
||||
private QueryBuilder filterBuilder;
|
||||
@Nullable private QueryBuilder queryBuilder;
|
||||
@Nullable private QueryBuilder filterBuilder;
|
||||
private List<ScriptField> scriptFields = new ArrayList<>();
|
||||
private List<SortBuilder> sortBuilders = new ArrayList<>();
|
||||
private List<AbstractAggregationBuilder> aggregationBuilders = new ArrayList<>();
|
||||
private HighlightBuilder highlightBuilder;
|
||||
private HighlightBuilder.Field[] highlightFields;
|
||||
@Nullable private HighlightBuilder highlightBuilder;
|
||||
@Nullable private HighlightBuilder.Field[] highlightFields;
|
||||
private Pageable pageable = Pageable.unpaged();
|
||||
private String[] fields;
|
||||
private SourceFilter sourceFilter;
|
||||
private CollapseBuilder collapseBuilder;
|
||||
private List<IndexBoost> indicesBoost;
|
||||
@Nullable private String[] fields;
|
||||
@Nullable private SourceFilter sourceFilter;
|
||||
@Nullable private CollapseBuilder collapseBuilder;
|
||||
@Nullable private List<IndexBoost> indicesBoost;
|
||||
private float minScore;
|
||||
private boolean trackScores;
|
||||
private Collection<String> ids;
|
||||
private String route;
|
||||
private SearchType searchType;
|
||||
private IndicesOptions indicesOptions;
|
||||
private String preference;
|
||||
@Nullable private Collection<String> ids;
|
||||
@Nullable private String route;
|
||||
@Nullable private SearchType searchType;
|
||||
@Nullable private IndicesOptions indicesOptions;
|
||||
@Nullable private String preference;
|
||||
|
||||
public NativeSearchQueryBuilder withQuery(QueryBuilder queryBuilder) {
|
||||
this.queryBuilder = queryBuilder;
|
||||
|
@ -81,6 +81,7 @@ public interface Query {
|
||||
/**
|
||||
* @return null if not set
|
||||
*/
|
||||
@Nullable
|
||||
Sort getSort();
|
||||
|
||||
/**
|
||||
@ -109,6 +110,7 @@ public interface Query {
|
||||
*
|
||||
* @return SourceFilter
|
||||
*/
|
||||
@Nullable
|
||||
SourceFilter getSourceFilter();
|
||||
|
||||
/**
|
||||
@ -131,6 +133,7 @@ public interface Query {
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Nullable
|
||||
Collection<String> getIds();
|
||||
|
||||
/**
|
||||
@ -138,6 +141,7 @@ public interface Query {
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Nullable
|
||||
String getRoute();
|
||||
|
||||
/**
|
||||
@ -152,6 +156,7 @@ public interface Query {
|
||||
*
|
||||
* @return null if not set
|
||||
*/
|
||||
@Nullable
|
||||
IndicesOptions getIndicesOptions();
|
||||
|
||||
/**
|
||||
@ -160,6 +165,7 @@ public interface Query {
|
||||
* @return
|
||||
* @since 3.2
|
||||
*/
|
||||
@Nullable
|
||||
String getPreference();
|
||||
|
||||
/**
|
||||
@ -183,17 +189,18 @@ public interface Query {
|
||||
*
|
||||
* @since 4.0
|
||||
*/
|
||||
@Nullable
|
||||
default Integer getMaxResults() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the {@link HighlightQuery}.*
|
||||
* Sets the {@link HighlightQuery}.
|
||||
*
|
||||
* @param highlightQuery the query to set
|
||||
* @since 4.0
|
||||
*/
|
||||
void setHighlightQuery(@Nullable HighlightQuery highlightQuery);
|
||||
void setHighlightQuery(HighlightQuery highlightQuery);
|
||||
|
||||
/**
|
||||
* @return the optional set {@link HighlightQuery}.
|
||||
|
@ -29,12 +29,15 @@ public class SimpleField implements Field {
|
||||
private String name;
|
||||
|
||||
public SimpleField(String name) {
|
||||
setName(name);
|
||||
Assert.notNull(name, "name must not be null");
|
||||
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setName(String name) {
|
||||
Assert.notNull(name, "name must not be null");
|
||||
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
|
@ -16,6 +16,7 @@
|
||||
package org.springframework.data.elasticsearch.core.query;
|
||||
|
||||
import org.elasticsearch.action.update.UpdateRequest;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* @author Rizwan Idrees
|
||||
@ -24,10 +25,11 @@ import org.elasticsearch.action.update.UpdateRequest;
|
||||
*/
|
||||
public class UpdateQuery {
|
||||
|
||||
private String id;
|
||||
private UpdateRequest updateRequest;
|
||||
@Nullable private String id;
|
||||
@Nullable private UpdateRequest updateRequest;
|
||||
private boolean doUpsert;
|
||||
|
||||
@Nullable
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
@ -36,6 +38,7 @@ public class UpdateQuery {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public UpdateRequest getUpdateRequest() {
|
||||
return updateRequest;
|
||||
}
|
||||
|
@ -17,6 +17,7 @@ package org.springframework.data.elasticsearch.core.query;
|
||||
|
||||
import org.elasticsearch.action.index.IndexRequest;
|
||||
import org.elasticsearch.action.update.UpdateRequest;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* @author Rizwan Idrees
|
||||
@ -25,9 +26,9 @@ import org.elasticsearch.action.update.UpdateRequest;
|
||||
*/
|
||||
public class UpdateQueryBuilder {
|
||||
|
||||
private String id;
|
||||
private UpdateRequest updateRequest;
|
||||
private IndexRequest indexRequest;
|
||||
@Nullable private String id;
|
||||
@Nullable private UpdateRequest updateRequest;
|
||||
@Nullable private IndexRequest indexRequest;
|
||||
private boolean doUpsert;
|
||||
|
||||
public UpdateQueryBuilder withId(String id) {
|
||||
|
@ -0,0 +1,3 @@
|
||||
@org.springframework.lang.NonNullApi
|
||||
@org.springframework.lang.NonNullFields
|
||||
package org.springframework.data.elasticsearch.core.query;
|
@ -0,0 +1,3 @@
|
||||
@org.springframework.lang.NonNullApi
|
||||
@org.springframework.lang.NonNullFields
|
||||
package org.springframework.data.elasticsearch;
|
@ -0,0 +1,3 @@
|
||||
@org.springframework.lang.NonNullApi
|
||||
@org.springframework.lang.NonNullFields
|
||||
package org.springframework.data.elasticsearch.repository.cdi;
|
@ -0,0 +1,3 @@
|
||||
@org.springframework.lang.NonNullApi
|
||||
@org.springframework.lang.NonNullFields
|
||||
package org.springframework.data.elasticsearch.repository.config;
|
@ -0,0 +1,3 @@
|
||||
@org.springframework.lang.NonNullApi
|
||||
@org.springframework.lang.NonNullFields
|
||||
package org.springframework.data.elasticsearch.repository.query;
|
@ -1,5 +1,3 @@
|
||||
/**
|
||||
* Infrastructure for the Elasticsearch document-to-object mapping subsystem.
|
||||
*/
|
||||
@org.springframework.lang.NonNullApi
|
||||
@org.springframework.lang.NonNullFields
|
||||
package org.springframework.data.elasticsearch.repository.query.parser;
|
||||
|
@ -79,10 +79,8 @@ public abstract class AbstractElasticsearchRepository<T, ID> implements Elastics
|
||||
protected ElasticsearchOperations operations;
|
||||
protected IndexOperations indexOperations;
|
||||
|
||||
protected Class<T> entityClass;
|
||||
protected ElasticsearchEntityInformation<T, ID> entityInformation;
|
||||
|
||||
public AbstractElasticsearchRepository() {}
|
||||
protected @Nullable Class<T> entityClass;
|
||||
protected @Nullable ElasticsearchEntityInformation<T, ID> entityInformation;
|
||||
|
||||
public AbstractElasticsearchRepository(ElasticsearchOperations operations) {
|
||||
Assert.notNull(operations, "ElasticsearchOperations must not be null.");
|
||||
@ -125,8 +123,7 @@ public abstract class AbstractElasticsearchRepository<T, ID> implements Elastics
|
||||
|
||||
@Override
|
||||
public Optional<T> findById(ID id) {
|
||||
GetQuery query = new GetQuery();
|
||||
query.setId(stringIdRepresentation(id));
|
||||
GetQuery query = new GetQuery(stringIdRepresentation(id));
|
||||
return Optional.ofNullable(operations.get(query, getEntityClass(), getIndexCoordinates()));
|
||||
}
|
||||
|
||||
@ -250,9 +247,11 @@ public abstract class AbstractElasticsearchRepository<T, ID> implements Elastics
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public Page<T> searchSimilar(T entity, String[] fields, Pageable pageable) {
|
||||
public Page<T> searchSimilar(T entity, @Nullable String[] fields, Pageable pageable) {
|
||||
|
||||
Assert.notNull(entity, "Cannot search similar records for 'null'.");
|
||||
Assert.notNull(pageable, "'pageable' cannot be 'null'");
|
||||
|
||||
MoreLikeThisQuery query = new MoreLikeThisQuery();
|
||||
query.setId(stringIdRepresentation(extractIdFromBean(entity)));
|
||||
query.setPageable(pageable);
|
||||
@ -395,7 +394,7 @@ public abstract class AbstractElasticsearchRepository<T, ID> implements Elastics
|
||||
return stringIds;
|
||||
}
|
||||
|
||||
protected abstract String stringIdRepresentation(@Nullable ID id);
|
||||
protected abstract @Nullable String stringIdRepresentation(@Nullable ID id);
|
||||
|
||||
private Long extractVersionFromBean(T entity) {
|
||||
return entityInformation.getVersion(entity);
|
||||
|
@ -35,6 +35,7 @@ import org.springframework.data.repository.query.QueryLookupStrategy;
|
||||
import org.springframework.data.repository.query.QueryLookupStrategy.Key;
|
||||
import org.springframework.data.repository.query.QueryMethodEvaluationContextProvider;
|
||||
import org.springframework.data.repository.query.RepositoryQuery;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
@ -47,6 +48,7 @@ import org.springframework.util.Assert;
|
||||
* @author Mark Paluch
|
||||
* @author Christoph Strobl
|
||||
* @author Sascha Woo
|
||||
* @author Peter-Josef Meisch
|
||||
*/
|
||||
public class ElasticsearchRepositoryFactory extends RepositoryFactorySupport {
|
||||
|
||||
@ -87,7 +89,7 @@ public class ElasticsearchRepositoryFactory extends RepositoryFactorySupport {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Optional<QueryLookupStrategy> getQueryLookupStrategy(Key key,
|
||||
protected Optional<QueryLookupStrategy> getQueryLookupStrategy(@Nullable Key key,
|
||||
QueryMethodEvaluationContextProvider evaluationContextProvider) {
|
||||
return Optional.of(new ElasticsearchQueryLookupStrategy());
|
||||
}
|
||||
|
@ -21,6 +21,7 @@ import org.springframework.data.elasticsearch.core.ElasticsearchOperations;
|
||||
import org.springframework.data.repository.Repository;
|
||||
import org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport;
|
||||
import org.springframework.data.repository.core.support.RepositoryFactorySupport;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
@ -30,11 +31,12 @@ import org.springframework.util.Assert;
|
||||
* @author Rizwan Idrees
|
||||
* @author Mohsin Husen
|
||||
* @author Mark Paluch
|
||||
* @author Peter-Josef Meisch
|
||||
*/
|
||||
public class ElasticsearchRepositoryFactoryBean<T extends Repository<S, ID>, S, ID extends Serializable> extends
|
||||
RepositoryFactoryBeanSupport<T, S, ID> {
|
||||
public class ElasticsearchRepositoryFactoryBean<T extends Repository<S, ID>, S, ID extends Serializable>
|
||||
extends RepositoryFactoryBeanSupport<T, S, ID> {
|
||||
|
||||
private ElasticsearchOperations operations;
|
||||
@Nullable private ElasticsearchOperations operations;
|
||||
|
||||
/**
|
||||
* Creates a new {@link ElasticsearchRepositoryFactoryBean} for the given repository interface.
|
||||
@ -70,6 +72,9 @@ public class ElasticsearchRepositoryFactoryBean<T extends Repository<S, ID>, S,
|
||||
|
||||
@Override
|
||||
protected RepositoryFactorySupport createRepositoryFactory() {
|
||||
|
||||
Assert.notNull(operations, "operations are not initialized");
|
||||
|
||||
return new ElasticsearchRepositoryFactory(operations);
|
||||
}
|
||||
}
|
||||
|
@ -18,6 +18,7 @@ package org.springframework.data.elasticsearch.repository.support;
|
||||
import java.util.Objects;
|
||||
|
||||
import org.springframework.data.elasticsearch.core.ElasticsearchOperations;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* Elasticsearch specific repository implementation. Likely to be used as target within
|
||||
@ -27,13 +28,10 @@ import org.springframework.data.elasticsearch.core.ElasticsearchOperations;
|
||||
* @author Mohsin Husen
|
||||
* @author Ryan Henszey
|
||||
* @author Sascha Woo
|
||||
* @author Peter-Josef Meisch
|
||||
*/
|
||||
public class SimpleElasticsearchRepository<T, ID> extends AbstractElasticsearchRepository<T, ID> {
|
||||
|
||||
public SimpleElasticsearchRepository() {
|
||||
super();
|
||||
}
|
||||
|
||||
public SimpleElasticsearchRepository(ElasticsearchEntityInformation<T, ID> metadata,
|
||||
ElasticsearchOperations elasticsearchOperations) {
|
||||
super(metadata, elasticsearchOperations);
|
||||
@ -44,7 +42,7 @@ public class SimpleElasticsearchRepository<T, ID> extends AbstractElasticsearchR
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String stringIdRepresentation(ID id) {
|
||||
protected @Nullable String stringIdRepresentation(@Nullable ID id) {
|
||||
return Objects.toString(id, null);
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,3 @@
|
||||
/**
|
||||
* infrastructure to define the Elasticsearch mapping for an index.
|
||||
*/
|
||||
@org.springframework.lang.NonNullApi
|
||||
@org.springframework.lang.NonNullFields
|
||||
package org.springframework.data.elasticsearch.repository.support;
|
||||
|
@ -0,0 +1,3 @@
|
||||
@org.springframework.lang.NonNullApi
|
||||
@org.springframework.lang.NonNullFields
|
||||
package org.springframework.data.elasticsearch.support;
|
@ -149,8 +149,7 @@ public class NestedObjectTests {
|
||||
indexOperations.refresh(PersonMultipleLevelNested.class);
|
||||
|
||||
// then
|
||||
GetQuery getQuery = new GetQuery();
|
||||
getQuery.setId("1");
|
||||
GetQuery getQuery = new GetQuery("1");
|
||||
PersonMultipleLevelNested personIndexed = operations.get(getQuery, PersonMultipleLevelNested.class,
|
||||
IndexCoordinates.of("test-index-person-multiple-level-nested").withTypes("user"));
|
||||
assertThat(personIndexed).isNotNull();
|
||||
|
@ -0,0 +1,3 @@
|
||||
@org.springframework.lang.NonNullApi
|
||||
@org.springframework.lang.NonNullFields
|
||||
package org.springframework.data.elasticsearch.client.reactive;
|
@ -0,0 +1,3 @@
|
||||
@org.springframework.lang.NonNullApi
|
||||
@org.springframework.lang.NonNullFields
|
||||
package org.springframework.data.elasticsearch.client.util;
|
@ -28,6 +28,7 @@ import org.springframework.data.elasticsearch.annotations.Document;
|
||||
import org.springframework.data.elasticsearch.config.AbstractElasticsearchConfiguration;
|
||||
import org.springframework.data.elasticsearch.repository.ElasticsearchRepository;
|
||||
import org.springframework.data.elasticsearch.repository.config.EnableElasticsearchRepositories;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit.jupiter.SpringExtension;
|
||||
|
||||
@ -68,7 +69,7 @@ public class ElasticsearchConfigurationTests {
|
||||
@Document(indexName = "test-index-config-abstractelasticsearchconfiguraiton", createIndex = false)
|
||||
static class CreateIndexFalseEntity {
|
||||
|
||||
@Id private String id;
|
||||
@Nullable @Id private String id;
|
||||
}
|
||||
|
||||
interface CreateIndexFalseRepository extends ElasticsearchRepository<CreateIndexFalseEntity, String> {}
|
||||
|
@ -0,0 +1,3 @@
|
||||
@org.springframework.lang.NonNullApi
|
||||
@org.springframework.lang.NonNullFields
|
||||
package org.springframework.data.elasticsearch.config.abstractelasticsearchconfiguration;
|
@ -47,6 +47,7 @@ import org.springframework.data.elasticsearch.repository.ElasticsearchRepository
|
||||
import org.springframework.data.elasticsearch.repository.config.EnableElasticsearchRepositories;
|
||||
import org.springframework.data.elasticsearch.utils.IndexInitializer;
|
||||
import org.springframework.data.repository.Repository;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
|
||||
/**
|
||||
@ -60,7 +61,7 @@ import org.springframework.test.context.ContextConfiguration;
|
||||
@ContextConfiguration(classes = { EnableElasticsearchRepositoriesTests.Config.class })
|
||||
public class EnableElasticsearchRepositoriesTests implements ApplicationContextAware {
|
||||
|
||||
ApplicationContext context;
|
||||
@Nullable ApplicationContext context;
|
||||
|
||||
@Override
|
||||
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
|
||||
|
@ -0,0 +1,3 @@
|
||||
@org.springframework.lang.NonNullApi
|
||||
@org.springframework.lang.NonNullFields
|
||||
package org.springframework.data.elasticsearch.config.notnested;
|
@ -32,6 +32,7 @@ import org.springframework.data.elasticsearch.core.convert.MappingElasticsearchC
|
||||
import org.springframework.data.elasticsearch.core.mapping.SimpleElasticsearchMappingContext;
|
||||
import org.springframework.data.elasticsearch.core.query.Criteria;
|
||||
import org.springframework.data.elasticsearch.core.query.CriteriaQuery;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* Tests for the mapping of {@link CriteriaQuery} by a
|
||||
@ -95,10 +96,10 @@ public class CriteriaQueryMappingTests {
|
||||
}
|
||||
|
||||
static class Person {
|
||||
@Id String id;
|
||||
@Field(name = "first-name") String firstName;
|
||||
@Field(name = "last-name") String lastName;
|
||||
@Field(name = "birth-date", type = FieldType.Date, format = DateFormat.custom,
|
||||
@Nullable @Id String id;
|
||||
@Nullable @Field(name = "first-name") String firstName;
|
||||
@Nullable @Field(name = "last-name") String lastName;
|
||||
@Nullable @Field(name = "birth-date", type = FieldType.Date, format = DateFormat.custom,
|
||||
pattern = "dd.MM.uuuu") LocalDate birthDate;
|
||||
}
|
||||
}
|
||||
|
@ -44,6 +44,7 @@ import org.springframework.data.elasticsearch.repository.query.ElasticsearchQuer
|
||||
import org.springframework.data.projection.SpelAwareProxyProjectionFactory;
|
||||
import org.springframework.data.repository.core.support.DefaultRepositoryMetadata;
|
||||
import org.springframework.data.repository.query.ParametersParameterAccessor;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* Tests for {@link ElasticsearchPartQuery}. Resides in the core package, as we need an instance of the
|
||||
@ -549,11 +550,12 @@ class ElasticsearchPartQueryTests {
|
||||
}
|
||||
|
||||
static class Book {
|
||||
@Id private String id;
|
||||
private String name;
|
||||
private Integer price;
|
||||
@Nullable @Id private String id;
|
||||
@Nullable private String name;
|
||||
@Nullable private Integer price;
|
||||
@Field(type = FieldType.Boolean) private boolean available;
|
||||
|
||||
@Nullable
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
@ -562,6 +564,7 @@ class ElasticsearchPartQueryTests {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
@ -570,6 +573,7 @@ class ElasticsearchPartQueryTests {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Integer getPrice() {
|
||||
return price;
|
||||
}
|
||||
|
@ -76,6 +76,7 @@ import org.springframework.data.elasticsearch.core.geo.GeoPoint;
|
||||
import org.springframework.data.elasticsearch.core.mapping.IndexCoordinates;
|
||||
import org.springframework.data.elasticsearch.core.query.*;
|
||||
import org.springframework.data.util.CloseableIterator;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* Base for testing rest/transport templates. Contains the test common to both implementing classes.
|
||||
@ -199,8 +200,7 @@ public abstract class ElasticsearchTemplateTests {
|
||||
operations.index(indexQuery, index);
|
||||
|
||||
// when
|
||||
GetQuery getQuery = new GetQuery();
|
||||
getQuery.setId(documentId);
|
||||
GetQuery getQuery = new GetQuery(documentId);
|
||||
SampleEntity sampleEntity1 = operations.get(getQuery, SampleEntity.class, index);
|
||||
|
||||
// then
|
||||
@ -415,8 +415,7 @@ public abstract class ElasticsearchTemplateTests {
|
||||
operations.bulkUpdate(queries, index);
|
||||
|
||||
// then
|
||||
GetQuery getQuery = new GetQuery();
|
||||
getQuery.setId(documentId);
|
||||
GetQuery getQuery = new GetQuery(documentId);
|
||||
SampleEntity indexedEntity = operations.get(getQuery, SampleEntity.class, index);
|
||||
assertThat(indexedEntity.getMessage()).isEqualTo(messageAfterUpdate);
|
||||
}
|
||||
@ -1431,8 +1430,7 @@ public abstract class ElasticsearchTemplateTests {
|
||||
operations.update(updateQuery, index);
|
||||
|
||||
// then
|
||||
GetQuery getQuery = new GetQuery();
|
||||
getQuery.setId(documentId);
|
||||
GetQuery getQuery = new GetQuery(documentId);
|
||||
SampleEntity indexedEntity = operations.get(getQuery, SampleEntity.class, index);
|
||||
assertThat(indexedEntity.getMessage()).isEqualTo(messageAfterUpdate);
|
||||
}
|
||||
@ -1497,8 +1495,7 @@ public abstract class ElasticsearchTemplateTests {
|
||||
operations.update(updateQuery, index);
|
||||
|
||||
// then
|
||||
GetQuery getQuery = new GetQuery();
|
||||
getQuery.setId(documentId);
|
||||
GetQuery getQuery = new GetQuery(documentId);
|
||||
SampleEntity indexedEntity = operations.get(getQuery, SampleEntity.class, index);
|
||||
assertThat(indexedEntity.getMessage()).isEqualTo(message);
|
||||
}
|
||||
@ -1741,8 +1738,7 @@ public abstract class ElasticsearchTemplateTests {
|
||||
// then
|
||||
assertThat(sampleEntity.getId()).isEqualTo(documentId);
|
||||
|
||||
GetQuery getQuery = new GetQuery();
|
||||
getQuery.setId(documentId);
|
||||
GetQuery getQuery = new GetQuery(documentId);
|
||||
SampleEntity result = operations.get(getQuery, SampleEntity.class, index);
|
||||
assertThat(result.getId()).isEqualTo(documentId);
|
||||
}
|
||||
@ -3043,8 +3039,10 @@ public abstract class ElasticsearchTemplateTests {
|
||||
|
||||
static class NestedEntity {
|
||||
|
||||
@Nullable
|
||||
@Field(type = Text) private String someField;
|
||||
|
||||
@Nullable
|
||||
public String getSomeField() {
|
||||
return someField;
|
||||
}
|
||||
|
@ -35,14 +35,15 @@ import org.springframework.data.elasticsearch.core.mapping.SimpleElasticsearchMa
|
||||
import org.springframework.data.elasticsearch.core.query.Criteria;
|
||||
import org.springframework.data.elasticsearch.core.query.CriteriaQuery;
|
||||
import org.springframework.data.elasticsearch.core.query.GeoDistanceOrder;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* @author Peter-Josef Meisch
|
||||
*/
|
||||
class RequestFactoryTest {
|
||||
|
||||
private static RequestFactory requestFactory;
|
||||
private static MappingElasticsearchConverter converter;
|
||||
@Nullable private static RequestFactory requestFactory;
|
||||
@Nullable private static MappingElasticsearchConverter converter;
|
||||
|
||||
@BeforeAll
|
||||
|
||||
@ -118,8 +119,8 @@ class RequestFactoryTest {
|
||||
}
|
||||
|
||||
static class Person {
|
||||
@Id String id;
|
||||
@Field(name = "last-name") String lastName;
|
||||
@Field(name = "current-location") GeoPoint location;
|
||||
@Nullable @Id String id;
|
||||
@Nullable @Field(name = "last-name") String lastName;
|
||||
@Nullable @Field(name = "current-location") GeoPoint location;
|
||||
}
|
||||
}
|
||||
|
@ -43,6 +43,7 @@ import org.springframework.data.elasticsearch.core.query.IndexQuery;
|
||||
import org.springframework.data.elasticsearch.junit.jupiter.ElasticsearchRestTemplateConfiguration;
|
||||
import org.springframework.data.elasticsearch.junit.jupiter.SpringIntegrationTest;
|
||||
import org.springframework.data.elasticsearch.utils.IndexInitializer;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
|
||||
/**
|
||||
@ -217,10 +218,11 @@ public class ElasticsearchTemplateCompletionTests {
|
||||
*/
|
||||
static class NonDocumentEntity {
|
||||
|
||||
@Id private String someId;
|
||||
private String someField1;
|
||||
private String someField2;
|
||||
@Nullable @Id private String someId;
|
||||
@Nullable private String someField1;
|
||||
@Nullable private String someField2;
|
||||
|
||||
@Nullable
|
||||
public String getSomeField1() {
|
||||
return someField1;
|
||||
}
|
||||
@ -229,6 +231,7 @@ public class ElasticsearchTemplateCompletionTests {
|
||||
this.someField1 = someField1;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getSomeField2() {
|
||||
return someField2;
|
||||
}
|
||||
@ -244,11 +247,11 @@ public class ElasticsearchTemplateCompletionTests {
|
||||
@Document(indexName = "test-index-core-completion", replicas = 0, refreshInterval = "-1")
|
||||
static class CompletionEntity {
|
||||
|
||||
@Id private String id;
|
||||
@Nullable @Id private String id;
|
||||
|
||||
private String name;
|
||||
@Nullable private String name;
|
||||
|
||||
@CompletionField(maxInputLength = 100) private Completion suggest;
|
||||
@Nullable @CompletionField(maxInputLength = 100) private Completion suggest;
|
||||
|
||||
private CompletionEntity() {}
|
||||
|
||||
@ -256,6 +259,7 @@ public class ElasticsearchTemplateCompletionTests {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
@ -264,6 +268,7 @@ public class ElasticsearchTemplateCompletionTests {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
@ -272,6 +277,7 @@ public class ElasticsearchTemplateCompletionTests {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Completion getSuggest() {
|
||||
return suggest;
|
||||
}
|
||||
@ -327,10 +333,9 @@ public class ElasticsearchTemplateCompletionTests {
|
||||
@Document(indexName = "test-index-annotated-completion", replicas = 0, refreshInterval = "-1")
|
||||
static class AnnotatedCompletionEntity {
|
||||
|
||||
@Id private String id;
|
||||
private String name;
|
||||
|
||||
@CompletionField(maxInputLength = 100) private Completion suggest;
|
||||
@Nullable @Id private String id;
|
||||
@Nullable private String name;
|
||||
@Nullable @CompletionField(maxInputLength = 100) private Completion suggest;
|
||||
|
||||
private AnnotatedCompletionEntity() {}
|
||||
|
||||
@ -338,6 +343,7 @@ public class ElasticsearchTemplateCompletionTests {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
@ -346,6 +352,7 @@ public class ElasticsearchTemplateCompletionTests {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
@ -354,6 +361,7 @@ public class ElasticsearchTemplateCompletionTests {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Completion getSuggest() {
|
||||
return suggest;
|
||||
}
|
||||
|
@ -51,6 +51,7 @@ import org.springframework.data.elasticsearch.core.query.IndexQuery;
|
||||
import org.springframework.data.elasticsearch.junit.jupiter.ElasticsearchRestTemplateConfiguration;
|
||||
import org.springframework.data.elasticsearch.junit.jupiter.SpringIntegrationTest;
|
||||
import org.springframework.data.elasticsearch.utils.IndexInitializer;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
|
||||
/**
|
||||
@ -216,10 +217,11 @@ public class ElasticsearchTemplateCompletionWithContextsTests {
|
||||
*/
|
||||
static class NonDocumentEntity {
|
||||
|
||||
@Id private String someId;
|
||||
private String someField1;
|
||||
private String someField2;
|
||||
@Nullable @Id private String someId;
|
||||
@Nullable private String someField1;
|
||||
@Nullable private String someField2;
|
||||
|
||||
@Nullable
|
||||
public String getSomeField1() {
|
||||
return someField1;
|
||||
}
|
||||
@ -228,6 +230,7 @@ public class ElasticsearchTemplateCompletionWithContextsTests {
|
||||
this.someField1 = someField1;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getSomeField2() {
|
||||
return someField2;
|
||||
}
|
||||
@ -245,10 +248,10 @@ public class ElasticsearchTemplateCompletionWithContextsTests {
|
||||
static class ContextCompletionEntity {
|
||||
|
||||
public static final String LANGUAGE_CATEGORY = "language";
|
||||
@Id private String id;
|
||||
private String name;
|
||||
@Nullable @Id private String id;
|
||||
@Nullable private String name;
|
||||
|
||||
@CompletionField(maxInputLength = 100, contexts = {
|
||||
@Nullable @CompletionField(maxInputLength = 100, contexts = {
|
||||
@CompletionContext(name = LANGUAGE_CATEGORY, type = ContextMapping.Type.CATEGORY) }) private Completion suggest;
|
||||
|
||||
private ContextCompletionEntity() {}
|
||||
@ -257,6 +260,7 @@ public class ElasticsearchTemplateCompletionWithContextsTests {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
@ -265,6 +269,7 @@ public class ElasticsearchTemplateCompletionWithContextsTests {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
@ -273,6 +278,7 @@ public class ElasticsearchTemplateCompletionWithContextsTests {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Completion getSuggest() {
|
||||
return suggest;
|
||||
}
|
||||
|
@ -26,7 +26,6 @@ import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.time.LocalDate;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
@ -61,6 +60,7 @@ import org.springframework.data.geo.Circle;
|
||||
import org.springframework.data.geo.Point;
|
||||
import org.springframework.data.geo.Polygon;
|
||||
import org.springframework.data.mapping.context.MappingContext;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* Unit tests for {@link MappingElasticsearchConverter}.
|
||||
@ -629,10 +629,10 @@ public class MappingElasticsearchConverterUnitTests {
|
||||
|
||||
public static class Sample {
|
||||
|
||||
public @ReadOnlyProperty String readOnly;
|
||||
public @Transient String annotatedTransientProperty;
|
||||
public transient String javaTransientProperty;
|
||||
public String property;
|
||||
@Nullable public @ReadOnlyProperty String readOnly;
|
||||
@Nullable public @Transient String annotatedTransientProperty;
|
||||
@Nullable public transient String javaTransientProperty;
|
||||
@Nullable public String property;
|
||||
}
|
||||
|
||||
@Data
|
||||
|
@ -65,6 +65,7 @@ import org.springframework.data.geo.Box;
|
||||
import org.springframework.data.geo.Circle;
|
||||
import org.springframework.data.geo.Point;
|
||||
import org.springframework.data.geo.Polygon;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
|
||||
/**
|
||||
@ -562,59 +563,59 @@ public class MappingBuilderTests extends MappingContextBaseTests {
|
||||
|
||||
@Document(indexName = "fieldname-index")
|
||||
static class IdEntity {
|
||||
@Id @Field("id-property") private String id;
|
||||
@Nullable @Id @Field("id-property") private String id;
|
||||
}
|
||||
|
||||
@Document(indexName = "fieldname-index")
|
||||
static class TextEntity {
|
||||
|
||||
@Id @Field("id-property") private String id;
|
||||
@Nullable @Id @Field("id-property") private String id;
|
||||
|
||||
@Field(name = "text-property", type = FieldType.Text) //
|
||||
private String textProperty;
|
||||
@Nullable private String textProperty;
|
||||
}
|
||||
|
||||
@Document(indexName = "fieldname-index")
|
||||
static class MappingEntity {
|
||||
|
||||
@Id @Field("id-property") private String id;
|
||||
@Nullable @Id @Field("id-property") private String id;
|
||||
|
||||
@Field("mapping-property") @Mapping(mappingPath = "/mappings/test-field-analyzed-mappings.json") //
|
||||
private byte[] mappingProperty;
|
||||
@Nullable private byte[] mappingProperty;
|
||||
}
|
||||
|
||||
@Document(indexName = "fieldname-index")
|
||||
static class GeoPointEntity {
|
||||
|
||||
@Id @Field("id-property") private String id;
|
||||
@Nullable @Id @Field("id-property") private String id;
|
||||
|
||||
@Field("geopoint-property") private GeoPoint geoPoint;
|
||||
@Nullable @Field("geopoint-property") private GeoPoint geoPoint;
|
||||
}
|
||||
|
||||
@Document(indexName = "fieldname-index")
|
||||
static class CircularEntity {
|
||||
|
||||
@Id @Field("id-property") private String id;
|
||||
@Nullable @Id @Field("id-property") private String id;
|
||||
|
||||
@Field(name = "circular-property", type = FieldType.Object, ignoreFields = { "circular-property" }) //
|
||||
@Nullable @Field(name = "circular-property", type = FieldType.Object, ignoreFields = { "circular-property" }) //
|
||||
private CircularEntity circularProperty;
|
||||
}
|
||||
|
||||
@Document(indexName = "fieldname-index")
|
||||
static class CompletionEntity {
|
||||
|
||||
@Id @Field("id-property") private String id;
|
||||
@Nullable @Id @Field("id-property") private String id;
|
||||
|
||||
@Field("completion-property") @CompletionField(maxInputLength = 100) //
|
||||
@Nullable @Field("completion-property") @CompletionField(maxInputLength = 100) //
|
||||
private Completion suggest;
|
||||
}
|
||||
|
||||
@Document(indexName = "fieldname-index")
|
||||
static class MultiFieldEntity {
|
||||
|
||||
@Id @Field("id-property") private String id;
|
||||
@Nullable @Id @Field("id-property") private String id;
|
||||
|
||||
@Field("multifield-property") //
|
||||
@Nullable @Field("multifield-property") //
|
||||
@MultiField(mainField = @Field(type = FieldType.Text, analyzer = "whitespace"), otherFields = {
|
||||
@InnerField(suffix = "prefix", type = FieldType.Text, analyzer = "stop", searchAnalyzer = "standard") }) //
|
||||
private String description;
|
||||
@ -629,9 +630,9 @@ public class MappingBuilderTests extends MappingContextBaseTests {
|
||||
@Document(indexName = "test-index-minimal")
|
||||
static class MinimalChildEntity {
|
||||
|
||||
@Id private String id;
|
||||
@Nullable @Id private String id;
|
||||
|
||||
@Parent(type = "parentType") private String parentId;
|
||||
@Nullable @Parent(type = "parentType") private String parentId;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -663,8 +664,9 @@ public class MappingBuilderTests extends MappingContextBaseTests {
|
||||
@Document(indexName = "test-index-simple-recursive-mapping-builder", replicas = 0, refreshInterval = "-1")
|
||||
static class SimpleRecursiveEntity {
|
||||
|
||||
@Id private String id;
|
||||
@Field(type = FieldType.Object, ignoreFields = { "circularObject" }) private SimpleRecursiveEntity circularObject;
|
||||
@Nullable @Id private String id;
|
||||
@Nullable @Field(type = FieldType.Object,
|
||||
ignoreFields = { "circularObject" }) private SimpleRecursiveEntity circularObject;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -713,9 +715,10 @@ public class MappingBuilderTests extends MappingContextBaseTests {
|
||||
*/
|
||||
static class Author {
|
||||
|
||||
private String id;
|
||||
private String name;
|
||||
@Nullable private String id;
|
||||
@Nullable private String name;
|
||||
|
||||
@Nullable
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
@ -724,6 +727,7 @@ public class MappingBuilderTests extends MappingContextBaseTests {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
@ -739,8 +743,9 @@ public class MappingBuilderTests extends MappingContextBaseTests {
|
||||
@Document(indexName = "test-index-sample-inherited-mapping-builder", replicas = 0, refreshInterval = "-1")
|
||||
static class SampleInheritedEntity extends AbstractInheritedEntity {
|
||||
|
||||
@Field(type = Text, index = false, store = true, analyzer = "standard") private String message;
|
||||
@Nullable @Field(type = Text, index = false, store = true, analyzer = "standard") private String message;
|
||||
|
||||
@Nullable
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
@ -808,10 +813,11 @@ public class MappingBuilderTests extends MappingContextBaseTests {
|
||||
*/
|
||||
static class AbstractInheritedEntity {
|
||||
|
||||
@Id private String id;
|
||||
@Nullable @Id private String id;
|
||||
|
||||
@Field(type = FieldType.Date, index = false) private Date createdDate;
|
||||
@Nullable @Field(type = FieldType.Date, index = false) private Date createdDate;
|
||||
|
||||
@Nullable
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
@ -820,6 +826,7 @@ public class MappingBuilderTests extends MappingContextBaseTests {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Date getCreatedDate() {
|
||||
return createdDate;
|
||||
}
|
||||
@ -835,12 +842,13 @@ public class MappingBuilderTests extends MappingContextBaseTests {
|
||||
@Document(indexName = "test-index-recursive-mapping-mapping-builder", replicas = 0, refreshInterval = "-1")
|
||||
static class SampleTransientEntity {
|
||||
|
||||
@Id private String id;
|
||||
@Nullable @Id private String id;
|
||||
|
||||
@Field(type = Text, index = false, store = true, analyzer = "standard") private String message;
|
||||
@Nullable @Field(type = Text, index = false, store = true, analyzer = "standard") private String message;
|
||||
|
||||
@Transient private SampleTransientEntity.NestedEntity nested;
|
||||
@Nullable @Transient private SampleTransientEntity.NestedEntity nested;
|
||||
|
||||
@Nullable
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
@ -849,6 +857,7 @@ public class MappingBuilderTests extends MappingContextBaseTests {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
@ -860,7 +869,7 @@ public class MappingBuilderTests extends MappingContextBaseTests {
|
||||
static class NestedEntity {
|
||||
|
||||
@Field private static SampleTransientEntity.NestedEntity someField = new SampleTransientEntity.NestedEntity();
|
||||
@Field private Boolean something;
|
||||
@Nullable @Field private Boolean something;
|
||||
|
||||
public SampleTransientEntity.NestedEntity getSomeField() {
|
||||
return someField;
|
||||
@ -870,6 +879,7 @@ public class MappingBuilderTests extends MappingContextBaseTests {
|
||||
NestedEntity.someField = someField;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Boolean getSomething() {
|
||||
return something;
|
||||
}
|
||||
@ -913,7 +923,7 @@ public class MappingBuilderTests extends MappingContextBaseTests {
|
||||
*/
|
||||
@Document(indexName = "test-index-user-mapping-builder")
|
||||
static class User {
|
||||
@Id private String id;
|
||||
@Nullable @Id private String id;
|
||||
|
||||
@Field(type = FieldType.Nested, ignoreFields = { "users" }) private Set<Group> groups = new HashSet<>();
|
||||
}
|
||||
@ -924,54 +934,55 @@ public class MappingBuilderTests extends MappingContextBaseTests {
|
||||
@Document(indexName = "test-index-group-mapping-builder")
|
||||
static class Group {
|
||||
|
||||
@Id String id;
|
||||
@Nullable @Id String id;
|
||||
|
||||
@Field(type = FieldType.Nested, ignoreFields = { "groups" }) private Set<User> users = new HashSet<>();
|
||||
}
|
||||
|
||||
@Document(indexName = "test-index-field-mapping-parameters")
|
||||
static class FieldMappingParameters {
|
||||
@Field private String indexTrue;
|
||||
@Field(index = false) private String indexFalse;
|
||||
@Field(store = true) private String storeTrue;
|
||||
@Field private String storeFalse;
|
||||
@Field private String coerceTrue;
|
||||
@Field(coerce = false) private String coerceFalse;
|
||||
@Field(fielddata = true) private String fielddataTrue;
|
||||
@Field private String fielddataFalse;
|
||||
@Field(copyTo = { "foo", "bar" }) private String copyTo;
|
||||
@Field(ignoreAbove = 42) private String ignoreAbove;
|
||||
@Field(type = FieldType.Integer) private String type;
|
||||
@Field(type = FieldType.Date, format = DateFormat.custom, pattern = "YYYYMMDD") private LocalDate date;
|
||||
@Field(analyzer = "ana", searchAnalyzer = "sana", normalizer = "norma") private String analyzers;
|
||||
@Field(type = Keyword) private String docValuesTrue;
|
||||
@Field(type = Keyword, docValues = false) private String docValuesFalse;
|
||||
@Field(ignoreMalformed = true) private String ignoreMalformedTrue;
|
||||
@Field() private String ignoreMalformedFalse;
|
||||
@Field(indexOptions = IndexOptions.none) private String indexOptionsNone;
|
||||
@Field(indexOptions = IndexOptions.positions) private String indexOptionsPositions;
|
||||
@Field(indexPhrases = true) private String indexPhrasesTrue;
|
||||
@Field() private String indexPhrasesFalse;
|
||||
@Field(indexPrefixes = @IndexPrefixes) private String defaultIndexPrefixes;
|
||||
@Field(indexPrefixes = @IndexPrefixes(minChars = 1, maxChars = 10)) private String customIndexPrefixes;
|
||||
@Field private String normsTrue;
|
||||
@Field(norms = false) private String normsFalse;
|
||||
@Field private String nullValueNotSet;
|
||||
@Field(nullValue = "NULLNULL") private String nullValueSet;
|
||||
@Field(positionIncrementGap = 42) private String positionIncrementGap;
|
||||
@Field private String similarityDefault;
|
||||
@Field(similarity = Similarity.Boolean) private String similarityBoolean;
|
||||
@Field private String termVectorDefault;
|
||||
@Field(termVector = TermVector.with_offsets) private String termVectorWithOffsets;
|
||||
@Field(type = FieldType.Scaled_Float, scalingFactor = 100.0) Double scaledFloat;
|
||||
@Nullable @Field private String indexTrue;
|
||||
@Nullable @Field(index = false) private String indexFalse;
|
||||
@Nullable @Field(store = true) private String storeTrue;
|
||||
@Nullable @Field private String storeFalse;
|
||||
@Nullable @Field private String coerceTrue;
|
||||
@Nullable @Field(coerce = false) private String coerceFalse;
|
||||
@Nullable @Field(fielddata = true) private String fielddataTrue;
|
||||
@Nullable @Field private String fielddataFalse;
|
||||
@Nullable @Field(copyTo = { "foo", "bar" }) private String copyTo;
|
||||
@Nullable @Field(ignoreAbove = 42) private String ignoreAbove;
|
||||
@Nullable @Field(type = FieldType.Integer) private String type;
|
||||
@Nullable @Field(type = FieldType.Date, format = DateFormat.custom, pattern = "YYYYMMDD") private LocalDate date;
|
||||
@Nullable @Field(analyzer = "ana", searchAnalyzer = "sana", normalizer = "norma") private String analyzers;
|
||||
@Nullable @Field(type = Keyword) private String docValuesTrue;
|
||||
@Nullable @Field(type = Keyword, docValues = false) private String docValuesFalse;
|
||||
@Nullable @Field(ignoreMalformed = true) private String ignoreMalformedTrue;
|
||||
@Nullable @Field() private String ignoreMalformedFalse;
|
||||
@Nullable @Field(indexOptions = IndexOptions.none) private String indexOptionsNone;
|
||||
@Nullable @Field(indexOptions = IndexOptions.positions) private String indexOptionsPositions;
|
||||
@Nullable @Field(indexPhrases = true) private String indexPhrasesTrue;
|
||||
@Nullable @Field() private String indexPhrasesFalse;
|
||||
@Nullable @Field(indexPrefixes = @IndexPrefixes) private String defaultIndexPrefixes;
|
||||
@Nullable @Field(indexPrefixes = @IndexPrefixes(minChars = 1, maxChars = 10)) private String customIndexPrefixes;
|
||||
@Nullable @Field private String normsTrue;
|
||||
@Nullable @Field(norms = false) private String normsFalse;
|
||||
@Nullable @Field private String nullValueNotSet;
|
||||
@Nullable @Field(nullValue = "NULLNULL") private String nullValueSet;
|
||||
@Nullable @Field(positionIncrementGap = 42) private String positionIncrementGap;
|
||||
@Nullable @Field private String similarityDefault;
|
||||
@Nullable @Field(similarity = Similarity.Boolean) private String similarityBoolean;
|
||||
@Nullable @Field private String termVectorDefault;
|
||||
@Nullable @Field(termVector = TermVector.with_offsets) private String termVectorWithOffsets;
|
||||
@Nullable @Field(type = FieldType.Scaled_Float, scalingFactor = 100.0) Double scaledFloat;
|
||||
}
|
||||
|
||||
@Document(indexName = "test-index-configure-dynamic-mapping")
|
||||
@DynamicMapping(DynamicMappingValue.False)
|
||||
static class ConfigureDynamicMappingEntity {
|
||||
|
||||
@DynamicMapping(DynamicMappingValue.Strict) @Field(type = FieldType.Object) private Author author;
|
||||
@Nullable @DynamicMapping(DynamicMappingValue.Strict) @Field(type = FieldType.Object) private Author author;
|
||||
|
||||
@Nullable
|
||||
public Author getAuthor() {
|
||||
return author;
|
||||
}
|
||||
|
@ -10,6 +10,7 @@ import org.springframework.data.elasticsearch.annotations.FieldType;
|
||||
import org.springframework.data.elasticsearch.annotations.InnerField;
|
||||
import org.springframework.data.elasticsearch.annotations.Score;
|
||||
import org.springframework.data.elasticsearch.core.mapping.ElasticsearchPersistentEntity;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* @author Peter-Josef Meisch
|
||||
@ -59,10 +60,10 @@ public class MappingParametersTest extends MappingContextBaseTests {
|
||||
}
|
||||
|
||||
static class AnnotatedClass {
|
||||
@Field private String field;
|
||||
@InnerField(suffix = "test", type = FieldType.Text) private String innerField;
|
||||
@Nullable @Field private String field;
|
||||
@Nullable @InnerField(suffix = "test", type = FieldType.Text) private String innerField;
|
||||
@Score private float score;
|
||||
@Field(type = FieldType.Text, docValues = false) private String docValuesText;
|
||||
@Field(type = FieldType.Nested, docValues = false) private String docValuesNested;
|
||||
@Nullable @Field(type = FieldType.Text, docValues = false) private String docValuesText;
|
||||
@Nullable @Field(type = FieldType.Nested, docValues = false) private String docValuesNested;
|
||||
}
|
||||
}
|
||||
|
@ -17,7 +17,6 @@ package org.springframework.data.elasticsearch.core.index;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@ -29,6 +28,7 @@ import org.springframework.data.elasticsearch.annotations.Field;
|
||||
import org.springframework.data.elasticsearch.annotations.FieldType;
|
||||
import org.springframework.data.elasticsearch.junit.jupiter.ElasticsearchTemplateConfiguration;
|
||||
import org.springframework.data.elasticsearch.junit.jupiter.SpringIntegrationTest;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
|
||||
/**
|
||||
@ -46,8 +46,7 @@ public class SimpleDynamicTemplatesMappingTests extends MappingContextBaseTests
|
||||
|
||||
String mapping = getMappingBuilder().buildPropertyMapping(SampleDynamicTemplatesEntity.class);
|
||||
|
||||
String EXPECTED_MAPPING_ONE = "{\"dynamic_templates\":"
|
||||
+ "[{\"with_custom_analyzer\":{"
|
||||
String EXPECTED_MAPPING_ONE = "{\"dynamic_templates\":" + "[{\"with_custom_analyzer\":{"
|
||||
+ "\"mapping\":{\"type\":\"string\",\"analyzer\":\"standard_lowercase_asciifolding\"},"
|
||||
+ "\"path_match\":\"names.*\"}}]," + "\"properties\":{\"names\":{\"type\":\"object\"}}}";
|
||||
|
||||
@ -58,8 +57,7 @@ public class SimpleDynamicTemplatesMappingTests extends MappingContextBaseTests
|
||||
public void testCorrectDynamicTemplatesMappingsTwo() {
|
||||
|
||||
String mapping = getMappingBuilder().buildPropertyMapping(SampleDynamicTemplatesEntityTwo.class);
|
||||
String EXPECTED_MAPPING_TWO = "{\"dynamic_templates\":"
|
||||
+ "[{\"with_custom_analyzer\":{"
|
||||
String EXPECTED_MAPPING_TWO = "{\"dynamic_templates\":" + "[{\"with_custom_analyzer\":{"
|
||||
+ "\"mapping\":{\"type\":\"string\",\"analyzer\":\"standard_lowercase_asciifolding\"},"
|
||||
+ "\"path_match\":\"names.*\"}}," + "{\"participantA1_with_custom_analyzer\":{"
|
||||
+ "\"mapping\":{\"type\":\"string\",\"analyzer\":\"standard_lowercase_asciifolding\"},"
|
||||
@ -71,27 +69,25 @@ public class SimpleDynamicTemplatesMappingTests extends MappingContextBaseTests
|
||||
/**
|
||||
* @author Petr Kukral
|
||||
*/
|
||||
@Document(indexName = "test-dynamictemplates", indexStoreType = "memory",
|
||||
replicas = 0, refreshInterval = "-1")
|
||||
@Document(indexName = "test-dynamictemplates", indexStoreType = "memory", replicas = 0, refreshInterval = "-1")
|
||||
@DynamicTemplates(mappingPath = "/mappings/test-dynamic_templates_mappings.json")
|
||||
static class SampleDynamicTemplatesEntity {
|
||||
|
||||
@Id private String id;
|
||||
@Nullable @Id private String id;
|
||||
|
||||
@Field(type = FieldType.Object) private Map<String, String> names = new HashMap<>();
|
||||
@Nullable @Field(type = FieldType.Object) private Map<String, String> names = new HashMap<>();
|
||||
}
|
||||
|
||||
/**
|
||||
* @author Petr Kukral
|
||||
*/
|
||||
@Document(indexName = "test-dynamictemplates", indexStoreType = "memory",
|
||||
replicas = 0, refreshInterval = "-1")
|
||||
@Document(indexName = "test-dynamictemplates", indexStoreType = "memory", replicas = 0, refreshInterval = "-1")
|
||||
@DynamicTemplates(mappingPath = "/mappings/test-dynamic_templates_mappings_two.json")
|
||||
static class SampleDynamicTemplatesEntityTwo {
|
||||
|
||||
@Id private String id;
|
||||
@Nullable @Id private String id;
|
||||
|
||||
@Field(type = FieldType.Object) private Map<String, String> names = new HashMap<>();
|
||||
@Nullable @Field(type = FieldType.Object) private Map<String, String> names = new HashMap<>();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -27,6 +27,7 @@ import org.springframework.data.mapping.model.Property;
|
||||
import org.springframework.data.mapping.model.SimpleTypeHolder;
|
||||
import org.springframework.data.util.ClassTypeInformation;
|
||||
import org.springframework.data.util.TypeInformation;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.ReflectionUtils;
|
||||
|
||||
/**
|
||||
@ -105,8 +106,9 @@ public class SimpleElasticsearchPersistentEntityTests {
|
||||
|
||||
private class EntityWithWrongVersionType {
|
||||
|
||||
@Version private String version;
|
||||
@Nullable @Version private String version;
|
||||
|
||||
@Nullable
|
||||
public String getVersion() {
|
||||
return version;
|
||||
}
|
||||
@ -118,9 +120,10 @@ public class SimpleElasticsearchPersistentEntityTests {
|
||||
|
||||
private class EntityWithMultipleVersionField {
|
||||
|
||||
@Version private Long version1;
|
||||
@Version private Long version2;
|
||||
@Nullable @Version private Long version1;
|
||||
@Nullable @Version private Long version2;
|
||||
|
||||
@Nullable
|
||||
public Long getVersion1() {
|
||||
return version1;
|
||||
}
|
||||
@ -129,6 +132,7 @@ public class SimpleElasticsearchPersistentEntityTests {
|
||||
this.version1 = version1;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Long getVersion2() {
|
||||
return version2;
|
||||
}
|
||||
@ -147,7 +151,7 @@ public class SimpleElasticsearchPersistentEntityTests {
|
||||
}
|
||||
|
||||
private static class FieldNameEntity {
|
||||
@Id private String id;
|
||||
@Field(name = "renamed-field") private String renamedField;
|
||||
@Nullable @Id private String id;
|
||||
@Nullable @Field(name = "renamed-field") private String renamedField;
|
||||
}
|
||||
}
|
||||
|
@ -27,6 +27,7 @@ import org.springframework.data.elasticsearch.annotations.Field;
|
||||
import org.springframework.data.elasticsearch.annotations.FieldType;
|
||||
import org.springframework.data.elasticsearch.annotations.Score;
|
||||
import org.springframework.data.mapping.MappingException;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* Unit tests for {@link SimpleElasticsearchPersistentProperty}.
|
||||
@ -110,20 +111,20 @@ public class SimpleElasticsearchPersistentPropertyUnitTests {
|
||||
}
|
||||
|
||||
static class InvalidScoreProperty {
|
||||
@Score String scoreProperty;
|
||||
@Nullable @Score String scoreProperty;
|
||||
}
|
||||
|
||||
static class FieldNameProperty {
|
||||
@Field(name = "by-name") String fieldProperty;
|
||||
@Nullable @Field(name = "by-name") String fieldProperty;
|
||||
}
|
||||
|
||||
static class FieldValueProperty {
|
||||
@Field(value = "by-value") String fieldProperty;
|
||||
@Nullable @Field(value = "by-value") String fieldProperty;
|
||||
}
|
||||
|
||||
static class DatesProperty {
|
||||
@Field(type = FieldType.Date, format = DateFormat.basic_date) Date date;
|
||||
@Field(type = FieldType.Date, format = DateFormat.custom, pattern = "dd.MM.uuuu") LocalDate localDate;
|
||||
@Field(type = FieldType.Date, format = DateFormat.basic_date_time) LocalDateTime localDateTime;
|
||||
@Nullable @Field(type = FieldType.Date, format = DateFormat.basic_date) Date date;
|
||||
@Nullable @Field(type = FieldType.Date, format = DateFormat.custom, pattern = "dd.MM.uuuu") LocalDate localDate;
|
||||
@Nullable @Field(type = FieldType.Date, format = DateFormat.basic_date_time) LocalDateTime localDateTime;
|
||||
}
|
||||
}
|
||||
|
@ -30,6 +30,7 @@ import org.springframework.data.elasticsearch.annotations.HighlightField;
|
||||
import org.springframework.data.elasticsearch.annotations.HighlightParameters;
|
||||
import org.springframework.data.elasticsearch.core.ResourceUtil;
|
||||
import org.springframework.data.elasticsearch.core.mapping.SimpleElasticsearchMappingContext;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
@ -117,10 +118,11 @@ class HighlightQueryBuilderTests {
|
||||
|
||||
@Document(indexName = "dont-care")
|
||||
private static class HighlightEntity {
|
||||
@Id private String id;
|
||||
@Field(name = "some-field") private String someField;
|
||||
@Field(name = "other-field") private String otherField;
|
||||
@Nullable @Id private String id;
|
||||
@Nullable @Field(name = "some-field") private String someField;
|
||||
@Nullable @Field(name = "other-field") private String otherField;
|
||||
|
||||
@Nullable
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
@ -129,6 +131,7 @@ class HighlightQueryBuilderTests {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getSomeField() {
|
||||
return someField;
|
||||
}
|
||||
|
@ -17,17 +17,21 @@ package org.springframework.data.elasticsearch.repositories.cdi;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* @author Mohsin Husen
|
||||
* @author Oliver Gierke
|
||||
* @author Mark Paluch
|
||||
* @author Peter-Josef Meisch
|
||||
*/
|
||||
class CdiRepositoryClient {
|
||||
|
||||
private CdiProductRepository repository;
|
||||
private SamplePersonRepository samplePersonRepository;
|
||||
private QualifiedProductRepository qualifiedProductRepository;
|
||||
@Nullable private CdiProductRepository repository;
|
||||
@Nullable private SamplePersonRepository samplePersonRepository;
|
||||
@Nullable private QualifiedProductRepository qualifiedProductRepository;
|
||||
|
||||
@Nullable
|
||||
public CdiProductRepository getRepository() {
|
||||
return repository;
|
||||
}
|
||||
@ -37,6 +41,7 @@ class CdiRepositoryClient {
|
||||
this.repository = repository;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public SamplePersonRepository getSamplePersonRepository() {
|
||||
return samplePersonRepository;
|
||||
}
|
||||
@ -46,6 +51,7 @@ class CdiRepositoryClient {
|
||||
this.samplePersonRepository = samplePersonRepository;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public QualifiedProductRepository getQualifiedProductRepository() {
|
||||
return qualifiedProductRepository;
|
||||
}
|
||||
|
@ -41,6 +41,7 @@ import org.springframework.data.elasticsearch.annotations.Field;
|
||||
import org.springframework.data.elasticsearch.annotations.FieldType;
|
||||
import org.springframework.data.elasticsearch.annotations.InnerField;
|
||||
import org.springframework.data.elasticsearch.annotations.MultiField;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* @author Mohsin Husen
|
||||
@ -50,7 +51,7 @@ import org.springframework.data.elasticsearch.annotations.MultiField;
|
||||
*/
|
||||
public class CdiRepositoryTests {
|
||||
|
||||
private static CdiTestContainer cdiContainer;
|
||||
@Nullable private static CdiTestContainer cdiContainer;
|
||||
private CdiProductRepository repository;
|
||||
private SamplePersonRepository personRepository;
|
||||
private QualifiedProductRepository qualifiedProductRepository;
|
||||
@ -158,8 +159,7 @@ public class CdiRepositoryTests {
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
@Document(indexName = "test-index-product-cdi-repository", replicas = 0,
|
||||
refreshInterval = "-1")
|
||||
@Document(indexName = "test-index-product-cdi-repository", replicas = 0, refreshInterval = "-1")
|
||||
static class Product {
|
||||
|
||||
@Id private String id;
|
||||
@ -188,8 +188,7 @@ public class CdiRepositoryTests {
|
||||
}
|
||||
|
||||
@Data
|
||||
@Document(indexName = "test-index-person-cdi-repository", replicas = 0,
|
||||
refreshInterval = "-1")
|
||||
@Document(indexName = "test-index-person-cdi-repository", replicas = 0, refreshInterval = "-1")
|
||||
static class Person {
|
||||
|
||||
@Id private String id;
|
||||
@ -206,8 +205,7 @@ public class CdiRepositoryTests {
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
@Document(indexName = "test-index-book-cdi-repository", replicas = 0,
|
||||
refreshInterval = "-1")
|
||||
@Document(indexName = "test-index-book-cdi-repository", replicas = 0, refreshInterval = "-1")
|
||||
static class Book {
|
||||
|
||||
@Id private String id;
|
||||
|
@ -0,0 +1,3 @@
|
||||
@org.springframework.lang.NonNullApi
|
||||
@org.springframework.lang.NonNullFields
|
||||
package org.springframework.data.elasticsearch.repositories.cdi;
|
@ -50,6 +50,7 @@ import org.springframework.data.elasticsearch.core.query.StringQuery;
|
||||
import org.springframework.data.projection.SpelAwareProxyProjectionFactory;
|
||||
import org.springframework.data.repository.Repository;
|
||||
import org.springframework.data.repository.core.support.DefaultRepositoryMetadata;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* @author Christoph Strobl
|
||||
@ -123,18 +124,15 @@ public class ElasticsearchStringQueryUnitTests {
|
||||
* @author Artur Konczak
|
||||
*/
|
||||
|
||||
@Document(indexName = "test-index-person-query-unittest", replicas = 0,
|
||||
refreshInterval = "-1")
|
||||
@Document(indexName = "test-index-person-query-unittest", replicas = 0, refreshInterval = "-1")
|
||||
static class Person {
|
||||
|
||||
@Id private String id;
|
||||
|
||||
private String name;
|
||||
|
||||
@Field(type = FieldType.Nested) private List<Car> car;
|
||||
|
||||
@Field(type = FieldType.Nested, includeInParent = true) private List<Book> books;
|
||||
@Nullable @Id private String id;
|
||||
@Nullable private String name;
|
||||
@Nullable @Field(type = FieldType.Nested) private List<Car> car;
|
||||
@Nullable @Field(type = FieldType.Nested, includeInParent = true) private List<Book> books;
|
||||
|
||||
@Nullable
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
@ -143,6 +141,7 @@ public class ElasticsearchStringQueryUnitTests {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
@ -151,6 +150,7 @@ public class ElasticsearchStringQueryUnitTests {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public List<Car> getCar() {
|
||||
return car;
|
||||
}
|
||||
@ -159,6 +159,7 @@ public class ElasticsearchStringQueryUnitTests {
|
||||
this.car = car;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public List<Book> getBooks() {
|
||||
return books;
|
||||
}
|
||||
@ -178,8 +179,7 @@ public class ElasticsearchStringQueryUnitTests {
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
@Document(indexName = "test-index-book-query-unittest", replicas = 0,
|
||||
refreshInterval = "-1")
|
||||
@Document(indexName = "test-index-book-query-unittest", replicas = 0, refreshInterval = "-1")
|
||||
static class Book {
|
||||
|
||||
@Id private String id;
|
||||
@ -229,9 +229,10 @@ public class ElasticsearchStringQueryUnitTests {
|
||||
*/
|
||||
static class Author {
|
||||
|
||||
private String id;
|
||||
private String name;
|
||||
@Nullable private String id;
|
||||
@Nullable private String name;
|
||||
|
||||
@Nullable
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
@ -240,6 +241,7 @@ public class ElasticsearchStringQueryUnitTests {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
@ -48,6 +48,7 @@ import org.springframework.data.projection.ProjectionFactory;
|
||||
import org.springframework.data.projection.SpelAwareProxyProjectionFactory;
|
||||
import org.springframework.data.repository.Repository;
|
||||
import org.springframework.data.repository.core.support.DefaultRepositoryMetadata;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* @author Christoph Strobl
|
||||
@ -152,14 +153,15 @@ public class ReactiveElasticsearchQueryMethodUnitTests {
|
||||
@Document(indexName = INDEX_NAME, replicas = 0, refreshInterval = "-1")
|
||||
static class Person {
|
||||
|
||||
@Id private String id;
|
||||
@Nullable @Id private String id;
|
||||
|
||||
private String name;
|
||||
@Nullable private String name;
|
||||
|
||||
@Field(type = FieldType.Nested) private List<Car> car;
|
||||
@Nullable @Field(type = FieldType.Nested) private List<Car> car;
|
||||
|
||||
@Field(type = FieldType.Nested, includeInParent = true) private List<Book> books;
|
||||
@Nullable @Field(type = FieldType.Nested, includeInParent = true) private List<Book> books;
|
||||
|
||||
@Nullable
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
@ -168,6 +170,7 @@ public class ReactiveElasticsearchQueryMethodUnitTests {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
@ -176,6 +179,7 @@ public class ReactiveElasticsearchQueryMethodUnitTests {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public List<Car> getCar() {
|
||||
return car;
|
||||
}
|
||||
@ -184,6 +188,7 @@ public class ReactiveElasticsearchQueryMethodUnitTests {
|
||||
this.car = car;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public List<Book> getBooks() {
|
||||
return books;
|
||||
}
|
||||
@ -203,8 +208,7 @@ public class ReactiveElasticsearchQueryMethodUnitTests {
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
@Document(indexName = "test-index-book-reactive-repository-query", replicas = 0,
|
||||
refreshInterval = "-1")
|
||||
@Document(indexName = "test-index-book-reactive-repository-query", replicas = 0, refreshInterval = "-1")
|
||||
static class Book {
|
||||
|
||||
@Id private String id;
|
||||
@ -254,9 +258,10 @@ public class ReactiveElasticsearchQueryMethodUnitTests {
|
||||
*/
|
||||
static class Author {
|
||||
|
||||
private String id;
|
||||
private String name;
|
||||
@Nullable private String id;
|
||||
@Nullable private String name;
|
||||
|
||||
@Nullable
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
@ -265,6 +270,7 @@ public class ReactiveElasticsearchQueryMethodUnitTests {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
@ -55,6 +55,7 @@ import org.springframework.data.repository.Repository;
|
||||
import org.springframework.data.repository.core.support.DefaultRepositoryMetadata;
|
||||
import org.springframework.data.repository.query.QueryMethodEvaluationContextProvider;
|
||||
import org.springframework.expression.spel.standard.SpelExpressionParser;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* @author Christoph Strobl
|
||||
@ -175,18 +176,18 @@ public class ReactiveElasticsearchStringQueryUnitTests {
|
||||
* @author Artur Konczak
|
||||
*/
|
||||
|
||||
@Document(indexName = "test-index-person-reactive-repository-string-query", replicas = 0,
|
||||
refreshInterval = "-1")
|
||||
@Document(indexName = "test-index-person-reactive-repository-string-query", replicas = 0, refreshInterval = "-1")
|
||||
public class Person {
|
||||
|
||||
@Id private String id;
|
||||
@Nullable @Id private String id;
|
||||
|
||||
private String name;
|
||||
@Nullable private String name;
|
||||
|
||||
@Field(type = FieldType.Nested) private List<Car> car;
|
||||
@Nullable @Field(type = FieldType.Nested) private List<Car> car;
|
||||
|
||||
@Field(type = FieldType.Nested, includeInParent = true) private List<Book> books;
|
||||
@Nullable @Field(type = FieldType.Nested, includeInParent = true) private List<Book> books;
|
||||
|
||||
@Nullable
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
@ -195,6 +196,7 @@ public class ReactiveElasticsearchStringQueryUnitTests {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
@ -203,6 +205,7 @@ public class ReactiveElasticsearchStringQueryUnitTests {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public List<Car> getCar() {
|
||||
return car;
|
||||
}
|
||||
@ -211,6 +214,7 @@ public class ReactiveElasticsearchStringQueryUnitTests {
|
||||
this.car = car;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public List<Book> getBooks() {
|
||||
return books;
|
||||
}
|
||||
@ -230,8 +234,7 @@ public class ReactiveElasticsearchStringQueryUnitTests {
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
@Document(indexName = "test-index-book-reactive-repository-string-query", replicas = 0,
|
||||
refreshInterval = "-1")
|
||||
@Document(indexName = "test-index-book-reactive-repository-string-query", replicas = 0, refreshInterval = "-1")
|
||||
static class Book {
|
||||
|
||||
@Id private String id;
|
||||
@ -281,9 +284,10 @@ public class ReactiveElasticsearchStringQueryUnitTests {
|
||||
*/
|
||||
static class Author {
|
||||
|
||||
private String id;
|
||||
private String name;
|
||||
@Nullable private String id;
|
||||
@Nullable private String name;
|
||||
|
||||
@Nullable
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
@ -292,6 +296,7 @@ public class ReactiveElasticsearchStringQueryUnitTests {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ class StubParameterAccessor implements ElasticsearchParameterAccessor {
|
||||
*/
|
||||
@Override
|
||||
public Pageable getPageable() {
|
||||
return null;
|
||||
return Pageable.unpaged();
|
||||
}
|
||||
|
||||
/*
|
||||
@ -104,8 +104,8 @@ class StubParameterAccessor implements ElasticsearchParameterAccessor {
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.data.repository.query.ParameterAccessor#findDynamicProjection()
|
||||
*/
|
||||
@Override
|
||||
public Class<?> findDynamicProjection() {
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public Class<?> findDynamicProjection() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user