use of org.springframework.data.elasticsearch.core.IndexOperations in project spring-data-elasticsearch by spring-projects.
the class IndexTemplateIntegrationTests method shouldDeleteTemplate.
// DATAES-612
@Test
void shouldDeleteTemplate() {
IndexOperations indexOps = operations.indexOps(IndexCoordinates.of("dont-care"));
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);
assertThat(acknowledged).isTrue();
boolean exists = indexOps.existsTemplate(existsTemplateRequest);
assertThat(exists).isTrue();
acknowledged = indexOps.deleteTemplate(new DeleteTemplateRequest(templateName));
assertThat(acknowledged).isTrue();
exists = indexOps.existsTemplate(existsTemplateRequest);
assertThat(exists).isFalse();
}
use of org.springframework.data.elasticsearch.core.IndexOperations in project spring-data-elasticsearch by spring-projects.
the class MappingBuilderIntegrationTests method shouldWriteCorrectTermVectorValues.
// DATAES-991
@Test
@DisplayName("should write correct TermVector values")
void shouldWriteCorrectTermVectorValues() {
IndexOperations indexOps = operations.indexOps(TermVectorFieldEntity.class);
indexOps.create();
indexOps.putMapping();
}
use of org.springframework.data.elasticsearch.core.IndexOperations in project spring-data-elasticsearch by spring-projects.
the class MappingBuilderIntegrationTests method shouldUseKeywordNormalizer.
// DATAES-492
@Test
@SuppressWarnings("rawtypes")
public void shouldUseKeywordNormalizer() {
// given
IndexOperations indexOps = operations.indexOps(NormalizerEntity.class);
indexOps.create();
indexOps.putMapping();
// when
Map mapping = indexOps.getMapping();
Map properties = (Map) mapping.get("properties");
Map fieldName = (Map) properties.get("name");
Map fieldDescriptionLowerCase = (Map) ((Map) ((Map) properties.get("description")).get("fields")).get("lower_case");
// then
assertThat(fieldName.get("type")).isEqualTo("keyword");
assertThat(fieldName.get("normalizer")).isEqualTo("lower_case_normalizer");
assertThat(fieldDescriptionLowerCase.get("type")).isEqualTo("keyword");
assertThat(fieldDescriptionLowerCase.get("normalizer")).isEqualTo("lower_case_normalizer");
}
use of org.springframework.data.elasticsearch.core.IndexOperations in project spring-data-elasticsearch by spring-projects.
the class MappingBuilderIntegrationTests method shouldUseCopyTo.
// DATAES-503
@Test
@SuppressWarnings("rawtypes")
public void shouldUseCopyTo() {
// given
IndexOperations indexOps = operations.indexOps(CopyToEntity.class);
indexOps.create();
indexOps.putMapping(CopyToEntity.class);
// when
Map mapping = indexOps.getMapping();
Map properties = (Map) mapping.get("properties");
Map fieldFirstName = (Map) properties.get("firstName");
Map fieldLastName = (Map) properties.get("lastName");
// then
List<String> copyToValue = Collections.singletonList("name");
assertThat(fieldFirstName.get("copy_to")).isEqualTo(copyToValue);
assertThat(fieldLastName.get("copy_to")).isEqualTo(copyToValue);
}
use of org.springframework.data.elasticsearch.core.IndexOperations in project spring-data-elasticsearch by spring-projects.
the class MappingBuilderIntegrationTests method shouldWriteRuntimeFields.
// #1816
@Test
@DisplayName("should write runtime fields")
void shouldWriteRuntimeFields() {
IndexOperations indexOps = operations.indexOps(RuntimeFieldEntity.class);
indexOps.create();
indexOps.putMapping();
}
Aggregations