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

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


    repository.save(new SpELEntity());
    repository.save(new SpELEntity());
    //When

    //Then
    NativeSearchQuery nativeSearchQuery = new NativeSearchQuery(QueryBuilders.matchAllQuery());
    nativeSearchQuery.addIndices("abz-entity");
    long count = template.count(nativeSearchQuery);
    assertThat(count, is(2L));
  }
View Full Code Here


    elasticsearchTemplate.refresh(ParentEntity.class, true);
    elasticsearchTemplate.refresh(ChildEntity.class, true);

    // find all parents that have the first child
    QueryBuilder query = hasChildQuery(ParentEntity.CHILD_TYPE, QueryBuilders.termQuery("name", child1name.toLowerCase()));
    List<ParentEntity> parents = elasticsearchTemplate.queryForList(new NativeSearchQuery(query), ParentEntity.class);

    // we're expecting only the first parent as result
    assertThat("parents", parents, contains(hasProperty("id", is(parent1.getId()))));
  }
View Full Code Here

    elasticsearchTemplate.refresh(ParentEntity.class, true);
    elasticsearchTemplate.refresh(ChildEntity.class, true);

    // find all parents that have the first child using topChildren Query
    QueryBuilder query = topChildrenQuery(ParentEntity.CHILD_TYPE, QueryBuilders.termQuery("name", child1name.toLowerCase()));
    List<ParentEntity> parents = elasticsearchTemplate.queryForList(new NativeSearchQuery(query), ParentEntity.class);

    // we're expecting only the first parent as result
    assertThat("parents", parents, contains(hasProperty("id", is(parent1.getId()))));
  }
View Full Code Here

TOP

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

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.