mirror of
https://github.com/spring-projects/spring-data-elasticsearch.git
synced 2025-06-22 20:12:11 +00:00
DATAES-637 - Change branch 4.0. to use Elasticsearch 7.3.
Original PR: #302
This commit is contained in:
parent
9cb9c72acc
commit
ce686b1f03
2
pom.xml
2
pom.xml
@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<commonslang>2.6</commonslang>
|
<commonslang>2.6</commonslang>
|
||||||
<elasticsearch>6.8.1</elasticsearch>
|
<elasticsearch>7.3.0</elasticsearch>
|
||||||
<log4j>2.9.1</log4j>
|
<log4j>2.9.1</log4j>
|
||||||
<springdata.commons>2.3.0.BUILD-SNAPSHOT</springdata.commons>
|
<springdata.commons>2.3.0.BUILD-SNAPSHOT</springdata.commons>
|
||||||
<netty>4.1.39.Final</netty>
|
<netty>4.1.39.Final</netty>
|
||||||
|
@ -22,7 +22,6 @@ import java.lang.annotation.RetentionPolicy;
|
|||||||
import java.lang.annotation.Target;
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
import org.elasticsearch.index.VersionType;
|
import org.elasticsearch.index.VersionType;
|
||||||
|
|
||||||
import org.springframework.data.annotation.Persistent;
|
import org.springframework.data.annotation.Persistent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -33,6 +32,7 @@ import org.springframework.data.annotation.Persistent;
|
|||||||
* @author Mason Chan
|
* @author Mason Chan
|
||||||
* @author Ivan Greene
|
* @author Ivan Greene
|
||||||
* @author Mark Paluch
|
* @author Mark Paluch
|
||||||
|
* @author Peter-Josef Meisch
|
||||||
*/
|
*/
|
||||||
@Persistent
|
@Persistent
|
||||||
@Inherited
|
@Inherited
|
||||||
@ -54,8 +54,14 @@ public @interface Document {
|
|||||||
String indexName();
|
String indexName();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Mapping type name.
|
* Mapping type name. <br/>
|
||||||
|
* deprecated as Elasticsearch does not support this anymore
|
||||||
|
* (@see <a href="https://www.elastic.co/guide/en/elasticsearch/reference/7.3/removal-of-types.html">Elastisearch removal of types documentation</a>) and will remove it in
|
||||||
|
* Elasticsearch 8.
|
||||||
|
*
|
||||||
|
* @deprecated since 4.0
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
String type() default "";
|
String type() default "";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -64,9 +70,11 @@ public @interface Document {
|
|||||||
boolean useServerConfiguration() default false;
|
boolean useServerConfiguration() default false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Number of shards for the index {@link #indexName()}. Used for index creation.
|
* Number of shards for the index {@link #indexName()}. Used for index creation. <br/>
|
||||||
|
* With version 4.0, the default value is changed from 5 to 1 to reflect the change in the default settings of
|
||||||
|
* Elasticsearch which changed to 1 as well in Elasticsearch 7.0.
|
||||||
*/
|
*/
|
||||||
short shards() default 5;
|
short shards() default 1;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Number of replicas for the index {@link #indexName()}. Used for index creation.
|
* Number of replicas for the index {@link #indexName()}. Used for index creation.
|
||||||
|
@ -20,6 +20,7 @@ import static java.util.Arrays.*;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
import java.util.Collections;
|
||||||
|
|
||||||
import org.elasticsearch.client.Client;
|
import org.elasticsearch.client.Client;
|
||||||
import org.elasticsearch.client.node.NodeClient;
|
import org.elasticsearch.client.node.NodeClient;
|
||||||
@ -42,6 +43,7 @@ import org.springframework.util.StringUtils;
|
|||||||
* @author Rizwan Idrees
|
* @author Rizwan Idrees
|
||||||
* @author Mohsin Husen
|
* @author Mohsin Husen
|
||||||
* @author Ilkang Na
|
* @author Ilkang Na
|
||||||
|
* @author Peter-Josef Meisch
|
||||||
*/
|
*/
|
||||||
public class NodeClientFactoryBean implements FactoryBean<Client>, InitializingBean, DisposableBean {
|
public class NodeClientFactoryBean implements FactoryBean<Client>, InitializingBean, DisposableBean {
|
||||||
|
|
||||||
@ -56,9 +58,12 @@ public class NodeClientFactoryBean implements FactoryBean<Client>, InitializingB
|
|||||||
|
|
||||||
public static class TestNode extends Node {
|
public static class TestNode extends Node {
|
||||||
|
|
||||||
|
private static final String DEFAULT_NODE_NAME = "spring-data-elasticsearch-test-node";
|
||||||
|
|
||||||
public TestNode(Settings preparedSettings, Collection<Class<? extends Plugin>> classpathPlugins) {
|
public TestNode(Settings preparedSettings, Collection<Class<? extends Plugin>> classpathPlugins) {
|
||||||
|
|
||||||
super(InternalSettingsPreparer.prepareEnvironment(preparedSettings, null), classpathPlugins, false);
|
super(InternalSettingsPreparer.prepareEnvironment(preparedSettings, Collections.emptyMap(), null,
|
||||||
|
() -> DEFAULT_NODE_NAME), classpathPlugins, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void registerDerivedNodeNameWithLogger(String nodeName) {
|
protected void registerDerivedNodeNameWithLogger(String nodeName) {
|
||||||
|
@ -122,6 +122,7 @@ import org.springframework.web.reactive.function.client.WebClient.RequestBodySpe
|
|||||||
*
|
*
|
||||||
* @author Christoph Strobl
|
* @author Christoph Strobl
|
||||||
* @author Mark Paluch
|
* @author Mark Paluch
|
||||||
|
* @author Peter-Josef Meisch
|
||||||
* @since 3.2
|
* @since 3.2
|
||||||
* @see ClientConfiguration
|
* @see ClientConfiguration
|
||||||
* @see ReactiveRestClients
|
* @see ReactiveRestClients
|
||||||
@ -548,7 +549,7 @@ public class DefaultReactiveElasticsearchClient implements ReactiveElasticsearch
|
|||||||
|
|
||||||
return new GetResult(response.getIndex(), response.getType(), response.getId(), response.getSeqNo(),
|
return new GetResult(response.getIndex(), response.getType(), response.getId(), response.getSeqNo(),
|
||||||
response.getPrimaryTerm(), response.getVersion(), response.isExists(), response.getSourceAsBytesRef(),
|
response.getPrimaryTerm(), response.getVersion(), response.isExists(), response.getSourceAsBytesRef(),
|
||||||
response.getFields());
|
response.getFields(), null);
|
||||||
}
|
}
|
||||||
|
|
||||||
// -->
|
// -->
|
||||||
|
@ -33,7 +33,6 @@ import org.elasticsearch.action.admin.cluster.health.ClusterHealthRequest;
|
|||||||
import org.elasticsearch.action.admin.cluster.storedscripts.DeleteStoredScriptRequest;
|
import org.elasticsearch.action.admin.cluster.storedscripts.DeleteStoredScriptRequest;
|
||||||
import org.elasticsearch.action.admin.cluster.storedscripts.GetStoredScriptRequest;
|
import org.elasticsearch.action.admin.cluster.storedscripts.GetStoredScriptRequest;
|
||||||
import org.elasticsearch.action.admin.cluster.storedscripts.PutStoredScriptRequest;
|
import org.elasticsearch.action.admin.cluster.storedscripts.PutStoredScriptRequest;
|
||||||
import org.elasticsearch.action.admin.indices.analyze.AnalyzeRequest;
|
|
||||||
import org.elasticsearch.action.admin.indices.close.CloseIndexRequest;
|
import org.elasticsearch.action.admin.indices.close.CloseIndexRequest;
|
||||||
import org.elasticsearch.action.admin.indices.create.CreateIndexRequest;
|
import org.elasticsearch.action.admin.indices.create.CreateIndexRequest;
|
||||||
import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest;
|
import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest;
|
||||||
@ -60,6 +59,7 @@ import org.elasticsearch.action.update.UpdateRequest;
|
|||||||
import org.elasticsearch.client.Request;
|
import org.elasticsearch.client.Request;
|
||||||
import org.elasticsearch.client.Requests;
|
import org.elasticsearch.client.Requests;
|
||||||
import org.elasticsearch.client.RethrottleRequest;
|
import org.elasticsearch.client.RethrottleRequest;
|
||||||
|
import org.elasticsearch.client.indices.AnalyzeRequest;
|
||||||
import org.elasticsearch.cluster.health.ClusterHealthStatus;
|
import org.elasticsearch.cluster.health.ClusterHealthStatus;
|
||||||
import org.elasticsearch.common.Priority;
|
import org.elasticsearch.common.Priority;
|
||||||
import org.elasticsearch.common.Strings;
|
import org.elasticsearch.common.Strings;
|
||||||
@ -98,6 +98,8 @@ import org.springframework.lang.Nullable;
|
|||||||
* <p>
|
* <p>
|
||||||
* Only intended for internal use.
|
* Only intended for internal use.
|
||||||
*
|
*
|
||||||
|
* @author Christoph Strobl
|
||||||
|
* @author Peter-Josef Meisch
|
||||||
* @since 3.2
|
* @since 3.2
|
||||||
*/
|
*/
|
||||||
public class RequestConverters {
|
public class RequestConverters {
|
||||||
@ -718,10 +720,10 @@ public class RequestConverters {
|
|||||||
Request request = new Request(HttpMethod.PUT.name(),
|
Request request = new Request(HttpMethod.PUT.name(),
|
||||||
RequestConverters.endpoint(putMappingRequest.indices(), "_mapping", putMappingRequest.type()));
|
RequestConverters.endpoint(putMappingRequest.indices(), "_mapping", putMappingRequest.type()));
|
||||||
|
|
||||||
RequestConverters.Params parameters = new RequestConverters.Params(request);
|
RequestConverters.Params parameters = new RequestConverters.Params(request) //
|
||||||
parameters.withTimeout(putMappingRequest.timeout());
|
.withTimeout(putMappingRequest.timeout()) //
|
||||||
parameters.withMasterTimeout(putMappingRequest.masterNodeTimeout());
|
.withMasterTimeout(putMappingRequest.masterNodeTimeout()) //
|
||||||
|
.withIncludeTypeName(true);
|
||||||
request.setEntity(RequestConverters.createEntity(putMappingRequest, RequestConverters.REQUEST_BODY_CONTENT_TYPE));
|
request.setEntity(RequestConverters.createEntity(putMappingRequest, RequestConverters.REQUEST_BODY_CONTENT_TYPE));
|
||||||
return request;
|
return request;
|
||||||
}
|
}
|
||||||
@ -942,7 +944,10 @@ public class RequestConverters {
|
|||||||
|
|
||||||
Params withWaitForActiveShards(ActiveShardCount activeShardCount, ActiveShardCount defaultActiveShardCount) {
|
Params withWaitForActiveShards(ActiveShardCount activeShardCount, ActiveShardCount defaultActiveShardCount) {
|
||||||
if (activeShardCount != null && activeShardCount != defaultActiveShardCount) {
|
if (activeShardCount != null && activeShardCount != defaultActiveShardCount) {
|
||||||
return putParam("wait_for_active_shards", activeShardCount.toString().toLowerCase(Locale.ROOT));
|
// in Elasticsearch 7, "default" cannot be sent anymore, so it needs to be mapped to the default value of 1
|
||||||
|
String value = activeShardCount == ActiveShardCount.DEFAULT ? "1"
|
||||||
|
: activeShardCount.toString().toLowerCase(Locale.ROOT);
|
||||||
|
return putParam("wait_for_active_shards", value);
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@ -1082,6 +1087,18 @@ public class RequestConverters {
|
|||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* sets the include_type_name parameter. Needed for Elasticsearch 7 to be used with the mapping types still
|
||||||
|
* available. Will be removed again when Elasticsearch drops the support for this parameter in Elasticsearch 8.
|
||||||
|
*
|
||||||
|
* @deprecated since 4.0
|
||||||
|
* @since 4.0
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
Params withIncludeTypeName(boolean includeTypeName) {
|
||||||
|
return putParam("include_type_name", String.valueOf(includeTypeName));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -28,7 +28,6 @@ import org.elasticsearch.action.get.MultiGetResponse;
|
|||||||
import org.elasticsearch.action.search.SearchResponse;
|
import org.elasticsearch.action.search.SearchResponse;
|
||||||
import org.elasticsearch.common.document.DocumentField;
|
import org.elasticsearch.common.document.DocumentField;
|
||||||
import org.elasticsearch.search.SearchHit;
|
import org.elasticsearch.search.SearchHit;
|
||||||
|
|
||||||
import org.springframework.core.convert.ConversionService;
|
import org.springframework.core.convert.ConversionService;
|
||||||
import org.springframework.core.convert.support.DefaultConversionService;
|
import org.springframework.core.convert.support.DefaultConversionService;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
@ -40,6 +39,7 @@ import org.springframework.data.elasticsearch.core.aggregation.impl.AggregatedPa
|
|||||||
import org.springframework.data.elasticsearch.core.mapping.ElasticsearchPersistentEntity;
|
import org.springframework.data.elasticsearch.core.mapping.ElasticsearchPersistentEntity;
|
||||||
import org.springframework.data.elasticsearch.core.mapping.ElasticsearchPersistentProperty;
|
import org.springframework.data.elasticsearch.core.mapping.ElasticsearchPersistentProperty;
|
||||||
import org.springframework.data.elasticsearch.core.mapping.SimpleElasticsearchMappingContext;
|
import org.springframework.data.elasticsearch.core.mapping.SimpleElasticsearchMappingContext;
|
||||||
|
import org.springframework.data.elasticsearch.support.SearchHitsUtil;
|
||||||
import org.springframework.data.mapping.PersistentPropertyAccessor;
|
import org.springframework.data.mapping.PersistentPropertyAccessor;
|
||||||
import org.springframework.data.mapping.context.MappingContext;
|
import org.springframework.data.mapping.context.MappingContext;
|
||||||
import org.springframework.data.mapping.model.ConvertingPropertyAccessor;
|
import org.springframework.data.mapping.model.ConvertingPropertyAccessor;
|
||||||
@ -99,7 +99,7 @@ public class DefaultResultMapper extends AbstractResultMapper {
|
|||||||
@Override
|
@Override
|
||||||
public <T> AggregatedPage<T> mapResults(SearchResponse response, Class<T> clazz, Pageable pageable) {
|
public <T> AggregatedPage<T> mapResults(SearchResponse response, Class<T> clazz, Pageable pageable) {
|
||||||
|
|
||||||
long totalHits = response.getHits().getTotalHits();
|
long totalHits = SearchHitsUtil.getTotalCount(response.getHits());
|
||||||
float maxScore = response.getHits().getMaxScore();
|
float maxScore = response.getHits().getMaxScore();
|
||||||
|
|
||||||
List<T> results = new ArrayList<>();
|
List<T> results = new ArrayList<>();
|
||||||
|
@ -56,6 +56,7 @@ import org.elasticsearch.action.search.SearchResponse;
|
|||||||
import org.elasticsearch.action.search.SearchScrollRequest;
|
import org.elasticsearch.action.search.SearchScrollRequest;
|
||||||
import org.elasticsearch.action.update.UpdateRequest;
|
import org.elasticsearch.action.update.UpdateRequest;
|
||||||
import org.elasticsearch.action.update.UpdateResponse;
|
import org.elasticsearch.action.update.UpdateResponse;
|
||||||
|
import org.elasticsearch.client.Request;
|
||||||
import org.elasticsearch.client.RequestOptions;
|
import org.elasticsearch.client.RequestOptions;
|
||||||
import org.elasticsearch.client.Requests;
|
import org.elasticsearch.client.Requests;
|
||||||
import org.elasticsearch.client.Response;
|
import org.elasticsearch.client.Response;
|
||||||
@ -104,6 +105,7 @@ import org.springframework.data.elasticsearch.core.mapping.ElasticsearchPersiste
|
|||||||
import org.springframework.data.elasticsearch.core.mapping.ElasticsearchPersistentProperty;
|
import org.springframework.data.elasticsearch.core.mapping.ElasticsearchPersistentProperty;
|
||||||
import org.springframework.data.elasticsearch.core.mapping.SimpleElasticsearchMappingContext;
|
import org.springframework.data.elasticsearch.core.mapping.SimpleElasticsearchMappingContext;
|
||||||
import org.springframework.data.elasticsearch.core.query.*;
|
import org.springframework.data.elasticsearch.core.query.*;
|
||||||
|
import org.springframework.data.elasticsearch.support.SearchHitsUtil;
|
||||||
import org.springframework.data.util.CloseableIterator;
|
import org.springframework.data.util.CloseableIterator;
|
||||||
import org.springframework.lang.Nullable;
|
import org.springframework.lang.Nullable;
|
||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
@ -302,7 +304,8 @@ public class ElasticsearchRestTemplate extends AbstractElasticsearchTemplate
|
|||||||
Map<String, Object> mappings = null;
|
Map<String, Object> mappings = null;
|
||||||
RestClient restClient = client.getLowLevelClient();
|
RestClient restClient = client.getLowLevelClient();
|
||||||
try {
|
try {
|
||||||
Response response = restClient.performRequest("GET", "/" + indexName + "/_mapping/" + type);
|
Request request = new Request("GET", '/' + indexName + "/_mapping/" + type + "?include_type_name=true");
|
||||||
|
Response response = restClient.performRequest(request);
|
||||||
mappings = convertMappingResponse(EntityUtils.toString(response.getEntity()), type);
|
mappings = convertMappingResponse(EntityUtils.toString(response.getEntity()), type);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new ElasticsearchException(
|
throw new ElasticsearchException(
|
||||||
@ -601,7 +604,7 @@ public class ElasticsearchRestTemplate extends AbstractElasticsearchTemplate
|
|||||||
countRequest.source(sourceBuilder);
|
countRequest.source(sourceBuilder);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return client.search(countRequest, RequestOptions.DEFAULT).getHits().getTotalHits();
|
return SearchHitsUtil.getTotalCount(client.search(countRequest, RequestOptions.DEFAULT).getHits());
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new ElasticsearchException("Error while searching for request: " + countRequest.toString(), e);
|
throw new ElasticsearchException("Error while searching for request: " + countRequest.toString(), e);
|
||||||
}
|
}
|
||||||
@ -622,7 +625,7 @@ public class ElasticsearchRestTemplate extends AbstractElasticsearchTemplate
|
|||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new ElasticsearchException("Error for search request: " + searchRequest.toString(), e);
|
throw new ElasticsearchException("Error for search request: " + searchRequest.toString(), e);
|
||||||
}
|
}
|
||||||
return response.getHits().getTotalHits();
|
return SearchHitsUtil.getTotalCount(response.getHits());
|
||||||
}
|
}
|
||||||
|
|
||||||
private <T> SearchRequest prepareCount(Query query, Class<T> clazz) {
|
private <T> SearchRequest prepareCount(Query query, Class<T> clazz) {
|
||||||
@ -844,7 +847,7 @@ public class ElasticsearchRestTemplate extends AbstractElasticsearchTemplate
|
|||||||
public boolean typeExists(String index, String type) {
|
public boolean typeExists(String index, String type) {
|
||||||
RestClient restClient = client.getLowLevelClient();
|
RestClient restClient = client.getLowLevelClient();
|
||||||
try {
|
try {
|
||||||
Response response = restClient.performRequest("HEAD", index + "/_mapping/" + type);
|
Response response = restClient.performRequest(new Request("HEAD", index + "/_mapping/" + type));
|
||||||
return (response.getStatusLine().getStatusCode() == 200);
|
return (response.getStatusLine().getStatusCode() == 200);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new ElasticsearchException("Error while checking type exists for index: " + index + " type : " + type + " ",
|
throw new ElasticsearchException("Error while checking type exists for index: " + index + " type : " + type + " ",
|
||||||
@ -1272,7 +1275,7 @@ public class ElasticsearchRestTemplate extends AbstractElasticsearchTemplate
|
|||||||
Map settings = null;
|
Map settings = null;
|
||||||
RestClient restClient = client.getLowLevelClient();
|
RestClient restClient = client.getLowLevelClient();
|
||||||
try {
|
try {
|
||||||
Response response = restClient.performRequest("GET", "/" + indexName + "/_settings");
|
Response response = restClient.performRequest(new Request("GET", "/" + indexName + "/_settings"));
|
||||||
settings = convertSettingResponse(EntityUtils.toString(response.getEntity()), indexName);
|
settings = convertSettingResponse(EntityUtils.toString(response.getEntity()), indexName);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@ -1432,10 +1435,6 @@ public class ElasticsearchRestTemplate extends AbstractElasticsearchTemplate
|
|||||||
indexRequest.versionType(versionType);
|
indexRequest.versionType(versionType);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (query.getParentId() != null) {
|
|
||||||
indexRequest.parent(query.getParentId());
|
|
||||||
}
|
|
||||||
|
|
||||||
return indexRequest;
|
return indexRequest;
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new ElasticsearchException("failed to index the document [id: " + query.getId() + "]", e);
|
throw new ElasticsearchException("failed to index the document [id: " + query.getId() + "]", e);
|
||||||
@ -1466,7 +1465,7 @@ public class ElasticsearchRestTemplate extends AbstractElasticsearchTemplate
|
|||||||
String aliasResponse;
|
String aliasResponse;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
response = restClient.performRequest("GET", "/" + indexName + "/_alias/*");
|
response = restClient.performRequest(new Request("GET", "/" + indexName + "/_alias/*"));
|
||||||
aliasResponse = EntityUtils.toString(response.getEntity());
|
aliasResponse = EntityUtils.toString(response.getEntity());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new ElasticsearchException("Error while getting mapping for indexName : " + indexName, e);
|
throw new ElasticsearchException("Error while getting mapping for indexName : " + indexName, e);
|
||||||
|
@ -92,6 +92,7 @@ import org.springframework.data.elasticsearch.core.mapping.ElasticsearchPersiste
|
|||||||
import org.springframework.data.elasticsearch.core.mapping.ElasticsearchPersistentProperty;
|
import org.springframework.data.elasticsearch.core.mapping.ElasticsearchPersistentProperty;
|
||||||
import org.springframework.data.elasticsearch.core.mapping.SimpleElasticsearchMappingContext;
|
import org.springframework.data.elasticsearch.core.mapping.SimpleElasticsearchMappingContext;
|
||||||
import org.springframework.data.elasticsearch.core.query.*;
|
import org.springframework.data.elasticsearch.core.query.*;
|
||||||
|
import org.springframework.data.elasticsearch.support.SearchHitsUtil;
|
||||||
import org.springframework.data.util.CloseableIterator;
|
import org.springframework.data.util.CloseableIterator;
|
||||||
import org.springframework.lang.Nullable;
|
import org.springframework.lang.Nullable;
|
||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
@ -508,7 +509,7 @@ public class ElasticsearchTemplate extends AbstractElasticsearchTemplate
|
|||||||
if (elasticsearchQuery != null) {
|
if (elasticsearchQuery != null) {
|
||||||
countRequestBuilder.setQuery(elasticsearchQuery);
|
countRequestBuilder.setQuery(elasticsearchQuery);
|
||||||
}
|
}
|
||||||
return countRequestBuilder.execute().actionGet().getHits().getTotalHits();
|
return SearchHitsUtil.getTotalCount(countRequestBuilder.execute().actionGet().getHits());
|
||||||
}
|
}
|
||||||
|
|
||||||
private long doCount(SearchRequestBuilder searchRequestBuilder, QueryBuilder elasticsearchQuery,
|
private long doCount(SearchRequestBuilder searchRequestBuilder, QueryBuilder elasticsearchQuery,
|
||||||
@ -521,7 +522,7 @@ public class ElasticsearchTemplate extends AbstractElasticsearchTemplate
|
|||||||
if (elasticsearchFilter != null) {
|
if (elasticsearchFilter != null) {
|
||||||
searchRequestBuilder.setPostFilter(elasticsearchFilter);
|
searchRequestBuilder.setPostFilter(elasticsearchFilter);
|
||||||
}
|
}
|
||||||
return searchRequestBuilder.execute().actionGet().getHits().getTotalHits();
|
return SearchHitsUtil.getTotalCount(searchRequestBuilder.execute().actionGet().getHits());
|
||||||
}
|
}
|
||||||
|
|
||||||
private <T> SearchRequestBuilder prepareCount(Query query, Class<T> clazz) {
|
private <T> SearchRequestBuilder prepareCount(Query query, Class<T> clazz) {
|
||||||
@ -1202,10 +1203,6 @@ public class ElasticsearchTemplate extends AbstractElasticsearchTemplate
|
|||||||
indexRequestBuilder.setVersionType(versionType);
|
indexRequestBuilder.setVersionType(versionType);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (query.getParentId() != null) {
|
|
||||||
indexRequestBuilder.setParent(query.getParentId());
|
|
||||||
}
|
|
||||||
|
|
||||||
return indexRequestBuilder;
|
return indexRequestBuilder;
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new ElasticsearchException("failed to index the document [id: " + query.getId() + "]", e);
|
throw new ElasticsearchException("failed to index the document [id: " + query.getId() + "]", e);
|
||||||
|
@ -15,18 +15,21 @@
|
|||||||
*/
|
*/
|
||||||
package org.springframework.data.elasticsearch.core;
|
package org.springframework.data.elasticsearch.core;
|
||||||
|
|
||||||
|
import static java.util.Optional.*;
|
||||||
|
|
||||||
|
import java.time.ZonedDateTime;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.elasticsearch.search.aggregations.Aggregation;
|
import org.elasticsearch.search.aggregations.Aggregation;
|
||||||
import org.elasticsearch.search.aggregations.Aggregations;
|
import org.elasticsearch.search.aggregations.Aggregations;
|
||||||
import org.elasticsearch.search.aggregations.bucket.histogram.Histogram;
|
import org.elasticsearch.search.aggregations.bucket.histogram.Histogram;
|
||||||
import org.elasticsearch.search.aggregations.bucket.range.Range;
|
import org.elasticsearch.search.aggregations.bucket.range.Range;
|
||||||
import org.elasticsearch.search.aggregations.bucket.terms.Terms;
|
import org.elasticsearch.search.aggregations.bucket.terms.Terms;
|
||||||
import org.elasticsearch.search.aggregations.metrics.stats.extended.ExtendedStats;
|
import org.elasticsearch.search.aggregations.metrics.ExtendedStats;
|
||||||
import org.elasticsearch.search.aggregations.metrics.sum.Sum;
|
import org.elasticsearch.search.aggregations.metrics.Sum;
|
||||||
import org.joda.time.DateTime;
|
|
||||||
import org.springframework.data.domain.PageImpl;
|
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;
|
||||||
@ -40,8 +43,6 @@ import org.springframework.data.elasticsearch.core.facet.result.StatisticalResul
|
|||||||
import org.springframework.data.elasticsearch.core.facet.result.Term;
|
import org.springframework.data.elasticsearch.core.facet.result.Term;
|
||||||
import org.springframework.data.elasticsearch.core.facet.result.TermResult;
|
import org.springframework.data.elasticsearch.core.facet.result.TermResult;
|
||||||
|
|
||||||
import static java.util.Optional.ofNullable;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Container for query result and facet results
|
* Container for query result and facet results
|
||||||
*
|
*
|
||||||
@ -51,6 +52,7 @@ import static java.util.Optional.ofNullable;
|
|||||||
* @author Jonathan Yan
|
* @author Jonathan Yan
|
||||||
* @author Philipp Kräutli
|
* @author Philipp Kräutli
|
||||||
* @author Remco Zigterman
|
* @author Remco Zigterman
|
||||||
|
* @author Peter-Josef Meisch
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public abstract class FacetedPageImpl<T> extends PageImpl<T> implements FacetedPage<T>, AggregatedPage<T> {
|
public abstract class FacetedPageImpl<T> extends PageImpl<T> implements FacetedPage<T>, AggregatedPage<T> {
|
||||||
@ -106,8 +108,7 @@ public abstract class FacetedPageImpl<T> extends PageImpl<T> implements FacetedP
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void processAggregation(Aggregation agg)
|
private void processAggregation(Aggregation agg) {
|
||||||
{
|
|
||||||
if (agg instanceof Terms) {
|
if (agg instanceof Terms) {
|
||||||
processTermAggregation((Terms) agg);
|
processTermAggregation((Terms) agg);
|
||||||
}
|
}
|
||||||
@ -122,8 +123,7 @@ public abstract class FacetedPageImpl<T> extends PageImpl<T> implements FacetedP
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void processTermAggregation(Terms agg)
|
private void processTermAggregation(Terms agg) {
|
||||||
{
|
|
||||||
List<Term> terms = new ArrayList<>();
|
List<Term> terms = new ArrayList<>();
|
||||||
for (Terms.Bucket t : agg.getBuckets()) {
|
for (Terms.Bucket t : agg.getBuckets()) {
|
||||||
terms.add(new Term(t.getKeyAsString(), t.getDocCount()));
|
terms.add(new Term(t.getKeyAsString(), t.getDocCount()));
|
||||||
@ -131,36 +131,39 @@ public abstract class FacetedPageImpl<T> extends PageImpl<T> implements FacetedP
|
|||||||
addFacet(new TermResult(agg.getName(), terms, terms.size(), agg.getSumOfOtherDocCounts(), 0));
|
addFacet(new TermResult(agg.getName(), terms, terms.size(), agg.getSumOfOtherDocCounts(), 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void processRangeAggregation(Range agg)
|
private void processRangeAggregation(Range agg) {
|
||||||
{
|
|
||||||
List<? extends Range.Bucket> buckets = ((Range) agg).getBuckets();
|
List<? extends Range.Bucket> buckets = ((Range) agg).getBuckets();
|
||||||
List<org.springframework.data.elasticsearch.core.facet.result.Range> ranges = new ArrayList<>();
|
List<org.springframework.data.elasticsearch.core.facet.result.Range> ranges = new ArrayList<>();
|
||||||
for (Range.Bucket b : buckets) {
|
for (Range.Bucket b : buckets) {
|
||||||
ExtendedStats rStats = b.getAggregations().get(AbstractFacetRequest.INTERNAL_STATS);
|
ExtendedStats rStats = b.getAggregations().get(AbstractFacetRequest.INTERNAL_STATS);
|
||||||
if (rStats != null) {
|
if (rStats != null) {
|
||||||
Sum sum = b.getAggregations().get(RangeFacetRequest.RANGE_INTERNAL_SUM);
|
Sum sum = b.getAggregations().get(RangeFacetRequest.RANGE_INTERNAL_SUM);
|
||||||
ranges.add(new org.springframework.data.elasticsearch.core.facet.result.Range((Double) b.getFrom(), (Double) b.getTo(), b.getDocCount(), sum != null ? sum.getValue() : rStats.getSum(), rStats.getCount(), rStats.getMin(), rStats.getMax()));
|
ranges.add(new org.springframework.data.elasticsearch.core.facet.result.Range((Double) b.getFrom(),
|
||||||
|
(Double) b.getTo(), b.getDocCount(), sum != null ? sum.getValue() : rStats.getSum(), rStats.getCount(),
|
||||||
|
rStats.getMin(), rStats.getMax()));
|
||||||
} else {
|
} else {
|
||||||
ranges.add(new org.springframework.data.elasticsearch.core.facet.result.Range((Double) b.getFrom(), (Double) b.getTo(), b.getDocCount(), 0, 0, 0, 0));
|
ranges.add(new org.springframework.data.elasticsearch.core.facet.result.Range((Double) b.getFrom(),
|
||||||
|
(Double) b.getTo(), b.getDocCount(), 0, 0, 0, 0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
addFacet(new RangeResult(agg.getName(), ranges));
|
addFacet(new RangeResult(agg.getName(), ranges));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void processExtendedStatsAggregation(ExtendedStats agg)
|
private void processExtendedStatsAggregation(ExtendedStats agg) {
|
||||||
{
|
addFacet(new StatisticalResult(agg.getName(), agg.getCount(), agg.getMax(), agg.getMin(), agg.getAvg(),
|
||||||
addFacet(new StatisticalResult(agg.getName(), agg.getCount(), agg.getMax(), agg.getMin(), agg.getAvg(), agg.getStdDeviation(), agg.getSumOfSquares(), agg.getSum(), agg.getVariance()));
|
agg.getStdDeviation(), agg.getSumOfSquares(), agg.getSum(), agg.getVariance()));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void processHistogramAggregation(Histogram agg)
|
private void processHistogramAggregation(Histogram agg) {
|
||||||
{
|
|
||||||
List<IntervalUnit> intervals = new ArrayList<>();
|
List<IntervalUnit> intervals = new ArrayList<>();
|
||||||
for (Histogram.Bucket h : agg.getBuckets()) {
|
for (Histogram.Bucket h : agg.getBuckets()) {
|
||||||
ExtendedStats hStats = h.getAggregations().get(AbstractFacetRequest.INTERNAL_STATS);
|
ExtendedStats hStats = h.getAggregations().get(AbstractFacetRequest.INTERNAL_STATS);
|
||||||
if (hStats != null) {
|
if (hStats != null) {
|
||||||
intervals.add(new IntervalUnit(((DateTime) h.getKey()).getMillis(), h.getDocCount(), h.getDocCount(), hStats.getSum(), hStats.getAvg(), hStats.getMin(), hStats.getMax()));
|
intervals.add(new IntervalUnit(((ZonedDateTime) h.getKey()).toInstant().toEpochMilli(), h.getDocCount(),
|
||||||
|
h.getDocCount(), hStats.getSum(), hStats.getAvg(), hStats.getMin(), hStats.getMax()));
|
||||||
} else {
|
} else {
|
||||||
intervals.add(new IntervalUnit(((DateTime) h.getKey()).getMillis(), h.getDocCount(), h.getDocCount(), 0, 0, 0, 0));
|
intervals.add(new IntervalUnit(((ZonedDateTime) h.getKey()).toInstant().toEpochMilli(), h.getDocCount(),
|
||||||
|
h.getDocCount(), 0, 0, 0, 0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
addFacet(new HistogramResult(agg.getName(), intervals));
|
addFacet(new HistogramResult(agg.getName(), intervals));
|
||||||
|
@ -170,14 +170,6 @@ public class ReactiveElasticsearchTemplate implements ReactiveElasticsearchOpera
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (entity.hasParent()) {
|
|
||||||
|
|
||||||
Object parentId = entity.getParentId();
|
|
||||||
if (parentId != null) {
|
|
||||||
request.parent(converter.convertId(parentId));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
request = prepareIndexRequest(value, request);
|
request = prepareIndexRequest(value, request);
|
||||||
return doIndex(request);
|
return doIndex(request);
|
||||||
});
|
});
|
||||||
|
@ -20,6 +20,7 @@ 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 IndexQuery {
|
public class IndexQuery {
|
||||||
@ -84,6 +85,11 @@ public class IndexQuery {
|
|||||||
return parentId;
|
return parentId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated from 4.0. Elasticsearch 7 does not support the parent id in an index request. parent/child relations
|
||||||
|
* must be modeled using the join datatype. Setting it here will have no effect.
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
public void setParentId(String parentId) {
|
public void setParentId(String parentId) {
|
||||||
this.parentId = parentId;
|
this.parentId = parentId;
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,32 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2019 the original author or authors.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* https://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package org.springframework.data.elasticsearch.support;
|
||||||
|
|
||||||
|
import org.elasticsearch.search.SearchHits;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Utility class to prevent leaking of Lucene API into Spring Data Elasticsearch.
|
||||||
|
*
|
||||||
|
* @author Peter-Josef Meisch
|
||||||
|
* @since 4.0
|
||||||
|
*/
|
||||||
|
public final class SearchHitsUtil {
|
||||||
|
private SearchHitsUtil() {}
|
||||||
|
|
||||||
|
public static long getTotalCount(SearchHits searchHits) {
|
||||||
|
return searchHits.getTotalHits().value;
|
||||||
|
}
|
||||||
|
}
|
@ -11,7 +11,7 @@
|
|||||||
<xsd:import namespace="http://www.springframework.org/schema/beans"/>
|
<xsd:import namespace="http://www.springframework.org/schema/beans"/>
|
||||||
<xsd:import namespace="http://www.springframework.org/schema/tool"/>
|
<xsd:import namespace="http://www.springframework.org/schema/tool"/>
|
||||||
<xsd:import namespace="http://www.springframework.org/schema/data/repository"
|
<xsd:import namespace="http://www.springframework.org/schema/data/repository"
|
||||||
schemaLocation="http://www.springframework.org/schema/data/repository/spring-repository.xsd"/>
|
schemaLocation="https://www.springframework.org/schema/data/repository/spring-repository.xsd"/>
|
||||||
|
|
||||||
<xsd:element name="repositories">
|
<xsd:element name="repositories">
|
||||||
<xsd:complexType>
|
<xsd:complexType>
|
||||||
|
@ -31,6 +31,7 @@ import org.springframework.data.elasticsearch.client.ClientConfiguration;
|
|||||||
import org.springframework.data.elasticsearch.client.RestClients;
|
import org.springframework.data.elasticsearch.client.RestClients;
|
||||||
import org.springframework.data.elasticsearch.client.reactive.ReactiveElasticsearchClient;
|
import org.springframework.data.elasticsearch.client.reactive.ReactiveElasticsearchClient;
|
||||||
import org.springframework.data.elasticsearch.client.reactive.ReactiveRestClients;
|
import org.springframework.data.elasticsearch.client.reactive.ReactiveRestClients;
|
||||||
|
import org.springframework.data.elasticsearch.support.SearchHitsUtil;
|
||||||
import org.springframework.data.util.Version;
|
import org.springframework.data.util.Version;
|
||||||
import org.springframework.util.ObjectUtils;
|
import org.springframework.util.ObjectUtils;
|
||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
@ -59,7 +60,8 @@ public final class TestUtils {
|
|||||||
|
|
||||||
try (RestHighLevelClient client = restHighLevelClient()) {
|
try (RestHighLevelClient client = restHighLevelClient()) {
|
||||||
|
|
||||||
org.elasticsearch.Version version = client.info(RequestOptions.DEFAULT).getVersion();
|
org.elasticsearch.Version version = org.elasticsearch.Version
|
||||||
|
.fromString(client.info(RequestOptions.DEFAULT).getVersion().getNumber());
|
||||||
return new Version(version.major, version.minor, version.revision);
|
return new Version(version.major, version.minor, version.revision);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@ -91,10 +93,10 @@ public final class TestUtils {
|
|||||||
|
|
||||||
try (RestHighLevelClient client = restHighLevelClient()) {
|
try (RestHighLevelClient client = restHighLevelClient()) {
|
||||||
|
|
||||||
return 0L == client
|
return 0L == SearchHitsUtil.getTotalCount(client
|
||||||
.search(new SearchRequest(indexName)
|
.search(new SearchRequest(indexName)
|
||||||
.source(SearchSourceBuilder.searchSource().query(QueryBuilders.matchAllQuery())), RequestOptions.DEFAULT)
|
.source(SearchSourceBuilder.searchSource().query(QueryBuilders.matchAllQuery())), RequestOptions.DEFAULT)
|
||||||
.getHits().getTotalHits();
|
.getHits());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,7 +30,6 @@ import java.util.stream.IntStream;
|
|||||||
|
|
||||||
import org.elasticsearch.ElasticsearchStatusException;
|
import org.elasticsearch.ElasticsearchStatusException;
|
||||||
import org.elasticsearch.Version;
|
import org.elasticsearch.Version;
|
||||||
import org.elasticsearch.action.admin.indices.create.CreateIndexRequest;
|
|
||||||
import org.elasticsearch.action.admin.indices.get.GetIndexRequest;
|
import org.elasticsearch.action.admin.indices.get.GetIndexRequest;
|
||||||
import org.elasticsearch.action.delete.DeleteRequest;
|
import org.elasticsearch.action.delete.DeleteRequest;
|
||||||
import org.elasticsearch.action.get.GetRequest;
|
import org.elasticsearch.action.get.GetRequest;
|
||||||
@ -41,6 +40,7 @@ import org.elasticsearch.action.support.WriteRequest.RefreshPolicy;
|
|||||||
import org.elasticsearch.action.update.UpdateRequest;
|
import org.elasticsearch.action.update.UpdateRequest;
|
||||||
import org.elasticsearch.client.RequestOptions;
|
import org.elasticsearch.client.RequestOptions;
|
||||||
import org.elasticsearch.client.RestHighLevelClient;
|
import org.elasticsearch.client.RestHighLevelClient;
|
||||||
|
import org.elasticsearch.client.indices.CreateIndexRequest;
|
||||||
import org.elasticsearch.common.unit.TimeValue;
|
import org.elasticsearch.common.unit.TimeValue;
|
||||||
import org.elasticsearch.index.get.GetResult;
|
import org.elasticsearch.index.get.GetResult;
|
||||||
import org.elasticsearch.index.query.QueryBuilders;
|
import org.elasticsearch.index.query.QueryBuilders;
|
||||||
@ -65,7 +65,7 @@ import org.springframework.test.context.junit4.SpringRunner;
|
|||||||
/**
|
/**
|
||||||
* @author Christoph Strobl
|
* @author Christoph Strobl
|
||||||
* @author Mark Paluch
|
* @author Mark Paluch
|
||||||
* @currentRead Fool's Fate - Robin Hobb
|
* @author Peter-Josef Meisch
|
||||||
*/
|
*/
|
||||||
@RunWith(SpringRunner.class)
|
@RunWith(SpringRunner.class)
|
||||||
@ContextConfiguration("classpath:infrastructure.xml")
|
@ContextConfiguration("classpath:infrastructure.xml")
|
||||||
@ -79,7 +79,9 @@ public class ReactiveElasticsearchClientTests {
|
|||||||
static final String TYPE_I = "doc-type-1";
|
static final String TYPE_I = "doc-type-1";
|
||||||
static final String TYPE_II = "doc-type-2";
|
static final String TYPE_II = "doc-type-2";
|
||||||
|
|
||||||
static final Map<String, String> DOC_SOURCE;
|
// must be <String, Object> and not <String, String>, otherwise UpdateRequest.doc() will use the overload with
|
||||||
|
// (Object...)
|
||||||
|
static final Map<String, Object> DOC_SOURCE;
|
||||||
|
|
||||||
RestHighLevelClient syncClient;
|
RestHighLevelClient syncClient;
|
||||||
ReactiveElasticsearchClient client;
|
ReactiveElasticsearchClient client;
|
||||||
@ -135,7 +137,6 @@ public class ReactiveElasticsearchClientTests {
|
|||||||
client.info().as(StepVerifier::create) //
|
client.info().as(StepVerifier::create) //
|
||||||
.consumeNextWith(it -> {
|
.consumeNextWith(it -> {
|
||||||
|
|
||||||
assertThat(it.isAvailable()).isTrue();
|
|
||||||
assertThat(it.getVersion()).isGreaterThanOrEqualTo(Version.CURRENT);
|
assertThat(it.getVersion()).isGreaterThanOrEqualTo(Version.CURRENT);
|
||||||
}) //
|
}) //
|
||||||
.verifyComplete();
|
.verifyComplete();
|
||||||
|
@ -179,7 +179,7 @@ public class ReactiveElasticsearchClientUnitTests {
|
|||||||
|
|
||||||
verify(hostProvider.client(HOST)).method(HttpMethod.GET);
|
verify(hostProvider.client(HOST)).method(HttpMethod.GET);
|
||||||
URI uri = hostProvider.when(HOST).captureUri();
|
URI uri = hostProvider.when(HOST).captureUri();
|
||||||
assertThat(uri.getRawPath()).isEqualTo("/twitter/_all/1");
|
assertThat(uri.getRawPath()).isEqualTo("/twitter/_doc/1");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test // DATAES-488
|
@Test // DATAES-488
|
||||||
@ -315,7 +315,7 @@ public class ReactiveElasticsearchClientUnitTests {
|
|||||||
verify(hostProvider.client(HOST)).method(HttpMethod.HEAD);
|
verify(hostProvider.client(HOST)).method(HttpMethod.HEAD);
|
||||||
|
|
||||||
URI uri = hostProvider.when(HOST).captureUri();
|
URI uri = hostProvider.when(HOST).captureUri();
|
||||||
assertThat(uri.getRawPath()).isEqualTo("/twitter/_all/1");
|
assertThat(uri.getRawPath()).isEqualTo("/twitter/_doc/1");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test // DATAES-488
|
@Test // DATAES-488
|
||||||
@ -359,7 +359,7 @@ public class ReactiveElasticsearchClientUnitTests {
|
|||||||
});
|
});
|
||||||
|
|
||||||
URI uri = hostProvider.when(HOST).captureUri();
|
URI uri = hostProvider.when(HOST).captureUri();
|
||||||
assertThat(uri.getRawPath()).isEqualTo("/twitter/10/_create");
|
assertThat(uri.getRawPath()).isEqualTo("/twitter/_doc/10/_create");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test // DATAES-488
|
@Test // DATAES-488
|
||||||
@ -378,7 +378,7 @@ public class ReactiveElasticsearchClientUnitTests {
|
|||||||
});
|
});
|
||||||
|
|
||||||
URI uri = hostProvider.when(HOST).captureUri();
|
URI uri = hostProvider.when(HOST).captureUri();
|
||||||
assertThat(uri.getRawPath()).isEqualTo("/twitter/10");
|
assertThat(uri.getRawPath()).isEqualTo("/twitter/_doc/10");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test // DATAES-488
|
@Test // DATAES-488
|
||||||
|
@ -33,6 +33,7 @@ import java.util.HashMap;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.apache.lucene.search.TotalHits;
|
||||||
import org.elasticsearch.action.get.GetResponse;
|
import org.elasticsearch.action.get.GetResponse;
|
||||||
import org.elasticsearch.action.get.MultiGetItemResponse;
|
import org.elasticsearch.action.get.MultiGetItemResponse;
|
||||||
import org.elasticsearch.action.get.MultiGetResponse;
|
import org.elasticsearch.action.get.MultiGetResponse;
|
||||||
@ -51,7 +52,6 @@ import org.junit.runners.Parameterized;
|
|||||||
import org.junit.runners.Parameterized.Parameters;
|
import org.junit.runners.Parameterized.Parameters;
|
||||||
import org.mockito.Mock;
|
import org.mockito.Mock;
|
||||||
import org.mockito.MockitoAnnotations;
|
import org.mockito.MockitoAnnotations;
|
||||||
|
|
||||||
import org.springframework.core.convert.support.DefaultConversionService;
|
import org.springframework.core.convert.support.DefaultConversionService;
|
||||||
import org.springframework.data.annotation.Id;
|
import org.springframework.data.annotation.Id;
|
||||||
import org.springframework.data.annotation.Version;
|
import org.springframework.data.annotation.Version;
|
||||||
@ -113,7 +113,7 @@ public class DefaultResultMapperTests {
|
|||||||
// given
|
// given
|
||||||
SearchHit[] hits = { createCarHit("Ford", "Grat"), createCarHit("BMW", "Arrow") };
|
SearchHit[] hits = { createCarHit("Ford", "Grat"), createCarHit("BMW", "Arrow") };
|
||||||
SearchHits searchHits = mock(SearchHits.class);
|
SearchHits searchHits = mock(SearchHits.class);
|
||||||
when(searchHits.getTotalHits()).thenReturn(2L);
|
when(searchHits.getTotalHits()).thenReturn(new TotalHits(2L, TotalHits.Relation.EQUAL_TO));
|
||||||
when(searchHits.iterator()).thenReturn(new ArrayIterator(hits));
|
when(searchHits.iterator()).thenReturn(new ArrayIterator(hits));
|
||||||
when(response.getHits()).thenReturn(searchHits);
|
when(response.getHits()).thenReturn(searchHits);
|
||||||
|
|
||||||
@ -135,7 +135,7 @@ public class DefaultResultMapperTests {
|
|||||||
// given
|
// given
|
||||||
SearchHit[] hits = { createCarHit("Ford", "Grat"), createCarHit("BMW", "Arrow") };
|
SearchHit[] hits = { createCarHit("Ford", "Grat"), createCarHit("BMW", "Arrow") };
|
||||||
SearchHits searchHits = mock(SearchHits.class);
|
SearchHits searchHits = mock(SearchHits.class);
|
||||||
when(searchHits.getTotalHits()).thenReturn(2L);
|
when(searchHits.getTotalHits()).thenReturn(new TotalHits(2L, TotalHits.Relation.EQUAL_TO));
|
||||||
when(searchHits.iterator()).thenReturn(new ArrayIterator(hits));
|
when(searchHits.iterator()).thenReturn(new ArrayIterator(hits));
|
||||||
when(response.getHits()).thenReturn(searchHits);
|
when(response.getHits()).thenReturn(searchHits);
|
||||||
|
|
||||||
@ -154,7 +154,7 @@ public class DefaultResultMapperTests {
|
|||||||
// given
|
// given
|
||||||
SearchHit[] hits = { createCarPartialHit("Ford", "Grat"), createCarPartialHit("BMW", "Arrow") };
|
SearchHit[] hits = { createCarPartialHit("Ford", "Grat"), createCarPartialHit("BMW", "Arrow") };
|
||||||
SearchHits searchHits = mock(SearchHits.class);
|
SearchHits searchHits = mock(SearchHits.class);
|
||||||
when(searchHits.getTotalHits()).thenReturn(2L);
|
when(searchHits.getTotalHits()).thenReturn(new TotalHits(2L, TotalHits.Relation.EQUAL_TO));
|
||||||
when(searchHits.iterator()).thenReturn(new ArrayIterator(hits));
|
when(searchHits.iterator()).thenReturn(new ArrayIterator(hits));
|
||||||
when(response.getHits()).thenReturn(searchHits);
|
when(response.getHits()).thenReturn(searchHits);
|
||||||
|
|
||||||
@ -247,7 +247,7 @@ public class DefaultResultMapperTests {
|
|||||||
when(hit2.getVersion()).thenReturn(5678L);
|
when(hit2.getVersion()).thenReturn(5678L);
|
||||||
|
|
||||||
SearchHits searchHits = mock(SearchHits.class);
|
SearchHits searchHits = mock(SearchHits.class);
|
||||||
when(searchHits.getTotalHits()).thenReturn(2L);
|
when(searchHits.getTotalHits()).thenReturn(new TotalHits(2L, TotalHits.Relation.EQUAL_TO));
|
||||||
when(searchHits.iterator()).thenReturn(Arrays.asList(hit1, hit2).iterator());
|
when(searchHits.iterator()).thenReturn(Arrays.asList(hit1, hit2).iterator());
|
||||||
|
|
||||||
SearchResponse searchResponse = mock(SearchResponse.class);
|
SearchResponse searchResponse = mock(SearchResponse.class);
|
||||||
|
@ -2624,7 +2624,7 @@ public class ElasticsearchTemplateTests {
|
|||||||
// then
|
// then
|
||||||
assertThat(created).isTrue();
|
assertThat(created).isTrue();
|
||||||
Map setting = elasticsearchTemplate.getSetting(UseServerConfigurationEntity.class);
|
Map setting = elasticsearchTemplate.getSetting(UseServerConfigurationEntity.class);
|
||||||
assertThat(setting.get("index.number_of_shards")).isEqualTo("5");
|
assertThat(setting.get("index.number_of_shards")).isEqualTo("1");
|
||||||
assertThat(setting.get("index.number_of_replicas")).isEqualTo("1");
|
assertThat(setting.get("index.number_of_replicas")).isEqualTo("1");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ import lombok.Setter;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.elasticsearch.common.geo.GeoHashUtils;
|
import org.elasticsearch.geo.utils.Geohash;
|
||||||
import org.elasticsearch.index.query.QueryBuilders;
|
import org.elasticsearch.index.query.QueryBuilders;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
@ -86,7 +86,7 @@ public class ElasticsearchTemplateGeoTests {
|
|||||||
double[] lonLatArray = { 0.100000, 51.000000 };
|
double[] lonLatArray = { 0.100000, 51.000000 };
|
||||||
String latLonString = "51.000000, 0.100000";
|
String latLonString = "51.000000, 0.100000";
|
||||||
String geohash = "u10j46mkfekr";
|
String geohash = "u10j46mkfekr";
|
||||||
GeoHashUtils.stringEncode(0.100000, 51.000000);
|
Geohash.stringEncode(0.100000, 51.000000);
|
||||||
LocationMarkerEntity location1 = LocationMarkerEntity.builder() //
|
LocationMarkerEntity location1 = LocationMarkerEntity.builder() //
|
||||||
.id("1").name("Artur Konczak") //
|
.id("1").name("Artur Konczak") //
|
||||||
.locationAsString(latLonString) //
|
.locationAsString(latLonString) //
|
||||||
@ -258,7 +258,7 @@ public class ElasticsearchTemplateGeoTests {
|
|||||||
// given
|
// given
|
||||||
loadClassBaseEntities();
|
loadClassBaseEntities();
|
||||||
CriteriaQuery geoLocationCriteriaQuery3 = new CriteriaQuery(new Criteria("location")
|
CriteriaQuery geoLocationCriteriaQuery3 = new CriteriaQuery(new Criteria("location")
|
||||||
.boundedBy(GeoHashUtils.stringEncode(0, 53.5171d), GeoHashUtils.stringEncode(0.2062d, 49.5171d)));
|
.boundedBy(Geohash.stringEncode(0, 53.5171d), Geohash.stringEncode(0.2062d, 49.5171d)));
|
||||||
|
|
||||||
// when
|
// when
|
||||||
List<AuthorMarkerEntity> geoAuthorsForGeoCriteria3 = elasticsearchTemplate.queryForList(geoLocationCriteriaQuery3,
|
List<AuthorMarkerEntity> geoAuthorsForGeoCriteria3 = elasticsearchTemplate.queryForList(geoLocationCriteriaQuery3,
|
||||||
|
Binary file not shown.
Binary file not shown.
@ -20,7 +20,7 @@
|
|||||||
description=Adds "built in" analyzers to Elasticsearch.
|
description=Adds "built in" analyzers to Elasticsearch.
|
||||||
#
|
#
|
||||||
# 'version': plugin's version
|
# 'version': plugin's version
|
||||||
version=6.8.1
|
version=7.3.0
|
||||||
#
|
#
|
||||||
# 'name': the plugin name
|
# 'name': the plugin name
|
||||||
name=analysis-common
|
name=analysis-common
|
||||||
@ -35,7 +35,7 @@ classname=org.elasticsearch.analysis.common.CommonAnalysisPlugin
|
|||||||
java.version=1.8
|
java.version=1.8
|
||||||
#
|
#
|
||||||
# 'elasticsearch.version': version of elasticsearch compiled against
|
# 'elasticsearch.version': version of elasticsearch compiled against
|
||||||
elasticsearch.version=6.8.1
|
elasticsearch.version=7.3.0
|
||||||
### optional elements for plugins:
|
### optional elements for plugins:
|
||||||
#
|
#
|
||||||
# 'extended.plugins': other plugins this plugin extends through SPI
|
# 'extended.plugins': other plugins this plugin extends through SPI
|
||||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -20,7 +20,7 @@
|
|||||||
description=Module for ingest processors that do not require additional security permissions or have large dependencies and resources
|
description=Module for ingest processors that do not require additional security permissions or have large dependencies and resources
|
||||||
#
|
#
|
||||||
# 'version': plugin's version
|
# 'version': plugin's version
|
||||||
version=6.8.1
|
version=7.3.0
|
||||||
#
|
#
|
||||||
# 'name': the plugin name
|
# 'name': the plugin name
|
||||||
name=ingest-common
|
name=ingest-common
|
||||||
@ -35,7 +35,7 @@ classname=org.elasticsearch.ingest.common.IngestCommonPlugin
|
|||||||
java.version=1.8
|
java.version=1.8
|
||||||
#
|
#
|
||||||
# 'elasticsearch.version': version of elasticsearch compiled against
|
# 'elasticsearch.version': version of elasticsearch compiled against
|
||||||
elasticsearch.version=6.8.1
|
elasticsearch.version=7.3.0
|
||||||
### optional elements for plugins:
|
### optional elements for plugins:
|
||||||
#
|
#
|
||||||
# 'extended.plugins': other plugins this plugin extends through SPI
|
# 'extended.plugins': other plugins this plugin extends through SPI
|
||||||
|
Binary file not shown.
Binary file not shown.
@ -20,7 +20,7 @@
|
|||||||
description=Lucene expressions integration for Elasticsearch
|
description=Lucene expressions integration for Elasticsearch
|
||||||
#
|
#
|
||||||
# 'version': plugin's version
|
# 'version': plugin's version
|
||||||
version=6.8.1
|
version=7.3.0
|
||||||
#
|
#
|
||||||
# 'name': the plugin name
|
# 'name': the plugin name
|
||||||
name=lang-expression
|
name=lang-expression
|
||||||
@ -35,7 +35,7 @@ classname=org.elasticsearch.script.expression.ExpressionPlugin
|
|||||||
java.version=1.8
|
java.version=1.8
|
||||||
#
|
#
|
||||||
# 'elasticsearch.version': version of elasticsearch compiled against
|
# 'elasticsearch.version': version of elasticsearch compiled against
|
||||||
elasticsearch.version=6.8.1
|
elasticsearch.version=7.3.0
|
||||||
### optional elements for plugins:
|
### optional elements for plugins:
|
||||||
#
|
#
|
||||||
# 'extended.plugins': other plugins this plugin extends through SPI
|
# 'extended.plugins': other plugins this plugin extends through SPI
|
||||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -20,7 +20,7 @@
|
|||||||
description=An easy, safe and fast scripting language for Elasticsearch
|
description=An easy, safe and fast scripting language for Elasticsearch
|
||||||
#
|
#
|
||||||
# 'version': plugin's version
|
# 'version': plugin's version
|
||||||
version=6.8.1
|
version=7.3.0
|
||||||
#
|
#
|
||||||
# 'name': the plugin name
|
# 'name': the plugin name
|
||||||
name=lang-painless
|
name=lang-painless
|
||||||
@ -35,7 +35,7 @@ classname=org.elasticsearch.painless.PainlessPlugin
|
|||||||
java.version=1.8
|
java.version=1.8
|
||||||
#
|
#
|
||||||
# 'elasticsearch.version': version of elasticsearch compiled against
|
# 'elasticsearch.version': version of elasticsearch compiled against
|
||||||
elasticsearch.version=6.8.1
|
elasticsearch.version=7.3.0
|
||||||
### optional elements for plugins:
|
### optional elements for plugins:
|
||||||
#
|
#
|
||||||
# 'extended.plugins': other plugins this plugin extends through SPI
|
# 'extended.plugins': other plugins this plugin extends through SPI
|
||||||
|
Binary file not shown.
Binary file not shown.
@ -20,7 +20,7 @@
|
|||||||
description=Adds advanced field mappers
|
description=Adds advanced field mappers
|
||||||
#
|
#
|
||||||
# 'version': plugin's version
|
# 'version': plugin's version
|
||||||
version=6.8.1
|
version=7.3.0
|
||||||
#
|
#
|
||||||
# 'name': the plugin name
|
# 'name': the plugin name
|
||||||
name=mapper-extras
|
name=mapper-extras
|
||||||
@ -35,11 +35,11 @@ classname=org.elasticsearch.index.mapper.MapperExtrasPlugin
|
|||||||
java.version=1.8
|
java.version=1.8
|
||||||
#
|
#
|
||||||
# 'elasticsearch.version': version of elasticsearch compiled against
|
# 'elasticsearch.version': version of elasticsearch compiled against
|
||||||
elasticsearch.version=6.8.1
|
elasticsearch.version=7.3.0
|
||||||
### optional elements for plugins:
|
### optional elements for plugins:
|
||||||
#
|
#
|
||||||
# 'extended.plugins': other plugins this plugin extends through SPI
|
# 'extended.plugins': other plugins this plugin extends through SPI
|
||||||
extended.plugins=
|
extended.plugins=lang-painless
|
||||||
#
|
#
|
||||||
# 'has.native.controller': whether or not the plugin has a native controller
|
# 'has.native.controller': whether or not the plugin has a native controller
|
||||||
has.native.controller=false
|
has.native.controller=false
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
description=The Reindex module adds APIs to reindex from one index to another or update documents in place.
|
description=The Reindex module adds APIs to reindex from one index to another or update documents in place.
|
||||||
#
|
#
|
||||||
# 'version': plugin's version
|
# 'version': plugin's version
|
||||||
version=6.8.1
|
version=7.3.0
|
||||||
#
|
#
|
||||||
# 'name': the plugin name
|
# 'name': the plugin name
|
||||||
name=reindex
|
name=reindex
|
||||||
@ -35,7 +35,7 @@ classname=org.elasticsearch.index.reindex.ReindexPlugin
|
|||||||
java.version=1.8
|
java.version=1.8
|
||||||
#
|
#
|
||||||
# 'elasticsearch.version': version of elasticsearch compiled against
|
# 'elasticsearch.version': version of elasticsearch compiled against
|
||||||
elasticsearch.version=6.8.1
|
elasticsearch.version=7.3.0
|
||||||
### optional elements for plugins:
|
### optional elements for plugins:
|
||||||
#
|
#
|
||||||
# 'extended.plugins': other plugins this plugin extends through SPI
|
# 'extended.plugins': other plugins this plugin extends through SPI
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
description=Module for URL repository
|
description=Module for URL repository
|
||||||
#
|
#
|
||||||
# 'version': plugin's version
|
# 'version': plugin's version
|
||||||
version=6.8.1
|
version=7.3.0
|
||||||
#
|
#
|
||||||
# 'name': the plugin name
|
# 'name': the plugin name
|
||||||
name=repository-url
|
name=repository-url
|
||||||
@ -35,7 +35,7 @@ classname=org.elasticsearch.plugin.repository.url.URLRepositoryPlugin
|
|||||||
java.version=1.8
|
java.version=1.8
|
||||||
#
|
#
|
||||||
# 'elasticsearch.version': version of elasticsearch compiled against
|
# 'elasticsearch.version': version of elasticsearch compiled against
|
||||||
elasticsearch.version=6.8.1
|
elasticsearch.version=7.3.0
|
||||||
### optional elements for plugins:
|
### optional elements for plugins:
|
||||||
#
|
#
|
||||||
# 'extended.plugins': other plugins this plugin extends through SPI
|
# 'extended.plugins': other plugins this plugin extends through SPI
|
||||||
|
Binary file not shown.
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user