use of org.springframework.data.elasticsearch.core.IndexOperations in project spring-data-elasticsearch by spring-projects.
the class ImmutableElasticsearchRepositoryTests method tearDown.
@AfterEach
void tearDown() {
IndexOperations indexOperations = operations.indexOps(ImmutableEntity.class);
indexOperations.delete();
}
use of org.springframework.data.elasticsearch.core.IndexOperations in project spring-data-elasticsearch by spring-projects.
the class FieldNamingStrategyIntegrationTests method setUp.
@BeforeEach
void setUp() {
IndexOperations indexOps = this.operations.indexOps(Entity.class);
indexOps.delete();
indexOps.create();
indexOps.putMapping();
}
use of org.springframework.data.elasticsearch.core.IndexOperations in project spring-data-elasticsearch by spring-projects.
the class IndexOperationIntegrationTests method shouldReturnInformationList.
// #1646, #1718
@Test
@DisplayName("should return a list of info for specific index")
void shouldReturnInformationList() throws JSONException {
IndexOperations indexOps = operations.indexOps(EntityWithSettingsAndMappings.class);
String aliasName = "testindexinformationindex";
indexOps.createWithMapping();
AliasActionParameters parameters = AliasActionParameters.builder().withAliases(aliasName).withIndices(INDEX_NAME).withIsHidden(false).withIsWriteIndex(false).withRouting("indexrouting").withSearchRouting("searchrouting").build();
indexOps.alias(new AliasActions(new AliasAction.Add(parameters)));
List<IndexInformation> indexInformationList = indexOps.getInformation();
IndexInformation indexInformation = indexInformationList.get(0);
assertThat(indexInformationList.size()).isEqualTo(1);
assertThat(indexInformation.getName()).isEqualTo(INDEX_NAME);
assertThat(indexInformation.getSettings().get("index.number_of_shards")).isEqualTo("1");
assertThat(indexInformation.getSettings().get("index.number_of_replicas")).isEqualTo("0");
assertThat(indexInformation.getSettings().get("index.analysis.analyzer.emailAnalyzer.type")).isEqualTo("custom");
assertThat(indexInformation.getAliases()).hasSize(1);
AliasData aliasData = indexInformation.getAliases().get(0);
assertThat(aliasData.getAlias()).isEqualTo(aliasName);
assertThat(aliasData.isHidden()).isEqualTo(false);
assertThat(aliasData.isWriteIndex()).isEqualTo(false);
assertThat(aliasData.getIndexRouting()).isEqualTo("indexrouting");
assertThat(aliasData.getSearchRouting()).isEqualTo("searchrouting");
String expectedMappings = //
"{\n" + //
" \"properties\": {\n" + //
" \"email\": {\n" + //
" \"type\": \"text\",\n" + //
" \"analyzer\": \"emailAnalyzer\"\n" + //
" }\n" + //
" }\n" + //
"}";
JSONAssert.assertEquals(expectedMappings, indexInformation.getMapping().toJson(), false);
}
use of org.springframework.data.elasticsearch.core.IndexOperations in project spring-data-elasticsearch by spring-projects.
the class IndexTemplateIntegrationTests method shouldCreateTemplate.
// DATAES-612
@Test
void shouldCreateTemplate() {
IndexOperations indexOps = operations.indexOps(IndexCoordinates.of("dont-care"));
org.springframework.data.elasticsearch.core.document.Document mapping = indexOps.createMapping(TemplateClass.class);
Settings settings = indexOps.createSettings(TemplateClass.class);
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).build();
boolean acknowledged = indexOps.putTemplate(putTemplateRequest);
assertThat(acknowledged).isTrue();
}
use of org.springframework.data.elasticsearch.core.IndexOperations in project spring-data-elasticsearch by spring-projects.
the class IndexTemplateIntegrationTests method shouldCheckExists.
// DATAES-612
@Test
void shouldCheckExists() {
IndexOperations indexOps = operations.indexOps(IndexCoordinates.of("dont-care"));
String templateName = "template" + UUID.randomUUID().toString();
ExistsTemplateRequest existsTemplateRequest = new ExistsTemplateRequest(templateName);
boolean exists = indexOps.existsTemplate(existsTemplateRequest);
assertThat(exists).isFalse();
PutTemplateRequest putTemplateRequest = //
PutTemplateRequest.builder(templateName, "log-*").withOrder(//
11).withVersion(//
42).build();
boolean acknowledged = indexOps.putTemplate(putTemplateRequest);
assertThat(acknowledged).isTrue();
exists = indexOps.existsTemplate(existsTemplateRequest);
assertThat(exists).isTrue();
}
Aggregations