Package org.springframework.data.elasticsearch.core.query

Examples of org.springframework.data.elasticsearch.core.query.NativeSearchQueryBuilder


  @Test
  public void shouldReturnKeyValueRangeFacetForStringValuesInGivenQuery() {
    // given
    String facetName = "rangeScoreOverYears";
    SearchQuery searchQuery = new NativeSearchQueryBuilder().withQuery(matchAllQuery())
        .withFacet(
            new RangeFacetRequestBuilder(facetName).fields(PUBLISHED_YEARS, "score")
                .to("2000").range("2000", "2002").from("2002").build()
        ).build();
    // when
View Full Code Here


  @Test
  public void shouldReturnStatisticalFacetForGivenQuery() {
    // given
    String facetName = "statPublishedYear";
    SearchQuery searchQuery = new NativeSearchQueryBuilder().withQuery(matchAllQuery())
        .withFacet(new StatisticalFacetRequestBuilder(facetName).field(PUBLISHED_YEARS).build()
        ).build();
    // when
    FacetedPage<ArticleEntity> result = elasticsearchTemplate.queryForPage(searchQuery, ArticleEntity.class);
    // then
View Full Code Here

  @Test
  public void shouldReturnHistogramFacetForGivenQuery() {
    // given
    String facetName = "numberPublicationPerYear";
    SearchQuery searchQuery = new NativeSearchQueryBuilder().withQuery(matchAllQuery())
        .withFacet(new HistogramFacetRequestBuilder(facetName).field(PUBLISHED_YEARS).interval(1).build()
        ).build();
    // when
    FacetedPage<ArticleEntity> result = elasticsearchTemplate.queryForPage(searchQuery, ArticleEntity.class);
    // then
View Full Code Here

  }

  @Test
  public void shouldReturnAggregatedResponseForGivenSearchQuery() {
    // given
    SearchQuery searchQuery = new NativeSearchQueryBuilder()
        .withQuery(matchAllQuery())
        .withSearchType(COUNT)
        .withIndices("articles").withTypes("article")
        .addAggregation(terms("subjects").field("subject"))
        .build();
View Full Code Here

      sampleEntity.setId(documentId);
      sampleEntity.setMessage("some test message");
      sampleEntity.setVersion(System.currentTimeMillis());
      repository.save(sampleEntity);

      SearchQuery query = new NativeSearchQueryBuilder()
              .withQuery(termQuery("message", "test"))
              .build();
      //when
      Page<IntegerIDEntity> page = repository.search(query);
      //then
View Full Code Here

      sampleEntity.setId(documentId);
      sampleEntity.setMessage("hello world.");
      sampleEntity.setVersion(System.currentTimeMillis());
      repository.save(sampleEntity);
      //when
      SearchQuery searchQuery = new NativeSearchQueryBuilder()
              .withQuery(fieldQuery("id",documentId))
              .build();
      Page<IntegerIDEntity> sampleEntities= repository.search(searchQuery);
      //then
      assertThat(sampleEntities.getTotalElements(), equalTo(1L));
View Full Code Here

  @Test
  public void shouldDeleteAll(){
      //when
      repository.deleteAll();
      //then
      SearchQuery searchQuery = new NativeSearchQueryBuilder()
              .withQuery(matchAllQuery())
              .build();
      Page<IntegerIDEntity> sampleEntities= repository.search(searchQuery);
      assertThat(sampleEntities.getTotalElements(), equalTo(0L));
  }
View Full Code Here

      sampleEntity.setVersion(System.currentTimeMillis());
      repository.save(sampleEntity);
      //when
      repository.delete(sampleEntity);
      //then
      SearchQuery searchQuery = new NativeSearchQueryBuilder()
              .withQuery(fieldQuery("id", documentId))
              .build();
      Page<IntegerIDEntity> sampleEntities= repository.search(searchQuery);
      assertThat(sampleEntities.getTotalElements(),equalTo(0L));
  }
View Full Code Here

      sampleEntity.setId(documentId);
      sampleEntity.setMessage("some test message");
      sampleEntity.setVersion(System.currentTimeMillis());
      repository.save(sampleEntity);

      SearchQuery query = new NativeSearchQueryBuilder()
              .withQuery(termQuery("message", "test"))
              .build();
      //when
      Page<DoubleIDEntity> page = repository.search(query);
      //then
View Full Code Here

      sampleEntity.setId(documentId);
      sampleEntity.setMessage("hello world.");
      sampleEntity.setVersion(System.currentTimeMillis());
      repository.save(sampleEntity);
      //when
      SearchQuery searchQuery = new NativeSearchQueryBuilder()
              .withQuery(fieldQuery("id",documentId))
              .build();
      Page<DoubleIDEntity> sampleEntities= repository.search(searchQuery);
      //then
      assertThat(sampleEntities.getTotalElements(), equalTo(1L));
View Full Code Here

TOP

Related Classes of org.springframework.data.elasticsearch.core.query.NativeSearchQueryBuilder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.