use of org.springframework.data.elasticsearch.core.IndexOperations in project spring-data-elasticsearch by spring-projects.
the class MappingBuilderIntegrationTests method shouldHandleReverseRelationship.
// DATAES-260 - StackOverflow when two reverse relationship.
@Test
public void shouldHandleReverseRelationship() {
// given
IndexOperations indexOpsUser = operations.indexOps(User.class);
indexOpsUser.create();
indexOpsUser.putMapping(User.class);
indexNameProvider.increment();
IndexOperations indexOpsGroup = operations.indexOps(Group.class);
indexOpsGroup.create();
indexOpsGroup.putMapping(Group.class);
// when
// then
}
use of org.springframework.data.elasticsearch.core.IndexOperations in project spring-data-elasticsearch by spring-projects.
the class MappingBuilderIntegrationTests method shouldAddSampleInheritedEntityDocumentToIndex.
// DATAES-76
@Test
public void shouldAddSampleInheritedEntityDocumentToIndex() {
// given
IndexOperations indexOps = operations.indexOps(SampleInheritedEntity.class);
// when
indexOps.create();
indexOps.putMapping(SampleInheritedEntity.class);
Date createdDate = new Date();
String message = "msg";
String id = "abc";
operations.index(new SampleInheritedEntityBuilder(id).createdDate(createdDate).message(message).buildIndex(), IndexCoordinates.of(indexNameProvider.indexName()));
NativeSearchQuery searchQuery = new NativeSearchQueryBuilder().withQuery(matchAllQuery()).build();
SearchHits<SampleInheritedEntity> result = operations.search(searchQuery, SampleInheritedEntity.class);
// then
assertThat(result).hasSize(1);
SampleInheritedEntity entry = result.getSearchHit(0).getContent();
assertThat(entry.getCreatedDate()).isEqualTo(createdDate);
assertThat(entry.getMessage()).isEqualTo(message);
}
use of org.springframework.data.elasticsearch.core.IndexOperations in project spring-data-elasticsearch by spring-projects.
the class MappingBuilderIntegrationTests method shouldWriteDynamicMappingAnnotations.
// #1767
@Test
@DisplayName("should write dynamic mapping annotations")
void shouldWriteDynamicMappingAnnotations() {
IndexOperations indexOps = operations.indexOps(DynamicMappingAnnotationEntity.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 shouldUseBothAnalyzer.
// DATAES-420
@Test
@SuppressWarnings({ "rawtypes", "unchecked" })
public void shouldUseBothAnalyzer() {
// given
IndexOperations indexOps = this.operations.indexOps(Book.class);
indexOps.create();
indexOps.putMapping(Book.class);
// when
Map mapping = indexOps.getMapping();
Map descriptionMapping = (Map) ((Map) mapping.get("properties")).get("description");
Map prefixDescription = (Map) ((Map) descriptionMapping.get("fields")).get("prefix");
// then
assertThat(prefixDescription).hasSize(3);
assertThat(prefixDescription.get("type")).isEqualTo("text");
assertThat(prefixDescription.get("analyzer")).isEqualTo("stop");
assertThat(prefixDescription.get("search_analyzer")).isEqualTo("standard");
assertThat(descriptionMapping.get("type")).isEqualTo("text");
assertThat(descriptionMapping.get("analyzer")).isEqualTo("whitespace");
}
use of org.springframework.data.elasticsearch.core.IndexOperations in project spring-data-elasticsearch by spring-projects.
the class MappingBuilderIntegrationTests method shouldWriteMappingForDisabledEntity.
// #1370
@Test
@DisplayName("should write mapping for disabled entity")
void shouldWriteMappingForDisabledEntity() {
IndexOperations indexOps = operations.indexOps(DisabledMappingEntity.class);
indexOps.create();
indexOps.putMapping();
}
Aggregations