Search in sources :

Example 6 with PutTemplateRequest

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

the class ReactiveIndexOperationsTest method shouldPutTemplate.

// DATAES-612
@Test
void shouldPutTemplate() {
    ReactiveIndexOperations indexOps = operations.indexOps(Entity.class);
    org.springframework.data.elasticsearch.core.document.Document mapping = indexOps.createMapping(TemplateClass.class).block();
    Settings settings = indexOps.createSettings(TemplateClass.class).block();
    AliasActions aliasActions = new AliasActions(new AliasAction.Add(AliasActionParameters.builderForTemplate().withAliases("alias1", "alias2").build()));
    PutTemplateRequest putTemplateRequest = // 
    PutTemplateRequest.builder("test-template", "log-*").withSettings(// 
    settings).withMappings(// 
    mapping).withAliasActions(// 
    aliasActions).withOrder(// 
    11).withVersion(// 
    42).build();
    Boolean acknowledged = indexOps.putTemplate(putTemplateRequest).block();
    assertThat(acknowledged).isTrue();
}
Also used : PutTemplateRequest(org.springframework.data.elasticsearch.core.index.PutTemplateRequest) AliasAction(org.springframework.data.elasticsearch.core.index.AliasAction) Settings(org.springframework.data.elasticsearch.core.index.Settings) AliasActions(org.springframework.data.elasticsearch.core.index.AliasActions) Test(org.junit.jupiter.api.Test) SpringIntegrationTest(org.springframework.data.elasticsearch.junit.jupiter.SpringIntegrationTest)

Aggregations

PutTemplateRequest (org.springframework.data.elasticsearch.core.index.PutTemplateRequest)6 Test (org.junit.jupiter.api.Test)5 AliasActions (org.springframework.data.elasticsearch.core.index.AliasActions)4 SpringIntegrationTest (org.springframework.data.elasticsearch.junit.jupiter.SpringIntegrationTest)4 AliasAction (org.springframework.data.elasticsearch.core.index.AliasAction)3 ExistsTemplateRequest (org.springframework.data.elasticsearch.core.index.ExistsTemplateRequest)3 Settings (org.springframework.data.elasticsearch.core.index.Settings)3 PutIndexTemplateRequest (org.elasticsearch.client.indices.PutIndexTemplateRequest)2 AliasData (org.springframework.data.elasticsearch.core.index.AliasData)2 DeleteTemplateRequest (org.springframework.data.elasticsearch.core.index.DeleteTemplateRequest)2 GetTemplateRequest (org.springframework.data.elasticsearch.core.index.GetTemplateRequest)2 TemplateData (org.springframework.data.elasticsearch.core.index.TemplateData)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