Example usage for org.springframework.data.elasticsearch.core.facet.result HistogramResult getIntervalUnit

List of usage examples for org.springframework.data.elasticsearch.core.facet.result HistogramResult getIntervalUnit

Introduction

In this page you can find the example usage for org.springframework.data.elasticsearch.core.facet.result HistogramResult getIntervalUnit.

Prototype

public List<IntervalUnit> getIntervalUnit() 

Source Link

Usage

From source file:example.springdata.elasticsearch.ElasticsearchOperationsTest.java

@Test
public void histogramFacetOnDate() {

    String termField = "date";
    int interval = 30;
    String facetName = "by-date";

    FacetedPage<Conference> firstPage = operations.queryForPage(new NativeSearchQueryBuilder() //
            .withQuery(matchAllQuery()) //
            .withFacet(new HistogramFacetRequestBuilder(facetName).//
                    timeUnit(TimeUnit.DAYS).//
                    interval(interval). //
                    field(termField).build())
            .////from www  .  ja v a2 s .co m
            build(), Conference.class);

    HistogramResult facet = (HistogramResult) firstPage.getFacet(facetName);

    assertThat(facet.getIntervalUnit(), hasSize(3));
}