mirror of
https://github.com/spring-projects/spring-data-elasticsearch.git
synced 2025-05-30 08:42:10 +00:00
parent
79087c4ada
commit
e193e1672b
@ -1,36 +0,0 @@
|
||||
/*
|
||||
* Copyright 2014-2021 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.annotations;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
import org.springframework.data.annotation.Persistent;
|
||||
|
||||
/**
|
||||
* Parent
|
||||
*
|
||||
* @author Philipp Jardas
|
||||
* @deprecated since 4.1, not supported anymore by Elasticsearch
|
||||
*/
|
||||
@Deprecated
|
||||
@Persistent
|
||||
@Inherited
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.FIELD)
|
||||
public @interface Parent {
|
||||
|
||||
String type();
|
||||
}
|
@ -1,173 +0,0 @@
|
||||
/*
|
||||
* Copyright 2015-2021 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.client;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
||||
import org.elasticsearch.client.Client;
|
||||
import org.elasticsearch.client.node.NodeClient;
|
||||
import org.elasticsearch.common.logging.LogConfigurator;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.node.InternalSettingsPreparer;
|
||||
import org.elasticsearch.node.Node;
|
||||
import org.elasticsearch.plugins.Plugin;
|
||||
import org.elasticsearch.transport.Netty4Plugin;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.DisposableBean;
|
||||
import org.springframework.beans.factory.FactoryBean;
|
||||
import org.springframework.beans.factory.FactoryBeanNotInitializedException;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* NodeClientFactoryBean
|
||||
*
|
||||
* @author Rizwan Idrees
|
||||
* @author Mohsin Husen
|
||||
* @author Ilkang Na
|
||||
* @author Peter-Josef Meisch
|
||||
* @deprecated since 4.1, we're not supporting embedded Node clients anymore, use the REST client
|
||||
*/
|
||||
@Deprecated
|
||||
public class NodeClientFactoryBean implements FactoryBean<Client>, InitializingBean, DisposableBean {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(NodeClientFactoryBean.class);
|
||||
private boolean local;
|
||||
private boolean enableHttp;
|
||||
private @Nullable String clusterName;
|
||||
private @Nullable Node node;
|
||||
private @Nullable NodeClient nodeClient;
|
||||
private @Nullable String pathData;
|
||||
private @Nullable String pathHome;
|
||||
private @Nullable String pathConfiguration;
|
||||
|
||||
public static class TestNode extends Node {
|
||||
|
||||
private static final String DEFAULT_NODE_NAME = "spring-data-elasticsearch-nodeclientfactorybean-test";
|
||||
|
||||
public TestNode(Settings preparedSettings, Collection<Class<? extends Plugin>> classpathPlugins) {
|
||||
|
||||
super(InternalSettingsPreparer.prepareEnvironment(preparedSettings, Collections.emptyMap(), null,
|
||||
() -> DEFAULT_NODE_NAME), classpathPlugins, false);
|
||||
}
|
||||
|
||||
protected void registerDerivedNodeNameWithLogger(String nodeName) {
|
||||
try {
|
||||
LogConfigurator.setNodeName(nodeName);
|
||||
} catch (Exception e) {
|
||||
// nagh - just forget about it
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
NodeClientFactoryBean() {}
|
||||
|
||||
public NodeClientFactoryBean(boolean local) {
|
||||
this.local = local;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NodeClient getObject() {
|
||||
|
||||
if (nodeClient == null) {
|
||||
throw new FactoryBeanNotInitializedException();
|
||||
}
|
||||
|
||||
return nodeClient;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends Client> getObjectType() {
|
||||
return NodeClient.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSingleton() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
|
||||
Settings settings = Settings.builder() //
|
||||
.put(loadConfig()) //
|
||||
.put("transport.type", "netty4") //
|
||||
.put("http.type", "netty4") //
|
||||
.put("path.home", this.pathHome) //
|
||||
.put("path.data", this.pathData) //
|
||||
.put("cluster.name", this.clusterName) //
|
||||
.put("node.max_local_storage_nodes", 100) //
|
||||
.build();
|
||||
node = new TestNode(settings, Collections.singletonList(Netty4Plugin.class));
|
||||
nodeClient = (NodeClient) node.start().client();
|
||||
}
|
||||
|
||||
private Settings loadConfig() throws IOException {
|
||||
if (!StringUtils.isEmpty(pathConfiguration)) {
|
||||
InputStream stream = getClass().getClassLoader().getResourceAsStream(pathConfiguration);
|
||||
if (stream != null) {
|
||||
return Settings.builder().loadFromStream(pathConfiguration,
|
||||
getClass().getClassLoader().getResourceAsStream(pathConfiguration), false).build();
|
||||
}
|
||||
logger.error(String.format("Unable to read node configuration from file [%s]", pathConfiguration));
|
||||
}
|
||||
return Settings.builder().build();
|
||||
}
|
||||
|
||||
public void setLocal(boolean local) {
|
||||
this.local = local;
|
||||
}
|
||||
|
||||
public void setEnableHttp(boolean enableHttp) {
|
||||
this.enableHttp = enableHttp;
|
||||
}
|
||||
|
||||
public void setClusterName(String clusterName) {
|
||||
this.clusterName = clusterName;
|
||||
}
|
||||
|
||||
public void setPathData(String pathData) {
|
||||
this.pathData = pathData;
|
||||
}
|
||||
|
||||
public void setPathHome(String pathHome) {
|
||||
this.pathHome = pathHome;
|
||||
}
|
||||
|
||||
public void setPathConfiguration(String configuration) {
|
||||
this.pathConfiguration = configuration;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
try {
|
||||
// NodeClient.close() is a noop, no need to call it here
|
||||
nodeClient = null;
|
||||
logger.info("Closing elasticSearch node");
|
||||
if (node != null) {
|
||||
node.close();
|
||||
node = null;
|
||||
}
|
||||
} catch (final Exception e) {
|
||||
logger.error("Error closing ElasticSearch client: ", e);
|
||||
}
|
||||
}
|
||||
}
|
@ -1102,58 +1102,6 @@ public interface ReactiveElasticsearchClient {
|
||||
*/
|
||||
Mono<Void> refreshIndex(HttpHeaders headers, RefreshRequest refreshRequest);
|
||||
|
||||
/**
|
||||
* Execute the given {@link org.elasticsearch.action.admin.indices.mapping.put.PutMappingRequest} against the
|
||||
* {@literal indices} API.
|
||||
*
|
||||
* @param consumer never {@literal null}.
|
||||
* @return a {@link Mono} signalling operation completion or an {@link Mono#error(Throwable) error} if eg. the index
|
||||
* does not exist.
|
||||
* @see <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-put-mapping.html"> Indices
|
||||
* Put Mapping API on elastic.co</a>
|
||||
* @deprecated since 4.1, use {@link #putMapping(Consumer)}
|
||||
*/
|
||||
@Deprecated
|
||||
default Mono<Boolean> updateMapping(
|
||||
Consumer<org.elasticsearch.action.admin.indices.mapping.put.PutMappingRequest> consumer) {
|
||||
return putMapping(consumer);
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the given {@link org.elasticsearch.action.admin.indices.mapping.put.PutMappingRequest} against the
|
||||
* {@literal indices} API.
|
||||
*
|
||||
* @param putMappingRequest must not be {@literal null}.
|
||||
* @return a {@link Mono} signalling operation completion or an {@link Mono#error(Throwable) error} if eg. the index
|
||||
* does not exist.
|
||||
* @see <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-put-mapping.html"> Indices
|
||||
* Put Mapping API on elastic.co</a>
|
||||
* @deprecated since 4.1, use {@link #putMapping(PutMappingRequest)}
|
||||
*/
|
||||
@Deprecated
|
||||
default Mono<Boolean> updateMapping(
|
||||
org.elasticsearch.action.admin.indices.mapping.put.PutMappingRequest putMappingRequest) {
|
||||
return putMapping(putMappingRequest);
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the given {@link org.elasticsearch.action.admin.indices.mapping.put.PutMappingRequest} against the
|
||||
* {@literal indices} API.
|
||||
*
|
||||
* @param headers Use {@link HttpHeaders} to provide eg. authentication data. Must not be {@literal null}.
|
||||
* @param putMappingRequest must not be {@literal null}.
|
||||
* @return a {@link Mono} signalling operation completion or an {@link Mono#error(Throwable) error} if eg. the index
|
||||
* does not exist.
|
||||
* @see <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-put-mapping.html"> Indices
|
||||
* Put Mapping API on elastic.co</a>
|
||||
* @deprecated since 4.1, use {@link #putMapping(HttpHeaders, PutMappingRequest)}
|
||||
*/
|
||||
@Deprecated
|
||||
default Mono<Boolean> updateMapping(HttpHeaders headers,
|
||||
org.elasticsearch.action.admin.indices.mapping.put.PutMappingRequest putMappingRequest) {
|
||||
return putMapping(headers, putMappingRequest);
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the given {@link org.elasticsearch.action.admin.indices.mapping.put.PutMappingRequest} against the
|
||||
* {@literal indices} API.
|
||||
|
@ -841,8 +841,7 @@ public class RequestConverters {
|
||||
|
||||
RequestConverters.Params parameters = new RequestConverters.Params(request) //
|
||||
.withTimeout(putMappingRequest.timeout()) //
|
||||
.withMasterTimeout(putMappingRequest.masterNodeTimeout()) //
|
||||
.withIncludeTypeName(false);
|
||||
.withMasterTimeout(putMappingRequest.masterNodeTimeout());
|
||||
request.setEntity(RequestConverters.createEntity(putMappingRequest, RequestConverters.REQUEST_BODY_CONTENT_TYPE));
|
||||
return request;
|
||||
}
|
||||
@ -853,8 +852,7 @@ public class RequestConverters {
|
||||
|
||||
new RequestConverters.Params(request) //
|
||||
.withTimeout(putMappingRequest.timeout()) //
|
||||
.withMasterTimeout(putMappingRequest.masterNodeTimeout()) //
|
||||
.withIncludeTypeName(false);
|
||||
.withMasterTimeout(putMappingRequest.masterNodeTimeout());
|
||||
request.setEntity(RequestConverters.createEntity(putMappingRequest, RequestConverters.REQUEST_BODY_CONTENT_TYPE));
|
||||
return request;
|
||||
}
|
||||
@ -880,7 +878,6 @@ public class RequestConverters {
|
||||
parameters.withMasterTimeout(getMappingsRequest.masterNodeTimeout());
|
||||
parameters.withIndicesOptions(getMappingsRequest.indicesOptions());
|
||||
parameters.withLocal(getMappingsRequest.local());
|
||||
parameters.withIncludeTypeName(false);
|
||||
return request;
|
||||
}
|
||||
|
||||
@ -893,7 +890,6 @@ public class RequestConverters {
|
||||
parameters.withMasterTimeout(getMappingsRequest.masterNodeTimeout());
|
||||
parameters.withIndicesOptions(getMappingsRequest.indicesOptions());
|
||||
parameters.withLocal(getMappingsRequest.local());
|
||||
parameters.withIncludeTypeName(false);
|
||||
return request;
|
||||
}
|
||||
|
||||
@ -1000,7 +996,6 @@ public class RequestConverters {
|
||||
RequestConverters.Params parameters = new Params(request);
|
||||
parameters.withIndicesOptions(getFieldMappingsRequest.indicesOptions());
|
||||
parameters.withIncludeDefaults(getFieldMappingsRequest.includeDefaults());
|
||||
parameters.withIncludeTypeName(false);
|
||||
return request;
|
||||
}
|
||||
|
||||
@ -1372,18 +1367,6 @@ public class RequestConverters {
|
||||
}
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -35,7 +35,6 @@ public class ElasticsearchNamespaceHandler extends NamespaceHandlerSupport {
|
||||
RepositoryBeanDefinitionParser parser = new RepositoryBeanDefinitionParser(extension);
|
||||
|
||||
registerBeanDefinitionParser("repositories", parser);
|
||||
registerBeanDefinitionParser("node-client", new NodeClientBeanDefinitionParser());
|
||||
registerBeanDefinitionParser("transport-client", new TransportClientBeanDefinitionParser());
|
||||
registerBeanDefinitionParser("rest-client", new RestClientBeanDefinitionParser());
|
||||
}
|
||||
|
@ -41,32 +41,22 @@ public @interface EnableElasticsearchAuditing {
|
||||
|
||||
/**
|
||||
* Configures the {@link AuditorAware} bean to be used to lookup the current principal.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
String auditorAwareRef() default "";
|
||||
|
||||
/**
|
||||
* Configures whether the creation and modification dates are set. Defaults to {@literal true}.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
boolean setDates() default true;
|
||||
|
||||
/**
|
||||
* Configures whether the entity shall be marked as modified on creation. Defaults to {@literal true}.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
boolean modifyOnCreate() default true;
|
||||
|
||||
/**
|
||||
* Configures a {@link DateTimeProvider} bean name that allows customizing the {@link org.joda.time.DateTime} to be
|
||||
* used for setting creation and modification dates.
|
||||
*
|
||||
* @return
|
||||
* @deprecated since 4.1
|
||||
*/
|
||||
@Deprecated
|
||||
String dateTimeProviderRef() default "";
|
||||
}
|
||||
|
@ -41,32 +41,22 @@ public @interface EnableReactiveElasticsearchAuditing {
|
||||
|
||||
/**
|
||||
* Configures the {@link AuditorAware} bean to be used to lookup the current principal.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
String auditorAwareRef() default "";
|
||||
|
||||
/**
|
||||
* Configures whether the creation and modification dates are set. Defaults to {@literal true}.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
boolean setDates() default true;
|
||||
|
||||
/**
|
||||
* Configures whether the entity shall be marked as modified on creation. Defaults to {@literal true}.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
boolean modifyOnCreate() default true;
|
||||
|
||||
/**
|
||||
* Configures a {@link DateTimeProvider} bean name that allows customizing the {@link org.joda.time.DateTime} to be
|
||||
* used for setting creation and modification dates.
|
||||
*
|
||||
* @return
|
||||
* @deprecated since 4.1
|
||||
*/
|
||||
@Deprecated
|
||||
String dateTimeProviderRef() default "";
|
||||
}
|
||||
|
@ -1,57 +0,0 @@
|
||||
/*
|
||||
* Copyright 2015-2021 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.config;
|
||||
|
||||
import org.springframework.beans.factory.support.AbstractBeanDefinition;
|
||||
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
|
||||
import org.springframework.beans.factory.xml.AbstractBeanDefinitionParser;
|
||||
import org.springframework.beans.factory.xml.ParserContext;
|
||||
import org.springframework.data.elasticsearch.client.NodeClientFactoryBean;
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
/**
|
||||
* NodeClientBeanDefinitionParser
|
||||
*
|
||||
* @author Rizwan Idrees
|
||||
* @author Mohsin Husen
|
||||
*/
|
||||
|
||||
public class NodeClientBeanDefinitionParser extends AbstractBeanDefinitionParser {
|
||||
|
||||
@Override
|
||||
protected AbstractBeanDefinition parseInternal(Element element, ParserContext parserContext) {
|
||||
BeanDefinitionBuilder builder = BeanDefinitionBuilder.rootBeanDefinition(NodeClientFactoryBean.class);
|
||||
setLocalSettings(element, builder);
|
||||
return getSourcedBeanDefinition(builder, element, parserContext);
|
||||
}
|
||||
|
||||
private void setLocalSettings(Element element, BeanDefinitionBuilder builder) {
|
||||
builder.addPropertyValue("local", Boolean.valueOf(element.getAttribute("local")));
|
||||
builder.addPropertyValue("clusterName", element.getAttribute("cluster-name"));
|
||||
builder.addPropertyValue("enableHttp", Boolean.valueOf(element.getAttribute("http-enabled")));
|
||||
builder.addPropertyValue("pathData", element.getAttribute("path-data"));
|
||||
builder.addPropertyValue("pathHome", element.getAttribute("path-home"));
|
||||
builder.addPropertyValue("pathConfiguration", element.getAttribute("path-configuration"));
|
||||
}
|
||||
|
||||
private AbstractBeanDefinition getSourcedBeanDefinition(BeanDefinitionBuilder builder, Element source,
|
||||
ParserContext context) {
|
||||
AbstractBeanDefinition definition = builder.getBeanDefinition();
|
||||
definition.setSource(context.extractSource(source));
|
||||
return definition;
|
||||
}
|
||||
}
|
@ -36,7 +36,6 @@ import org.springframework.data.elasticsearch.core.index.MappingBuilder;
|
||||
import org.springframework.data.elasticsearch.core.index.Settings;
|
||||
import org.springframework.data.elasticsearch.core.mapping.ElasticsearchPersistentEntity;
|
||||
import org.springframework.data.elasticsearch.core.mapping.IndexCoordinates;
|
||||
import org.springframework.data.elasticsearch.core.query.AliasQuery;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
@ -176,31 +175,8 @@ abstract class AbstractDefaultIndexOperations implements IndexOperations {
|
||||
|
||||
protected abstract void doRefresh(IndexCoordinates indexCoordinates);
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public boolean addAlias(AliasQuery query) {
|
||||
return doAddAlias(query, getIndexCoordinates());
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
protected abstract boolean doAddAlias(AliasQuery query, IndexCoordinates index);
|
||||
|
||||
@Override
|
||||
public List<AliasMetadata> queryForAlias() {
|
||||
return doQueryForAlias(getIndexCoordinates());
|
||||
}
|
||||
|
||||
protected abstract List<AliasMetadata> doQueryForAlias(IndexCoordinates index);
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public boolean removeAlias(AliasQuery query) {
|
||||
return doRemoveAlias(query, getIndexCoordinates());
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
protected abstract boolean doRemoveAlias(AliasQuery query, IndexCoordinates index);
|
||||
|
||||
@Override
|
||||
public Map<String, Set<AliasData>> getAliases(String... aliasNames) {
|
||||
|
||||
|
@ -53,7 +53,6 @@ import org.springframework.data.elasticsearch.core.index.PutTemplateRequest;
|
||||
import org.springframework.data.elasticsearch.core.index.Settings;
|
||||
import org.springframework.data.elasticsearch.core.index.TemplateData;
|
||||
import org.springframework.data.elasticsearch.core.mapping.IndexCoordinates;
|
||||
import org.springframework.data.elasticsearch.core.query.AliasQuery;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
@ -141,27 +140,6 @@ class DefaultIndexOperations extends AbstractDefaultIndexOperations implements I
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
protected boolean doAddAlias(AliasQuery query, IndexCoordinates index) {
|
||||
|
||||
IndicesAliasesRequest request = requestFactory.indicesAddAliasesRequest(query, index);
|
||||
return restTemplate
|
||||
.execute(client -> client.indices().updateAliases(request, RequestOptions.DEFAULT).isAcknowledged());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
protected boolean doRemoveAlias(AliasQuery query, IndexCoordinates index) {
|
||||
|
||||
Assert.notNull(index, "No index defined for Alias");
|
||||
Assert.notNull(query.getAliasName(), "No alias defined");
|
||||
|
||||
IndicesAliasesRequest indicesAliasesRequest = requestFactory.indicesRemoveAliasesRequest(query, index);
|
||||
return restTemplate.execute(
|
||||
client -> client.indices().updateAliases(indicesAliasesRequest, RequestOptions.DEFAULT).isAcknowledged());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<AliasMetadata> doQueryForAlias(IndexCoordinates index) {
|
||||
|
||||
|
@ -23,7 +23,6 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.elasticsearch.action.admin.indices.alias.IndicesAliasesRequest;
|
||||
import org.elasticsearch.action.admin.indices.alias.IndicesAliasesRequestBuilder;
|
||||
import org.elasticsearch.action.admin.indices.alias.get.GetAliasesRequest;
|
||||
import org.elasticsearch.action.admin.indices.create.CreateIndexRequestBuilder;
|
||||
@ -59,7 +58,6 @@ import org.springframework.data.elasticsearch.core.index.PutTemplateRequest;
|
||||
import org.springframework.data.elasticsearch.core.index.Settings;
|
||||
import org.springframework.data.elasticsearch.core.index.TemplateData;
|
||||
import org.springframework.data.elasticsearch.core.mapping.IndexCoordinates;
|
||||
import org.springframework.data.elasticsearch.core.query.AliasQuery;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
@ -146,24 +144,6 @@ class DefaultTransportIndexOperations extends AbstractDefaultIndexOperations imp
|
||||
return mappings.iterator().next().value.get(IndexCoordinates.TYPE).getSourceAsMap();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean doAddAlias(AliasQuery query, IndexCoordinates index) {
|
||||
IndicesAliasesRequest.AliasActions aliasAction = requestFactory.aliasAction(query, index);
|
||||
return client.admin().indices().prepareAliases().addAliasAction(aliasAction).execute().actionGet().isAcknowledged();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
protected boolean doRemoveAlias(AliasQuery query, IndexCoordinates index) {
|
||||
|
||||
Assert.notNull(index, "No index defined for Alias");
|
||||
Assert.notNull(query.getAliasName(), "No alias defined");
|
||||
|
||||
IndicesAliasesRequestBuilder indicesAliasesRequestBuilder = requestFactory
|
||||
.indicesRemoveAliasesRequestBuilder(client, query, index);
|
||||
return indicesAliasesRequestBuilder.execute().actionGet().isAcknowledged();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<AliasMetadata> doQueryForAlias(IndexCoordinates index) {
|
||||
|
||||
|
@ -93,22 +93,6 @@ class EntityOperations {
|
||||
return AdaptibleMappedEntity.of(entity, context, conversionService, routingResolver);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine index name and type name from {@link Entity} with {@code index} and {@code type} overrides. Allows using
|
||||
* preferred values for index and type if provided, otherwise fall back to index and type defined on entity level.
|
||||
*
|
||||
* @param entity the entity to determine the index name. Can be {@literal null} if {@code index} and {@literal type}
|
||||
* are provided.
|
||||
* @param index index name override can be {@literal null}.
|
||||
* @param type index type override can be {@literal null}.
|
||||
* @return the {@link IndexCoordinates} containing index name and index type.
|
||||
* @deprecated since 4.1, use {@link EntityOperations#determineIndex(Entity, String)}
|
||||
*/
|
||||
@Deprecated
|
||||
IndexCoordinates determineIndex(Entity<?> entity, @Nullable String index, @Nullable String type) {
|
||||
return determineIndex(entity.getPersistentEntity(), index, type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine index name and type name from {@link Entity} with {@code index} and {@code type} overrides. Allows using
|
||||
* preferred values for index and type if provided, otherwise fall back to index and type defined on entity level.
|
||||
@ -122,24 +106,6 @@ class EntityOperations {
|
||||
return determineIndex(entity.getPersistentEntity(), index);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine index name and type name from {@link ElasticsearchPersistentEntity} with {@code index} and {@code type}
|
||||
* overrides. Allows using preferred values for index and type if provided, otherwise fall back to index and type
|
||||
* defined on entity level.
|
||||
*
|
||||
* @param persistentEntity the entity to determine the index name. Can be {@literal null} if {@code index} and
|
||||
* {@literal type} are provided.
|
||||
* @param index index name override can be {@literal null}.
|
||||
* @param type index type override can be {@literal null}.
|
||||
* @return the {@link IndexCoordinates} containing index name and index type.
|
||||
* @deprecated since 4.1, use {@link EntityOperations#determineIndex(ElasticsearchPersistentEntity, String)}
|
||||
*/
|
||||
@Deprecated
|
||||
IndexCoordinates determineIndex(ElasticsearchPersistentEntity<?> persistentEntity, @Nullable String index,
|
||||
@Nullable String type) {
|
||||
return determineIndex(persistentEntity, index);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine index name and type name from {@link ElasticsearchPersistentEntity} with {@code index} and {@code type}
|
||||
* overrides. Allows using preferred values for index and type if provided, otherwise fall back to index and type
|
||||
@ -234,25 +200,6 @@ class EntityOperations {
|
||||
*/
|
||||
interface AdaptibleEntity<T> extends Entity<T> {
|
||||
|
||||
/**
|
||||
* Returns whether the entity has a parent.
|
||||
*
|
||||
* @return {@literal true} if the entity has a parent that has an {@literal id}.
|
||||
* @deprecated since 4.1, not supported anymore by Elasticsearch
|
||||
*/
|
||||
@Deprecated
|
||||
boolean hasParent();
|
||||
|
||||
/**
|
||||
* Returns the parent Id. Can be {@literal null}.
|
||||
*
|
||||
* @return can be {@literal null}.
|
||||
* @deprecated since 4.1, not supported anymore by Elasticsearch
|
||||
*/
|
||||
@Deprecated
|
||||
@Nullable
|
||||
Object getParentId();
|
||||
|
||||
/**
|
||||
* Populates the identifier of the backing entity if it has an identifier property and there's no identifier
|
||||
* currently present.
|
||||
@ -339,24 +286,6 @@ class EntityOperations {
|
||||
return map.get(ID_FIELD);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.data.elasticsearch.core.EntityOperations.AdaptibleEntity#hasParent()
|
||||
*/
|
||||
@Override
|
||||
public boolean hasParent() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.data.elasticsearch.core.EntityOperations.AdaptibleEntity#getParentId()
|
||||
*/
|
||||
@Override
|
||||
public Entity<?> getParentId() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.data.elasticsearch.core.EntityOperations.AdaptibleEntity#populateIdIfNecessary(java.lang.Object)
|
||||
@ -581,19 +510,6 @@ class EntityOperations {
|
||||
new ConvertingPropertyAccessor<>(propertyAccessor, conversionService), conversionService, routingResolver);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasParent() {
|
||||
return getRequiredPersistentEntity().getParentIdProperty() != null;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public Object getParentId() {
|
||||
|
||||
ElasticsearchPersistentProperty parentProperty = getRequiredPersistentEntity().getParentIdProperty();
|
||||
return propertyAccessor.getProperty(parentProperty);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public T populateIdIfNecessary(@Nullable Object id) {
|
||||
|
@ -19,7 +19,6 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.elasticsearch.cluster.metadata.AliasMetadata;
|
||||
import org.springframework.data.elasticsearch.core.document.Document;
|
||||
import org.springframework.data.elasticsearch.core.index.AliasActions;
|
||||
import org.springframework.data.elasticsearch.core.index.AliasData;
|
||||
@ -30,7 +29,6 @@ import org.springframework.data.elasticsearch.core.index.PutTemplateRequest;
|
||||
import org.springframework.data.elasticsearch.core.index.Settings;
|
||||
import org.springframework.data.elasticsearch.core.index.TemplateData;
|
||||
import org.springframework.data.elasticsearch.core.mapping.IndexCoordinates;
|
||||
import org.springframework.data.elasticsearch.core.query.AliasQuery;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
@ -190,35 +188,6 @@ public interface IndexOperations {
|
||||
// endregion
|
||||
|
||||
// region aliases
|
||||
/**
|
||||
* Add an alias.
|
||||
*
|
||||
* @param query query defining the alias
|
||||
* @return true if the alias was created
|
||||
* @deprecated since 4.1 use {@link #alias(AliasActions)}
|
||||
*/
|
||||
@Deprecated
|
||||
boolean addAlias(AliasQuery query);
|
||||
|
||||
/**
|
||||
* Get the alias information for a specified index.
|
||||
*
|
||||
* @return alias information
|
||||
* @deprecated since 4.1, use {@link #getAliases(String...)} or {@link #getAliasesForIndex(String...)}.
|
||||
*/
|
||||
@Deprecated
|
||||
List<AliasMetadata> queryForAlias();
|
||||
|
||||
/**
|
||||
* Remove an alias.
|
||||
*
|
||||
* @param query query defining the alias
|
||||
* @return true if the alias was removed
|
||||
* @deprecated since 4.1 use {@link #alias(AliasActions)}
|
||||
*/
|
||||
@Deprecated
|
||||
boolean removeAlias(AliasQuery query);
|
||||
|
||||
/**
|
||||
* Executes the given {@link AliasActions}.
|
||||
*
|
||||
|
@ -24,7 +24,6 @@ import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.elasticsearch.action.DocWriteRequest;
|
||||
@ -136,37 +135,6 @@ class RequestFactory {
|
||||
}
|
||||
|
||||
// region alias
|
||||
@Deprecated
|
||||
public IndicesAliasesRequest.AliasActions aliasAction(AliasQuery query, IndexCoordinates index) {
|
||||
|
||||
Assert.notNull(index, "No index defined for Alias");
|
||||
Assert.notNull(query.getAliasName(), "No alias defined");
|
||||
|
||||
String[] indexNames = index.getIndexNames();
|
||||
IndicesAliasesRequest.AliasActions aliasAction = IndicesAliasesRequest.AliasActions.add()
|
||||
.alias(query.getAliasName()).indices(indexNames);
|
||||
|
||||
if (query.getFilterBuilder() != null) {
|
||||
aliasAction.filter(query.getFilterBuilder());
|
||||
} else if (query.getFilter() != null) {
|
||||
aliasAction.filter(query.getFilter());
|
||||
}
|
||||
|
||||
if (!StringUtils.isEmpty(query.getRouting())) {
|
||||
aliasAction.routing(query.getRouting());
|
||||
}
|
||||
|
||||
if (!StringUtils.isEmpty(query.getSearchRouting())) {
|
||||
aliasAction.searchRouting(query.getSearchRouting());
|
||||
}
|
||||
|
||||
if (!StringUtils.isEmpty(query.getIndexRouting())) {
|
||||
aliasAction.indexRouting(query.getIndexRouting());
|
||||
}
|
||||
|
||||
return aliasAction;
|
||||
}
|
||||
|
||||
public GetAliasesRequest getAliasesRequest(IndexCoordinates index) {
|
||||
|
||||
String[] indexNames = index.getIndexNames();
|
||||
@ -182,14 +150,6 @@ class RequestFactory {
|
||||
return getAliasesRequest;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public IndicesAliasesRequest indicesAddAliasesRequest(AliasQuery query, IndexCoordinates index) {
|
||||
IndicesAliasesRequest.AliasActions aliasAction = aliasAction(query, index);
|
||||
IndicesAliasesRequest request = new IndicesAliasesRequest();
|
||||
request.addAliasAction(aliasAction);
|
||||
return request;
|
||||
}
|
||||
|
||||
public IndicesAliasesRequest indicesAliasesRequest(AliasActions aliasActions) {
|
||||
|
||||
IndicesAliasesRequest request = new IndicesAliasesRequest();
|
||||
@ -257,27 +217,6 @@ class RequestFactory {
|
||||
indicesAliasesRequest(aliasActions).getAliasActions().forEach(requestBuilder::addAliasAction);
|
||||
return requestBuilder;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public IndicesAliasesRequest indicesRemoveAliasesRequest(AliasQuery query, IndexCoordinates index) {
|
||||
|
||||
String[] indexNames = index.getIndexNames();
|
||||
IndicesAliasesRequest.AliasActions aliasAction = IndicesAliasesRequest.AliasActions.remove() //
|
||||
.indices(indexNames) //
|
||||
.alias(query.getAliasName());
|
||||
|
||||
return Requests.indexAliasesRequest() //
|
||||
.addAliasAction(aliasAction);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
IndicesAliasesRequestBuilder indicesRemoveAliasesRequestBuilder(Client client, AliasQuery query,
|
||||
IndexCoordinates index) {
|
||||
|
||||
String indexName = index.getIndexName();
|
||||
return client.admin().indices().prepareAliases().removeAlias(indexName, query.getAliasName());
|
||||
}
|
||||
|
||||
// endregion
|
||||
|
||||
// region bulk
|
||||
@ -355,7 +294,8 @@ class RequestFactory {
|
||||
|
||||
// region index management
|
||||
|
||||
public CreateIndexRequest createIndexRequest(IndexCoordinates index, Map<String, Object> settings, @Nullable Document mapping) {
|
||||
public CreateIndexRequest createIndexRequest(IndexCoordinates index, Map<String, Object> settings,
|
||||
@Nullable Document mapping) {
|
||||
|
||||
Assert.notNull(index, "index must not be null");
|
||||
Assert.notNull(settings, "settings must not be null");
|
||||
@ -1276,10 +1216,10 @@ class RequestFactory {
|
||||
|
||||
private QueryRescorerBuilder getQueryRescorerBuilder(RescorerQuery rescorerQuery) {
|
||||
|
||||
QueryBuilder queryBuilder = getQuery(rescorerQuery.getQuery());
|
||||
Assert.notNull("queryBuilder", "Could not build query for rescorerQuery");
|
||||
QueryBuilder queryBuilder = getQuery(rescorerQuery.getQuery());
|
||||
Assert.notNull("queryBuilder", "Could not build query for rescorerQuery");
|
||||
|
||||
QueryRescorerBuilder builder = new QueryRescorerBuilder(queryBuilder);
|
||||
QueryRescorerBuilder builder = new QueryRescorerBuilder(queryBuilder);
|
||||
|
||||
if (rescorerQuery.getScoreMode() != ScoreMode.Default) {
|
||||
builder.setScoreMode(QueryRescoreMode.valueOf(rescorerQuery.getScoreMode().name()));
|
||||
|
@ -34,44 +34,6 @@ public final class DateTimeConverters {
|
||||
|
||||
private static DateTimeFormatter formatter = ISODateTimeFormat.dateTime().withZone(DateTimeZone.UTC);
|
||||
|
||||
/**
|
||||
* @deprecated since 4.1
|
||||
*/
|
||||
@Deprecated
|
||||
public enum JodaDateTimeConverter implements Converter<ReadableInstant, String> {
|
||||
INSTANCE;
|
||||
|
||||
@Override
|
||||
public String convert(ReadableInstant source) {
|
||||
if (source == null) {
|
||||
return null;
|
||||
}
|
||||
return formatter.print(source);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated since 4.1
|
||||
*/
|
||||
@Deprecated
|
||||
public enum JodaLocalDateTimeConverter implements Converter<LocalDateTime, String> {
|
||||
INSTANCE;
|
||||
|
||||
@Override
|
||||
public String convert(LocalDateTime source) {
|
||||
if (source == null) {
|
||||
return null;
|
||||
}
|
||||
return formatter.print(source.toDateTime(DateTimeZone.UTC));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated since 4.1
|
||||
*/
|
||||
@Deprecated
|
||||
public enum JavaDateConverter implements Converter<Date, String> {
|
||||
INSTANCE;
|
||||
|
||||
|
@ -11,26 +11,6 @@ import com.fasterxml.jackson.databind.SerializerProvider;
|
||||
import com.fasterxml.jackson.databind.module.SimpleModule;
|
||||
import org.springframework.data.geo.Point;
|
||||
|
||||
/**
|
||||
* @author Artur Konaczak
|
||||
* @deprecated since 4.1, not used anymore
|
||||
*/
|
||||
@Deprecated
|
||||
public class CustomGeoModule extends SimpleModule {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* Creates a new {@link org.springframework.data.elasticsearch.core.geo.CustomGeoModule} registering serializers and deserializers for spring data commons geo-spatial types.
|
||||
*/
|
||||
public CustomGeoModule() {
|
||||
|
||||
super("Spring Data Elasticsearch Geo", new Version(1, 0, 0, null, "org.springframework.data.elasticsearch", "spring-data-elasticsearch-geo"));
|
||||
addSerializer(Point.class, new PointSerializer());
|
||||
addDeserializer(Point.class, new PointDeserializer());
|
||||
}
|
||||
}
|
||||
|
||||
class PointSerializer extends JsonSerializer<Point> {
|
||||
@Override
|
||||
public void serialize(Point value, JsonGenerator gen, SerializerProvider serializers) throws IOException {
|
||||
|
@ -116,12 +116,6 @@ public class MappingBuilder {
|
||||
// Dynamic templates
|
||||
addDynamicTemplatesMapping(builder, entity);
|
||||
|
||||
// Parent
|
||||
String parentType = entity.getParentType();
|
||||
if (hasText(parentType)) {
|
||||
builder.startObject(FIELD_PARENT).field(FIELD_PARAM_TYPE, parentType).endObject();
|
||||
}
|
||||
|
||||
mapEntity(builder, entity, true, "", false, FieldType.Auto, null, entity.findAnnotation(DynamicMapping.class));
|
||||
|
||||
builder.endObject() // root object
|
||||
|
@ -56,20 +56,6 @@ public interface ElasticsearchPersistentEntity<T> extends PersistentEntity<T, El
|
||||
@Override
|
||||
ElasticsearchPersistentProperty getVersionProperty();
|
||||
|
||||
/**
|
||||
* @deprecated since 4.1, not supported anymore by Elasticsearch
|
||||
*/
|
||||
@Deprecated
|
||||
@Nullable
|
||||
String getParentType();
|
||||
|
||||
/**
|
||||
* @deprecated since 4.1, not supported anymore by Elasticsearch
|
||||
*/
|
||||
@Deprecated
|
||||
@Nullable
|
||||
ElasticsearchPersistentProperty getParentIdProperty();
|
||||
|
||||
@Nullable
|
||||
String settingPath();
|
||||
|
||||
|
@ -33,25 +33,11 @@ public interface ElasticsearchPersistentProperty extends PersistentProperty<Elas
|
||||
|
||||
/**
|
||||
* Returns the name to be used to store the property in the document.
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
String getFieldName();
|
||||
|
||||
/**
|
||||
* Returns whether the current property is a <em>potential</em> parent property of the owning
|
||||
* {@link ElasticsearchPersistentEntity}. This method is mainly used by {@link ElasticsearchPersistentEntity}
|
||||
* implementation to discover parent property candidates on {@link ElasticsearchPersistentEntity} creation you should
|
||||
* rather call {@link ElasticsearchPersistentEntity#getScoreProperty()} to determine whether the current property is
|
||||
* the parent property of that {@link ElasticsearchPersistentEntity} under consideration.
|
||||
*
|
||||
* @return
|
||||
* @since 3.1
|
||||
* @deprecated since 4.1, not supported anymore by Elasticsearch
|
||||
*/
|
||||
@Deprecated
|
||||
boolean isParentProperty();
|
||||
|
||||
/**
|
||||
* Returns whether the current property is a {@link SeqNoPrimaryTerm} property.
|
||||
*
|
||||
@ -113,7 +99,7 @@ public interface ElasticsearchPersistentProperty extends PersistentProperty<Elas
|
||||
|
||||
/**
|
||||
* calls {@link #getActualType()} but returns null when an exception is thrown
|
||||
*
|
||||
*
|
||||
* @since 4.1
|
||||
*/
|
||||
@Nullable
|
||||
|
@ -27,7 +27,6 @@ import org.springframework.dao.InvalidDataAccessApiUsageException;
|
||||
import org.springframework.data.elasticsearch.annotations.Document;
|
||||
import org.springframework.data.elasticsearch.annotations.Field;
|
||||
import org.springframework.data.elasticsearch.annotations.FieldType;
|
||||
import org.springframework.data.elasticsearch.annotations.Parent;
|
||||
import org.springframework.data.elasticsearch.annotations.Routing;
|
||||
import org.springframework.data.elasticsearch.annotations.Setting;
|
||||
import org.springframework.data.elasticsearch.core.index.Settings;
|
||||
@ -149,20 +148,6 @@ public class SimpleElasticsearchPersistentEntity<T> extends BasicPersistentEntit
|
||||
return settingsParameter.get().refreshIntervall;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
@Deprecated
|
||||
public String getParentType() {
|
||||
return parentType;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
@Deprecated
|
||||
public ElasticsearchPersistentProperty getParentIdProperty() {
|
||||
return parentIdProperty;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public VersionType getVersionType() {
|
||||
@ -180,24 +165,6 @@ public class SimpleElasticsearchPersistentEntity<T> extends BasicPersistentEntit
|
||||
public void addPersistentProperty(ElasticsearchPersistentProperty property) {
|
||||
super.addPersistentProperty(property);
|
||||
|
||||
if (property.isParentProperty()) {
|
||||
ElasticsearchPersistentProperty parentProperty = this.parentIdProperty;
|
||||
|
||||
if (parentProperty != null) {
|
||||
throw new MappingException(String.format(
|
||||
"Attempt to add parent property %s but already have property %s registered "
|
||||
+ "as parent property. Check your mapping configuration!",
|
||||
property.getField(), parentProperty.getField()));
|
||||
}
|
||||
|
||||
Parent parentAnnotation = property.findAnnotation(Parent.class);
|
||||
this.parentIdProperty = property;
|
||||
|
||||
if (parentAnnotation != null) {
|
||||
this.parentType = parentAnnotation.type();
|
||||
}
|
||||
}
|
||||
|
||||
if (property.isSeqNoPrimaryTermProperty()) {
|
||||
|
||||
ElasticsearchPersistentProperty seqNoPrimaryTermProperty = this.seqNoPrimaryTermProperty;
|
||||
|
@ -29,7 +29,6 @@ import org.springframework.data.elasticsearch.annotations.FieldType;
|
||||
import org.springframework.data.elasticsearch.annotations.GeoPointField;
|
||||
import org.springframework.data.elasticsearch.annotations.GeoShapeField;
|
||||
import org.springframework.data.elasticsearch.annotations.MultiField;
|
||||
import org.springframework.data.elasticsearch.annotations.Parent;
|
||||
import org.springframework.data.elasticsearch.core.completion.Completion;
|
||||
import org.springframework.data.elasticsearch.core.convert.ConversionException;
|
||||
import org.springframework.data.elasticsearch.core.convert.ElasticsearchDateConverter;
|
||||
@ -66,7 +65,6 @@ public class SimpleElasticsearchPersistentProperty extends
|
||||
|
||||
private static final List<String> SUPPORTED_ID_PROPERTY_NAMES = Arrays.asList("id", "document");
|
||||
|
||||
private final boolean isParent;
|
||||
private final boolean isId;
|
||||
private final boolean isSeqNoPrimaryTerm;
|
||||
private final @Nullable String annotatedFieldName;
|
||||
@ -85,7 +83,6 @@ public class SimpleElasticsearchPersistentProperty extends
|
||||
: fieldNamingStrategy;
|
||||
this.isId = super.isIdProperty()
|
||||
|| (SUPPORTED_ID_PROPERTY_NAMES.contains(getFieldName()) && !hasExplicitFieldName());
|
||||
this.isParent = isAnnotationPresent(Parent.class);
|
||||
this.isSeqNoPrimaryTerm = SeqNoPrimaryTerm.class.isAssignableFrom(getRawType());
|
||||
|
||||
boolean isField = isAnnotationPresent(Field.class);
|
||||
@ -94,10 +91,6 @@ public class SimpleElasticsearchPersistentProperty extends
|
||||
throw new MappingException(String.format("Version property %s must be of type Long!", property.getName()));
|
||||
}
|
||||
|
||||
if (isParent && !getType().equals(String.class)) {
|
||||
throw new MappingException(String.format("Parent property %s must be of type String!", property.getName()));
|
||||
}
|
||||
|
||||
if (isField && isAnnotationPresent(MultiField.class)) {
|
||||
throw new MappingException("@Field annotation must not be used on a @MultiField property.");
|
||||
}
|
||||
@ -283,11 +276,6 @@ public class SimpleElasticsearchPersistentProperty extends
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isParentProperty() {
|
||||
return isParent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSeqNoPrimaryTermProperty() {
|
||||
return isSeqNoPrimaryTerm;
|
||||
|
@ -1,81 +0,0 @@
|
||||
/*
|
||||
* Copyright 2013-2021 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.core.query;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.elasticsearch.index.query.QueryBuilder;
|
||||
import org.springframework.data.elasticsearch.core.index.AliasActions;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* @author Mohsin Husen
|
||||
* @author Peter-Josef Meisch
|
||||
* @deprecated since 4.1, use {@link org.springframework.data.elasticsearch.core.IndexOperations#alias(AliasActions)}.
|
||||
*/
|
||||
public class AliasBuilder {
|
||||
|
||||
@Nullable private String aliasName;
|
||||
@Nullable private QueryBuilder filterBuilder;
|
||||
@Nullable private Map<String, Object> filter;
|
||||
@Nullable private String searchRouting;
|
||||
@Nullable private String indexRouting;
|
||||
@Nullable private String routing;
|
||||
|
||||
public AliasBuilder withAliasName(String aliasName) {
|
||||
this.aliasName = aliasName;
|
||||
return this;
|
||||
}
|
||||
|
||||
public AliasBuilder withFilterBuilder(QueryBuilder filterBuilder) {
|
||||
this.filterBuilder = filterBuilder;
|
||||
return this;
|
||||
}
|
||||
|
||||
public AliasBuilder withFilter(Map<String, Object> filter) {
|
||||
this.filter = filter;
|
||||
return this;
|
||||
}
|
||||
|
||||
public AliasBuilder withSearchRouting(String searchRouting) {
|
||||
this.searchRouting = searchRouting;
|
||||
return this;
|
||||
}
|
||||
|
||||
public AliasBuilder withIndexRouting(String indexRouting) {
|
||||
this.indexRouting = indexRouting;
|
||||
return this;
|
||||
}
|
||||
|
||||
public AliasBuilder withRouting(String routing) {
|
||||
this.routing = routing;
|
||||
return this;
|
||||
}
|
||||
|
||||
public AliasQuery build() {
|
||||
|
||||
Assert.notNull(aliasName, "aliasName must not be null");
|
||||
|
||||
AliasQuery aliasQuery = new AliasQuery(aliasName);
|
||||
aliasQuery.setFilterBuilder(filterBuilder);
|
||||
aliasQuery.setFilter(filter);
|
||||
aliasQuery.setSearchRouting(searchRouting);
|
||||
aliasQuery.setIndexRouting(indexRouting);
|
||||
aliasQuery.setRouting(routing);
|
||||
return aliasQuery;
|
||||
}
|
||||
}
|
@ -1,97 +0,0 @@
|
||||
/*
|
||||
* Copyright 2013-2021 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.core.query;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.elasticsearch.index.query.QueryBuilder;
|
||||
import org.springframework.data.elasticsearch.core.index.AliasActions;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* AliasQuery is useful for creating new alias or deleting existing ones
|
||||
*
|
||||
* @author Mohsin Husen
|
||||
* @author Peter-Josef Meisch
|
||||
* @deprecated since 4.1, use {@link org.springframework.data.elasticsearch.core.IndexOperations#alias(AliasActions)}
|
||||
*/
|
||||
@Deprecated
|
||||
public class AliasQuery {
|
||||
|
||||
public AliasQuery(String aliasName) {
|
||||
|
||||
Assert.notNull(aliasName, "aliasName must not be null");
|
||||
|
||||
this.aliasName = aliasName;
|
||||
}
|
||||
|
||||
private String aliasName;
|
||||
@Nullable private QueryBuilder filterBuilder;
|
||||
@Nullable private Map<String, Object> filter;
|
||||
@Nullable private String searchRouting;
|
||||
@Nullable private String indexRouting;
|
||||
@Nullable private String routing;
|
||||
|
||||
public String getAliasName() {
|
||||
return aliasName;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public QueryBuilder getFilterBuilder() {
|
||||
return filterBuilder;
|
||||
}
|
||||
|
||||
public void setFilterBuilder(QueryBuilder filterBuilder) {
|
||||
this.filterBuilder = filterBuilder;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Map<String, Object> getFilter() {
|
||||
return filter;
|
||||
}
|
||||
|
||||
public void setFilter(Map<String, Object> filter) {
|
||||
this.filter = filter;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getSearchRouting() {
|
||||
return searchRouting;
|
||||
}
|
||||
|
||||
public void setSearchRouting(String searchRouting) {
|
||||
this.searchRouting = searchRouting;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getIndexRouting() {
|
||||
return indexRouting;
|
||||
}
|
||||
|
||||
public void setIndexRouting(String indexRouting) {
|
||||
this.indexRouting = indexRouting;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getRouting() {
|
||||
return routing;
|
||||
}
|
||||
|
||||
public void setRouting(String routing) {
|
||||
this.routing = routing;
|
||||
}
|
||||
}
|
@ -54,8 +54,6 @@ import org.springframework.util.StringUtils;
|
||||
public class Criteria {
|
||||
|
||||
public static final String CRITERIA_VALUE_SEPARATOR = " ";
|
||||
/** @deprecated since 4.1, use {@link #CRITERIA_VALUE_SEPARATOR} */
|
||||
@SuppressWarnings("SpellCheckingInspection") public static final String CRITERIA_VALUE_SEPERATOR = CRITERIA_VALUE_SEPARATOR;
|
||||
|
||||
private @Nullable Field field;
|
||||
private float boost = Float.NaN;
|
||||
@ -112,7 +110,7 @@ public class Criteria {
|
||||
/**
|
||||
* Creates a Criteria for the given field, sets it's criteriaChain to the given value and adds itself to the end of
|
||||
* the chain.
|
||||
*
|
||||
*
|
||||
* @param criteriaChain the chain to add to
|
||||
* @param fieldName field to create the Criteria for
|
||||
*/
|
||||
@ -123,7 +121,7 @@ public class Criteria {
|
||||
/**
|
||||
* Creates a Criteria for the given field, sets it's criteriaChain to the given value and adds itself to the end of
|
||||
* the chain.
|
||||
*
|
||||
*
|
||||
* @param criteriaChain the chain to add to
|
||||
* @param field field to create the Criteria for
|
||||
*/
|
||||
@ -174,16 +172,6 @@ public class Criteria {
|
||||
return Collections.unmodifiableSet(this.filterCriteriaEntries);
|
||||
}
|
||||
|
||||
/**
|
||||
* Conjunction to be used with this criteria (AND | OR)
|
||||
*
|
||||
* @deprecated since 4.1, use {@link #getOperator()}
|
||||
*/
|
||||
@Deprecated
|
||||
public String getConjunctionOperator() {
|
||||
return Operator.AND.name();
|
||||
}
|
||||
|
||||
public Operator getOperator() {
|
||||
return Operator.AND;
|
||||
}
|
||||
@ -332,7 +320,7 @@ public class Criteria {
|
||||
|
||||
/**
|
||||
* adds a Criteria as subCriteria
|
||||
*
|
||||
*
|
||||
* @param criteria the criteria to add, must not be {@literal null}
|
||||
* @return this object
|
||||
* @since 4.1
|
||||
@ -570,7 +558,7 @@ public class Criteria {
|
||||
/**
|
||||
* Add a {@link OperationKey#MATCHES} entry to the {@link #queryCriteriaEntries}. This will build a match query with
|
||||
* the OR operator.
|
||||
*
|
||||
*
|
||||
* @param value the value to match
|
||||
* @return this object
|
||||
* @since 4.1
|
||||
@ -733,7 +721,7 @@ public class Criteria {
|
||||
|
||||
/**
|
||||
* Adds a new filter CriteriaEntry for GEO_INTERSECTS.
|
||||
*
|
||||
*
|
||||
* @param geoShape the GeoJson shape
|
||||
* @return this object
|
||||
*/
|
||||
@ -869,11 +857,6 @@ public class Criteria {
|
||||
super(criteriaChain, field);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getConjunctionOperator() {
|
||||
return Operator.OR.name();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Operator getOperator() {
|
||||
return Operator.OR;
|
||||
@ -882,7 +865,7 @@ public class Criteria {
|
||||
|
||||
/**
|
||||
* a list of {@link Criteria} objects that belong to one query.
|
||||
*
|
||||
*
|
||||
* @since 4.1
|
||||
*/
|
||||
public static class CriteriaChain extends LinkedList<Criteria> {}
|
||||
|
@ -48,20 +48,6 @@ public class ElasticsearchStringQuery extends AbstractElasticsearchRepositoryQue
|
||||
|
||||
private final GenericConversionService conversionService = new GenericConversionService();
|
||||
|
||||
{
|
||||
if (!conversionService.canConvert(java.util.Date.class, String.class)) {
|
||||
conversionService.addConverter(DateTimeConverters.JavaDateConverter.INSTANCE);
|
||||
}
|
||||
if (ClassUtils.isPresent("org.joda.time.DateTimeZone", ElasticsearchStringQuery.class.getClassLoader())) {
|
||||
if (!conversionService.canConvert(org.joda.time.ReadableInstant.class, String.class)) {
|
||||
conversionService.addConverter(DateTimeConverters.JodaDateTimeConverter.INSTANCE);
|
||||
}
|
||||
if (!conversionService.canConvert(org.joda.time.LocalDateTime.class, String.class)) {
|
||||
conversionService.addConverter(DateTimeConverters.JodaLocalDateTimeConverter.INSTANCE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public ElasticsearchStringQuery(ElasticsearchQueryMethod queryMethod, ElasticsearchOperations elasticsearchOperations,
|
||||
String query) {
|
||||
super(queryMethod, elasticsearchOperations);
|
||||
|
@ -1,38 +0,0 @@
|
||||
/*
|
||||
* Copyright 2013-2021 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.repository.support;
|
||||
|
||||
import org.springframework.data.elasticsearch.core.ElasticsearchOperations;
|
||||
|
||||
/**
|
||||
* Elasticsearch specific repository implementation. Likely to be used as target within
|
||||
* {@link ElasticsearchRepositoryFactory}
|
||||
*
|
||||
* @author Rizwan Idrees
|
||||
* @author Mohsin Husen
|
||||
* @author Ryan Henszey
|
||||
* @author Sascha Woo
|
||||
* @author Peter-Josef Meisch
|
||||
* @deprecated since 4.1, derive from {@link SimpleElasticsearchRepository} instead
|
||||
*/
|
||||
@Deprecated
|
||||
public abstract class AbstractElasticsearchRepository<T, ID> extends SimpleElasticsearchRepository<T, ID> {
|
||||
|
||||
public AbstractElasticsearchRepository(ElasticsearchEntityInformation<T, ID> metadata,
|
||||
ElasticsearchOperations elasticsearchOperations) {
|
||||
super(metadata, elasticsearchOperations);
|
||||
}
|
||||
}
|
@ -41,11 +41,4 @@ public interface ElasticsearchEntityInformation<T, ID> extends EntityInformation
|
||||
|
||||
@Nullable
|
||||
VersionType getVersionType();
|
||||
|
||||
/**
|
||||
* @deprecated since 4.1, not supported anymore by Elasticsearch
|
||||
*/
|
||||
@Deprecated
|
||||
@Nullable
|
||||
String getParentId(T entity);
|
||||
}
|
||||
|
@ -74,16 +74,4 @@ public class MappingElasticsearchEntityInformation<T, ID> extends PersistentEnti
|
||||
return persistentEntity.getVersionType();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public String getParentId(T entity) {
|
||||
|
||||
ElasticsearchPersistentProperty parentProperty = persistentEntity.getParentIdProperty();
|
||||
try {
|
||||
return parentProperty != null ? (String) persistentEntity.getPropertyAccessor(entity).getProperty(parentProperty)
|
||||
: null;
|
||||
} catch (Exception e) {
|
||||
throw new IllegalStateException("failed to load parent ID: " + e, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -923,7 +923,7 @@ public class ReactiveElasticsearchClientIntegrationTests {
|
||||
Map<String, Object> jsonMap = Collections.singletonMap("properties",
|
||||
Collections.singletonMap("message", Collections.singletonMap("type", "text")));
|
||||
|
||||
client.indices().updateMapping(request -> request.indices(INDEX_I).source(jsonMap)) //
|
||||
client.indices().putMapping(request -> request.indices(INDEX_I).source(jsonMap)) //
|
||||
.as(StepVerifier::create) //
|
||||
.expectNext(true) //
|
||||
.verifyComplete();
|
||||
@ -935,7 +935,7 @@ public class ReactiveElasticsearchClientIntegrationTests {
|
||||
Map<String, Object> jsonMap = Collections.singletonMap("properties",
|
||||
Collections.singletonMap("message", Collections.singletonMap("type", "text")));
|
||||
|
||||
client.indices().updateMapping(request -> request.indices(INDEX_I).source(jsonMap)) //
|
||||
client.indices().putMapping(request -> request.indices(INDEX_I).source(jsonMap)) //
|
||||
.as(StepVerifier::create) //
|
||||
.verifyError(ElasticsearchStatusException.class);
|
||||
}
|
||||
|
@ -35,7 +35,6 @@ import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
@ -46,7 +45,6 @@ import org.assertj.core.util.Lists;
|
||||
import org.elasticsearch.action.search.SearchRequest;
|
||||
import org.elasticsearch.action.support.IndicesOptions;
|
||||
import org.elasticsearch.action.update.UpdateRequest;
|
||||
import org.elasticsearch.cluster.metadata.AliasMetadata;
|
||||
import org.elasticsearch.common.lucene.search.function.CombineFunction;
|
||||
import org.elasticsearch.common.lucene.search.function.FunctionScoreQuery;
|
||||
import org.elasticsearch.index.VersionType;
|
||||
@ -89,7 +87,6 @@ import org.springframework.data.elasticsearch.core.geo.GeoPoint;
|
||||
import org.springframework.data.elasticsearch.core.index.AliasAction;
|
||||
import org.springframework.data.elasticsearch.core.index.AliasActionParameters;
|
||||
import org.springframework.data.elasticsearch.core.index.AliasActions;
|
||||
import org.springframework.data.elasticsearch.core.index.AliasData;
|
||||
import org.springframework.data.elasticsearch.core.join.JoinField;
|
||||
import org.springframework.data.elasticsearch.core.mapping.IndexCoordinates;
|
||||
import org.springframework.data.elasticsearch.core.query.*;
|
||||
@ -2804,209 +2801,6 @@ public abstract class ElasticsearchTemplateTests {
|
||||
return indexQueries;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldAddAlias() {
|
||||
|
||||
// given
|
||||
String aliasName = "test-alias";
|
||||
AliasQuery aliasQuery = new AliasBuilder() //
|
||||
.withAliasName(aliasName) //
|
||||
.build();
|
||||
|
||||
// when
|
||||
indexOperations.addAlias(aliasQuery);
|
||||
|
||||
// then
|
||||
List<AliasMetadata> aliases = indexOperations.queryForAlias();
|
||||
assertThat(aliases).isNotNull();
|
||||
assertThat(aliases.get(0).alias()).isEqualTo(aliasName);
|
||||
}
|
||||
|
||||
@Test // DATAES-864
|
||||
void shouldAddAliasesWithAliasActions() {
|
||||
|
||||
AliasActions aliasActions = new AliasActions();
|
||||
aliasActions.add(new AliasAction.Add(AliasActionParameters.builder()
|
||||
.withIndices(indexOperations.getIndexCoordinates().getIndexNames()).withAliases("aliasA", "aliasB").build()));
|
||||
|
||||
indexOperations.alias(aliasActions);
|
||||
|
||||
List<AliasMetadata> aliases = indexOperations.queryForAlias();
|
||||
assertThat(aliases).hasSize(2);
|
||||
assertThat(aliases.stream().map(AliasMetadata::alias).collect(Collectors.toList())).contains("aliasA", "aliasB");
|
||||
}
|
||||
|
||||
@Test // DATAES-864
|
||||
void shouldRemoveAliasesWithAliasActions() {
|
||||
|
||||
AliasActions aliasActions = new AliasActions();
|
||||
aliasActions.add(new AliasAction.Add(AliasActionParameters.builder()
|
||||
.withIndices(indexOperations.getIndexCoordinates().getIndexNames()).withAliases("aliasA", "aliasB").build()));
|
||||
|
||||
indexOperations.alias(aliasActions);
|
||||
|
||||
aliasActions = new AliasActions();
|
||||
aliasActions.add(new AliasAction.Remove(AliasActionParameters.builder()
|
||||
.withIndices(indexOperations.getIndexCoordinates().getIndexNames()).withAliases("aliasA", "aliasB").build()));
|
||||
|
||||
indexOperations.alias(aliasActions);
|
||||
|
||||
List<AliasMetadata> aliases = indexOperations.queryForAlias();
|
||||
assertThat(aliases).hasSize(0);
|
||||
}
|
||||
|
||||
@Test // DATAES-864
|
||||
void shouldGetAliasData() {
|
||||
AliasActions aliasActions = new AliasActions();
|
||||
aliasActions.add(new AliasAction.Add(AliasActionParameters.builder()
|
||||
.withIndices(indexOperations.getIndexCoordinates().getIndexNames()).withAliases("aliasA", "aliasB").build()));
|
||||
|
||||
indexOperations.alias(aliasActions);
|
||||
|
||||
Map<String, Set<AliasData>> aliasDatas = indexOperations.getAliases("aliasA");
|
||||
|
||||
Set<AliasData> aliasData = aliasDatas.get(indexOperations.getIndexCoordinates().getIndexName());
|
||||
|
||||
assertThat(aliasData.stream().map(AliasData::getAlias)).containsExactly("aliasA");
|
||||
}
|
||||
|
||||
@Test // DATAES-70
|
||||
public void shouldAddAliasForVariousRoutingValues() {
|
||||
|
||||
// given
|
||||
String alias1 = "test-alias-1";
|
||||
String alias2 = "test-alias-2";
|
||||
|
||||
AliasQuery aliasQuery1 = new AliasBuilder() //
|
||||
.withAliasName(alias1) //
|
||||
.withIndexRouting("0") //
|
||||
.build();
|
||||
|
||||
AliasQuery aliasQuery2 = new AliasBuilder() //
|
||||
.withAliasName(alias2) //
|
||||
.withSearchRouting("1") //
|
||||
.build();
|
||||
|
||||
// when
|
||||
IndexCoordinates index = IndexCoordinates.of(INDEX_NAME_SAMPLE_ENTITY);
|
||||
indexOperations.addAlias(aliasQuery1);
|
||||
indexOperations.addAlias(aliasQuery2);
|
||||
|
||||
String documentId = nextIdAsString();
|
||||
SampleEntity entity = SampleEntity.builder() //
|
||||
.id(documentId) //
|
||||
.message("some message") //
|
||||
.version(System.currentTimeMillis()) //
|
||||
.build();
|
||||
|
||||
IndexQuery indexQuery = new IndexQueryBuilder() //
|
||||
.withId(entity.getId()) //
|
||||
.withObject(entity) //
|
||||
.build();
|
||||
|
||||
operations.index(indexQuery, IndexCoordinates.of(alias1));
|
||||
|
||||
// then
|
||||
List<AliasMetadata> aliasMetaData = indexOperations.queryForAlias();
|
||||
assertThat(aliasMetaData).isNotEmpty();
|
||||
|
||||
AliasMetadata aliasMetaData1 = aliasMetaData.get(0);
|
||||
assertThat(aliasMetaData1).isNotNull();
|
||||
if (aliasMetaData1.alias().equals(alias1)) {
|
||||
assertThat(aliasMetaData1.indexRouting()).isEqualTo("0");
|
||||
} else if (aliasMetaData1.alias().equals(alias2)) {
|
||||
assertThat(aliasMetaData1.searchRouting()).isEqualTo("1");
|
||||
} else {
|
||||
fail("unknown alias");
|
||||
}
|
||||
|
||||
AliasMetadata aliasMetaData2 = aliasMetaData.get(1);
|
||||
assertThat(aliasMetaData2).isNotNull();
|
||||
if (aliasMetaData2.alias().equals(alias1)) {
|
||||
assertThat(aliasMetaData2.indexRouting()).isEqualTo("0");
|
||||
} else if (aliasMetaData2.alias().equals(alias2)) {
|
||||
assertThat(aliasMetaData2.searchRouting()).isEqualTo("1");
|
||||
} else {
|
||||
fail("unknown alias");
|
||||
}
|
||||
|
||||
// cleanup
|
||||
indexOperations.removeAlias(aliasQuery1);
|
||||
indexOperations.removeAlias(aliasQuery2);
|
||||
}
|
||||
|
||||
@Test // DATAES-70
|
||||
public void shouldAddAliasWithGivenRoutingValue() {
|
||||
|
||||
// given
|
||||
String alias = "test-alias";
|
||||
IndexCoordinates index = IndexCoordinates.of(INDEX_NAME_SAMPLE_ENTITY);
|
||||
|
||||
AliasQuery aliasQuery = new AliasBuilder() //
|
||||
.withAliasName(alias) //
|
||||
.withRouting("0") //
|
||||
.build();
|
||||
|
||||
// when
|
||||
indexOperations.addAlias(aliasQuery);
|
||||
|
||||
String documentId = nextIdAsString();
|
||||
SampleEntity sampleEntity = SampleEntity.builder() //
|
||||
.id(documentId) //
|
||||
.message("some message") //
|
||||
.version(System.currentTimeMillis()) //
|
||||
.build();
|
||||
|
||||
IndexQuery indexQuery = new IndexQueryBuilder() //
|
||||
.withId(sampleEntity.getId()) //
|
||||
.withObject(sampleEntity) //
|
||||
.build();
|
||||
|
||||
operations.index(indexQuery, IndexCoordinates.of(alias));
|
||||
operations.indexOps(IndexCoordinates.of(INDEX_NAME_SAMPLE_ENTITY)).refresh();
|
||||
|
||||
NativeSearchQuery query = new NativeSearchQueryBuilder() //
|
||||
.withQuery(matchAllQuery()) //
|
||||
.build();
|
||||
|
||||
long count = operations.count(query, IndexCoordinates.of(alias));
|
||||
|
||||
// then
|
||||
List<AliasMetadata> aliases = indexOperations.queryForAlias();
|
||||
assertThat(aliases).isNotNull();
|
||||
AliasMetadata aliasMetaData = aliases.get(0);
|
||||
assertThat(aliasMetaData.alias()).isEqualTo(alias);
|
||||
assertThat(aliasMetaData.searchRouting()).isEqualTo("0");
|
||||
assertThat(aliasMetaData.indexRouting()).isEqualTo("0");
|
||||
assertThat(count).isEqualTo(1);
|
||||
|
||||
// cleanup
|
||||
indexOperations.removeAlias(aliasQuery);
|
||||
}
|
||||
|
||||
@Test // DATAES-541
|
||||
public void shouldRemoveAlias() {
|
||||
|
||||
// given
|
||||
String aliasName = "test-alias";
|
||||
IndexCoordinates index = IndexCoordinates.of(INDEX_NAME_SAMPLE_ENTITY);
|
||||
|
||||
AliasQuery aliasQuery = new AliasBuilder() //
|
||||
.withAliasName(aliasName) //
|
||||
.build();
|
||||
|
||||
// when
|
||||
indexOperations.addAlias(aliasQuery);
|
||||
List<AliasMetadata> aliases = indexOperations.queryForAlias();
|
||||
assertThat(aliases).isNotNull();
|
||||
assertThat(aliases.get(0).alias()).isEqualTo(aliasName);
|
||||
|
||||
// then
|
||||
indexOperations.removeAlias(aliasQuery);
|
||||
aliases = indexOperations.queryForAlias();
|
||||
assertThat(aliases).isEmpty();
|
||||
}
|
||||
|
||||
@Document(indexName = INDEX_2_NAME)
|
||||
class ResultAggregator {
|
||||
|
||||
|
@ -31,31 +31,6 @@ import org.junit.jupiter.api.Test;
|
||||
*/
|
||||
public class DateTimeConvertersTests {
|
||||
|
||||
@Test
|
||||
public void testJodaDateTimeConverterWithNullValue() {
|
||||
assertThat(DateTimeConverters.JodaDateTimeConverter.INSTANCE.convert(null)).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testJodaDateTimeConverter() {
|
||||
DateTime dateTime = new DateTime(2013, 1, 24, 6, 35, 0, DateTimeZone.UTC);
|
||||
assertThat(DateTimeConverters.JodaDateTimeConverter.INSTANCE.convert(dateTime))
|
||||
.isEqualTo("2013-01-24T06:35:00.000Z");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testJodaLocalDateTimeConverterWithNullValue() {
|
||||
assertThat(DateTimeConverters.JodaLocalDateTimeConverter.INSTANCE.convert(null)).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testJodaLocalDateTimeConverter() {
|
||||
LocalDateTime dateTime = new LocalDateTime(new DateTime(2013, 1, 24, 6, 35, 0, DateTimeZone.UTC).getMillis(),
|
||||
DateTimeZone.UTC);
|
||||
assertThat(DateTimeConverters.JodaLocalDateTimeConverter.INSTANCE.convert(dateTime))
|
||||
.isEqualTo("2013-01-24T06:35:00.000Z");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testJavaDateConverterWithNullValue() {
|
||||
assertThat(DateTimeConverters.JavaDateConverter.INSTANCE.convert(null)).isNull();
|
||||
|
@ -5,13 +5,9 @@
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/data/elasticsearch https://www.springframework.org/schema/data/elasticsearch/spring-elasticsearch.xsd
|
||||
http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd">
|
||||
|
||||
<elasticsearch:node-client id="client" local="true"
|
||||
cluster-name="#{T(java.util.UUID).randomUUID().toString()}" http-enabled="false"
|
||||
path-data="target/elasticsearchTestData" path-home="src/test/resources/test-home-dir"/>
|
||||
|
||||
<bean name="elasticsearchTemplate"
|
||||
class="org.springframework.data.elasticsearch.core.ElasticsearchTemplate">
|
||||
<constructor-arg name="client" ref="client"/>
|
||||
<constructor-arg name="client" ref="transportClient"/>
|
||||
</bean>
|
||||
|
||||
<elasticsearch:transport-client id="transportClient"/>
|
||||
@ -19,7 +15,7 @@
|
||||
<elasticsearch:repositories
|
||||
base-package="org.springframework.data.elasticsearch.config.namespace"
|
||||
consider-nested-repositories="true" />
|
||||
|
||||
|
||||
<elasticsearch:rest-client id="restClient"/>
|
||||
|
||||
</beans>
|
||||
|
Loading…
x
Reference in New Issue
Block a user