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