Search in sources :

Example 26 with IndexOperations

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

the class MappingBuilderIntegrationTests method shouldWriteMappingForDisabledProperty.

// #1370
@Test
@DisplayName("should write mapping for disabled property")
void shouldWriteMappingForDisabledProperty() {
    IndexOperations indexOps = operations.indexOps(DisabledMappingProperty.class);
    indexOps.create();
    indexOps.putMapping();
}
Also used : IndexOperations(org.springframework.data.elasticsearch.core.IndexOperations) Test(org.junit.jupiter.api.Test) SpringIntegrationTest(org.springframework.data.elasticsearch.junit.jupiter.SpringIntegrationTest) DisplayName(org.junit.jupiter.api.DisplayName)

Example 27 with IndexOperations

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

the class MappingBuilderIntegrationTests method shouldWriteDynamicDetectionValues.

// #638
@Test
@DisplayName("should write dynamic detection values")
void shouldWriteDynamicDetectionValues() {
    IndexOperations indexOps = operations.indexOps(DynamicDetectionMapping.class);
    indexOps.create();
    indexOps.putMapping();
}
Also used : IndexOperations(org.springframework.data.elasticsearch.core.IndexOperations) Test(org.junit.jupiter.api.Test) SpringIntegrationTest(org.springframework.data.elasticsearch.junit.jupiter.SpringIntegrationTest) DisplayName(org.junit.jupiter.api.DisplayName)

Example 28 with IndexOperations

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

the class MappingBuilderIntegrationTests method shouldAddStockPriceDocumentToIndex.

// DATAES-530
@Test
public void shouldAddStockPriceDocumentToIndex() {
    // Given
    IndexOperations indexOps = operations.indexOps(StockPrice.class);
    // When
    indexOps.create();
    indexOps.putMapping(StockPrice.class);
    String symbol = "AU";
    double price = 2.34;
    String id = "abc";
    IndexCoordinates index = IndexCoordinates.of("test-index-stock-mapping-builder");
    // 
    StockPrice stockPrice = new StockPrice();
    stockPrice.setId(id);
    stockPrice.setSymbol(symbol);
    stockPrice.setPrice(BigDecimal.valueOf(price));
    operations.index(buildIndex(stockPrice), index);
    operations.indexOps(StockPrice.class).refresh();
    NativeSearchQuery searchQuery = new NativeSearchQueryBuilder().withQuery(matchAllQuery()).build();
    SearchHits<StockPrice> result = operations.search(searchQuery, StockPrice.class, index);
    // Then
    assertThat(result).hasSize(1);
    StockPrice entry = result.getSearchHit(0).getContent();
    assertThat(entry.getSymbol()).isEqualTo(symbol);
    assertThat(entry.getPrice()).isCloseTo(BigDecimal.valueOf(price), Percentage.withPercentage(0.01));
}
Also used : IndexOperations(org.springframework.data.elasticsearch.core.IndexOperations) NativeSearchQueryBuilder(org.springframework.data.elasticsearch.core.query.NativeSearchQueryBuilder) IndexCoordinates(org.springframework.data.elasticsearch.core.mapping.IndexCoordinates) NativeSearchQuery(org.springframework.data.elasticsearch.core.query.NativeSearchQuery) Test(org.junit.jupiter.api.Test) SpringIntegrationTest(org.springframework.data.elasticsearch.junit.jupiter.SpringIntegrationTest)

Example 29 with IndexOperations

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

the class MappingBuilderIntegrationTests method shouldWriteWildcardFieldMapping.

// DATAES-946
@Test
@DisplayName("should write wildcard field mapping")
void shouldWriteWildcardFieldMapping() {
    IndexOperations indexOps = operations.indexOps(WildcardEntity.class);
    indexOps.create();
    indexOps.putMapping();
}
Also used : IndexOperations(org.springframework.data.elasticsearch.core.IndexOperations) Test(org.junit.jupiter.api.Test) SpringIntegrationTest(org.springframework.data.elasticsearch.junit.jupiter.SpringIntegrationTest) DisplayName(org.junit.jupiter.api.DisplayName)

Example 30 with IndexOperations

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

the class MappingBuilderIntegrationTests method shouldWriteSourceExcludes.

// #796
@Test
@DisplayName("should write source excludes")
void shouldWriteSourceExcludes() {
    IndexOperations indexOps = operations.indexOps(ExcludedFieldEntity.class);
    indexOps.create();
    indexOps.putMapping();
}
Also used : IndexOperations(org.springframework.data.elasticsearch.core.IndexOperations) Test(org.junit.jupiter.api.Test) SpringIntegrationTest(org.springframework.data.elasticsearch.junit.jupiter.SpringIntegrationTest) DisplayName(org.junit.jupiter.api.DisplayName)

Aggregations

IndexOperations (org.springframework.data.elasticsearch.core.IndexOperations)35 Test (org.junit.jupiter.api.Test)24 SpringIntegrationTest (org.springframework.data.elasticsearch.junit.jupiter.SpringIntegrationTest)24 DisplayName (org.junit.jupiter.api.DisplayName)11 BeforeEach (org.junit.jupiter.api.BeforeEach)6 Map (java.util.Map)5 HashMap (java.util.HashMap)3 AfterEach (org.junit.jupiter.api.AfterEach)3 EsProduct (com.macro.mall.search.domain.EsProduct)2 Test (org.junit.Test)2 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)2 NativeSearchQuery (org.springframework.data.elasticsearch.core.query.NativeSearchQuery)2 NativeSearchQueryBuilder (org.springframework.data.elasticsearch.core.query.NativeSearchQueryBuilder)2 LocalDate (java.time.LocalDate)1 Date (java.util.Date)1 IndexInformation (org.springframework.data.elasticsearch.core.IndexInformation)1 IndexCoordinates (org.springframework.data.elasticsearch.core.mapping.IndexCoordinates)1