Search in sources :

Example 6 with Settings

use of org.springframework.data.elasticsearch.core.index.Settings 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

Settings (org.springframework.data.elasticsearch.core.index.Settings)6 AliasData (org.springframework.data.elasticsearch.core.index.AliasData)4 ArrayList (java.util.ArrayList)2 Test (org.junit.jupiter.api.Test)2 Document (org.springframework.data.elasticsearch.core.document.Document)2 AliasAction (org.springframework.data.elasticsearch.core.index.AliasAction)2 AliasActions (org.springframework.data.elasticsearch.core.index.AliasActions)2 PutTemplateRequest (org.springframework.data.elasticsearch.core.index.PutTemplateRequest)2 SpringIntegrationTest (org.springframework.data.elasticsearch.junit.jupiter.SpringIntegrationTest)2 LinkedHashMap (java.util.LinkedHashMap)1 IndexTemplateMetadata (org.elasticsearch.client.indices.IndexTemplateMetadata)1 AliasMetadata (org.elasticsearch.cluster.metadata.AliasMetadata)1 GetTemplateRequest (org.springframework.data.elasticsearch.core.index.GetTemplateRequest)1 TemplateData (org.springframework.data.elasticsearch.core.index.TemplateData)1 Nullable (org.springframework.lang.Nullable)1