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

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


  @Test
  public void shouldFindAuthorMarkersInRangeForGivenCriteriaQuery() {
    //given
    loadClassBaseEntities();
    CriteriaQuery geoLocationCriteriaQuery = new CriteriaQuery(
        new Criteria("location").within(new GeoPoint(45.7806d, 3.0875d), "20km"));
    //when
    List<AuthorMarkerEntity> geoAuthorsForGeoCriteria = elasticsearchTemplate.queryForList(geoLocationCriteriaQuery, AuthorMarkerEntity.class);

    //then
View Full Code Here


  @Test
  public void shouldFindSelectedAuthorMarkerInRangeForGivenCriteriaQuery() {
    //given
    loadClassBaseEntities();
    CriteriaQuery geoLocationCriteriaQuery2 = new CriteriaQuery(
        new Criteria("name").is("Mohsin Husen").and("location").within(new GeoPoint(51.5171d, 0.1062d), "20km"));
    //when
    List<AuthorMarkerEntity> geoAuthorsForGeoCriteria2 = elasticsearchTemplate.queryForList(geoLocationCriteriaQuery2, AuthorMarkerEntity.class);

    //then
View Full Code Here

  @Test
  public void shouldFindStringAnnotatedGeoMarkersInRangeForGivenCriteriaQuery() {
    //given
    loadAnnotationBaseEntities();
    CriteriaQuery geoLocationCriteriaQuery = new CriteriaQuery(
        new Criteria("location").within(new GeoPoint(51.000000, 0.100000), "1km"));
    //when
    List<AuthorMarkerAnnotatedEntity> geoAuthorsForGeoCriteria = elasticsearchTemplate.queryForList(geoLocationCriteriaQuery, AuthorMarkerAnnotatedEntity.class);

    //then
View Full Code Here

  @Test
  public void shouldFindDoubleAnnotatedGeoMarkersInRangeForGivenCriteriaQuery() {
    //given
    loadAnnotationBaseEntities();
    CriteriaQuery geoLocationCriteriaQuery = new CriteriaQuery(
        new Criteria("additionalLocation").within(new GeoPoint(51.001000, 0.10100), "1km"));
    //when
    List<AuthorMarkerAnnotatedEntity> geoAuthorsForGeoCriteria = elasticsearchTemplate.queryForList(geoLocationCriteriaQuery, AuthorMarkerAnnotatedEntity.class);

    //then
View Full Code Here

  @Test
  public void shouldFindAnnotatedGeoMarkersInRangeForGivenCriteriaQuery() {
    //given
    loadAnnotationBaseEntities();
    CriteriaQuery geoLocationCriteriaQuery = new CriteriaQuery(
        new Criteria("additionalLocation").within("51.001000, 0.10100", "1km"));
    //when
    List<AuthorMarkerAnnotatedEntity> geoAuthorsForGeoCriteria = elasticsearchTemplate.queryForList(geoLocationCriteriaQuery, AuthorMarkerAnnotatedEntity.class);

    //then
View Full Code Here

  @Test
  public void shouldFindAnnotatedGeoMarkersInRangeForGivenCriteriaQueryUsingGeohashLocation() {
    //given
    loadAnnotationBaseEntities();
    CriteriaQuery geoLocationCriteriaQuery = new CriteriaQuery(
        new Criteria("additionalLocation").within("u1044", "1km"));
    //when
    List<AuthorMarkerAnnotatedEntity> geoAuthorsForGeoCriteria = elasticsearchTemplate.queryForList(geoLocationCriteriaQuery, AuthorMarkerAnnotatedEntity.class);

    //then
View Full Code Here

  @Test
  public void shouldFindAuthorMarkersInBoxForGivenCriteriaQueryUsingGeoBox() {
    //given
    loadClassBaseEntities();
    CriteriaQuery geoLocationCriteriaQuery3 = new CriteriaQuery(
        new Criteria("location").boundedBy(
            new GeoBox(new GeoPoint(53.5171d, 0),
                new GeoPoint(49.5171d, 0.2062d))
        )
    );
View Full Code Here

  @Test
  public void shouldFindAuthorMarkersInBoxForGivenCriteriaQueryUsingGeohash() {
    //given
    loadClassBaseEntities();
    CriteriaQuery geoLocationCriteriaQuery3 = new CriteriaQuery(
        new Criteria("location").boundedBy(GeoHashUtils.encode(53.5171d, 0), GeoHashUtils.encode(49.5171d, 0.2062d)));
    //when
    List<AuthorMarkerEntity> geoAuthorsForGeoCriteria3 = elasticsearchTemplate.queryForList(geoLocationCriteriaQuery3, AuthorMarkerEntity.class);

    //then
View Full Code Here

  @Test
  public void shouldFindAuthorMarkersInBoxForGivenCriteriaQueryUsingGeoPoints() {
    //given
    loadClassBaseEntities();
    CriteriaQuery geoLocationCriteriaQuery3 = new CriteriaQuery(
        new Criteria("location").boundedBy(
            new GeoPoint(53.5171d, 0),
            new GeoPoint(49.5171d, 0.2062d))
    );
    //when
View Full Code Here

  }

  @Override
  public Object execute(Object[] parameters) {
    ParametersParameterAccessor accessor = new ParametersParameterAccessor(queryMethod.getParameters(), parameters);
    CriteriaQuery query = createQuery(accessor);
    if (queryMethod.isPageQuery()) {
      query.setPageable(accessor.getPageable());
      return elasticsearchOperations.queryForPage(query, queryMethod.getEntityInformation().getJavaType());
    } else if (queryMethod.isCollectionQuery()) {
      if (accessor.getPageable() != null) {
        query.setPageable(accessor.getPageable());
      }
      return elasticsearchOperations.queryForList(query, queryMethod.getEntityInformation().getJavaType());
    } else if (tree.isCountProjection()) {
      return elasticsearchOperations.count(query, queryMethod.getEntityInformation().getJavaType());
    }
View Full Code Here

TOP

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

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.