Search in sources :

Example 1 with DeleteTemplateRequest

use of org.springframework.data.elasticsearch.core.index.DeleteTemplateRequest in project spring-data-elasticsearch by spring-projects.

the class ReactiveIndexOperationsTest method shouldDeleteTemplate.

// DATAES-612
@Test
void shouldDeleteTemplate() {
    ReactiveIndexOperations indexOps = operations.indexOps(Entity.class);
    String templateName = "template" + UUID.randomUUID().toString();
    ExistsTemplateRequest existsTemplateRequest = new ExistsTemplateRequest(templateName);
    PutTemplateRequest putTemplateRequest = // 
    PutTemplateRequest.builder(templateName, "log-*").withOrder(// 
    11).withVersion(// 
    42).build();
    boolean acknowledged = indexOps.putTemplate(putTemplateRequest).block();
    assertThat(acknowledged).isTrue();
    boolean exists = indexOps.existsTemplate(existsTemplateRequest).block();
    assertThat(exists).isTrue();
    acknowledged = indexOps.deleteTemplate(new DeleteTemplateRequest(templateName)).block();
    assertThat(acknowledged).isTrue();
    exists = indexOps.existsTemplate(existsTemplateRequest).block();
    assertThat(exists).isFalse();
}
Also used : PutTemplateRequest(org.springframework.data.elasticsearch.core.index.PutTemplateRequest) ExistsTemplateRequest(org.springframework.data.elasticsearch.core.index.ExistsTemplateRequest) DeleteTemplateRequest(org.springframework.data.elasticsearch.core.index.DeleteTemplateRequest) Test(org.junit.jupiter.api.Test) SpringIntegrationTest(org.springframework.data.elasticsearch.junit.jupiter.SpringIntegrationTest)

Example 2 with DeleteTemplateRequest

use of org.springframework.data.elasticsearch.core.index.DeleteTemplateRequest in project spring-data-elasticsearch by spring-projects.

the class ReactiveIndexTemplate method deleteTemplate.

@Override
public Mono<Boolean> deleteTemplate(DeleteTemplateRequest deleteTemplateRequest) {
    Assert.notNull(deleteTemplateRequest, "deleteTemplateRequest must not be null");
    DeleteIndexTemplateRequest deleteIndexTemplateRequest = requestFactory.deleteIndexTemplateRequest(deleteTemplateRequest);
    return Mono.from(operations.executeWithIndicesClient(client -> client.deleteTemplate(deleteIndexTemplateRequest)));
}
Also used : AnnotatedElementUtils(org.springframework.core.annotation.AnnotatedElementUtils) GetMappingsRequest(org.elasticsearch.client.indices.GetMappingsRequest) AliasActions(org.springframework.data.elasticsearch.core.index.AliasActions) Settings(org.springframework.data.elasticsearch.core.index.Settings) PutIndexTemplateRequest(org.elasticsearch.client.indices.PutIndexTemplateRequest) InvalidDataAccessApiUsageException(org.springframework.dao.InvalidDataAccessApiUsageException) ElasticsearchPersistentEntity(org.springframework.data.elasticsearch.core.mapping.ElasticsearchPersistentEntity) Mapping(org.springframework.data.elasticsearch.annotations.Mapping) ElasticsearchConverter(org.springframework.data.elasticsearch.core.convert.ElasticsearchConverter) GetAliasesResponse(org.elasticsearch.client.GetAliasesResponse) Map(java.util.Map) Nullable(org.springframework.lang.Nullable) Requests(org.elasticsearch.client.Requests) AliasData(org.springframework.data.elasticsearch.core.index.AliasData) ReactiveMappingBuilder(org.springframework.data.elasticsearch.core.index.ReactiveMappingBuilder) TemplateData(org.springframework.data.elasticsearch.core.index.TemplateData) IndexTemplatesExistRequest(org.elasticsearch.client.indices.IndexTemplatesExistRequest) DeleteTemplateRequest(org.springframework.data.elasticsearch.core.index.DeleteTemplateRequest) ExistsTemplateRequest(org.springframework.data.elasticsearch.core.index.ExistsTemplateRequest) DeleteIndexRequest(org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest) CreateIndexRequest(org.elasticsearch.client.indices.CreateIndexRequest) IndexCoordinates(org.springframework.data.elasticsearch.core.mapping.IndexCoordinates) GetAliasesRequest(org.elasticsearch.action.admin.indices.alias.get.GetAliasesRequest) GetIndexTemplatesRequest(org.elasticsearch.client.indices.GetIndexTemplatesRequest) Set(java.util.Set) IndicesAliasesRequest(org.elasticsearch.action.admin.indices.alias.IndicesAliasesRequest) Mono(reactor.core.publisher.Mono) PutTemplateRequest(org.springframework.data.elasticsearch.core.index.PutTemplateRequest) DeleteIndexTemplateRequest(org.elasticsearch.action.admin.indices.template.delete.DeleteIndexTemplateRequest) Flux(reactor.core.publisher.Flux) GetTemplateRequest(org.springframework.data.elasticsearch.core.index.GetTemplateRequest) NoSuchIndexException(org.springframework.data.elasticsearch.NoSuchIndexException) Log(org.apache.commons.logging.Log) LogFactory(org.apache.commons.logging.LogFactory) GetSettingsRequest(org.elasticsearch.action.admin.indices.settings.get.GetSettingsRequest) GetIndexRequest(org.elasticsearch.client.indices.GetIndexRequest) Document(org.springframework.data.elasticsearch.core.document.Document) StringUtils(org.springframework.util.StringUtils) Assert(org.springframework.util.Assert) DeleteIndexTemplateRequest(org.elasticsearch.action.admin.indices.template.delete.DeleteIndexTemplateRequest)

Aggregations

DeleteTemplateRequest (org.springframework.data.elasticsearch.core.index.DeleteTemplateRequest)2 ExistsTemplateRequest (org.springframework.data.elasticsearch.core.index.ExistsTemplateRequest)2 PutTemplateRequest (org.springframework.data.elasticsearch.core.index.PutTemplateRequest)2 Map (java.util.Map)1 Set (java.util.Set)1 Log (org.apache.commons.logging.Log)1 LogFactory (org.apache.commons.logging.LogFactory)1 IndicesAliasesRequest (org.elasticsearch.action.admin.indices.alias.IndicesAliasesRequest)1 GetAliasesRequest (org.elasticsearch.action.admin.indices.alias.get.GetAliasesRequest)1 DeleteIndexRequest (org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest)1 GetSettingsRequest (org.elasticsearch.action.admin.indices.settings.get.GetSettingsRequest)1 DeleteIndexTemplateRequest (org.elasticsearch.action.admin.indices.template.delete.DeleteIndexTemplateRequest)1 GetAliasesResponse (org.elasticsearch.client.GetAliasesResponse)1 Requests (org.elasticsearch.client.Requests)1 CreateIndexRequest (org.elasticsearch.client.indices.CreateIndexRequest)1 GetIndexRequest (org.elasticsearch.client.indices.GetIndexRequest)1 GetIndexTemplatesRequest (org.elasticsearch.client.indices.GetIndexTemplatesRequest)1 GetMappingsRequest (org.elasticsearch.client.indices.GetMappingsRequest)1 IndexTemplatesExistRequest (org.elasticsearch.client.indices.IndexTemplatesExistRequest)1 PutIndexTemplateRequest (org.elasticsearch.client.indices.PutIndexTemplateRequest)1