use of org.springframework.data.elasticsearch.core.query.CriteriaQuery in project spring-data-elasticsearch by spring-projects.
the class GeoIntegrationTests method shouldFindSelectedAuthorMarkerInRangeForGivenCriteriaQuery.
@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
SearchHits<AuthorMarkerEntity> geoAuthorsForGeoCriteria2 = operations.search(geoLocationCriteriaQuery2, AuthorMarkerEntity.class, authorMarkerIndex);
// then
assertThat(geoAuthorsForGeoCriteria2).hasSize(1);
assertThat(geoAuthorsForGeoCriteria2.getSearchHit(0).getContent().getName()).isEqualTo("Mohsin Husen");
}
use of org.springframework.data.elasticsearch.core.query.CriteriaQuery in project spring-data-elasticsearch by spring-projects.
the class GeoIntegrationTests method shouldFindDoubleAnnotatedGeoMarkersInRangeForGivenCriteriaQuery.
@Test
public void shouldFindDoubleAnnotatedGeoMarkersInRangeForGivenCriteriaQuery() {
// given
loadAnnotationBaseEntities();
CriteriaQuery geoLocationCriteriaQuery = new CriteriaQuery(new Criteria("locationAsArray").within(new GeoPoint(51.001000, 0.10100), "1km"));
// when
SearchHits<LocationMarkerEntity> geoAuthorsForGeoCriteria = operations.search(geoLocationCriteriaQuery, LocationMarkerEntity.class, locationMarkerIndex);
// then
assertThat(geoAuthorsForGeoCriteria).hasSize(3);
}
use of org.springframework.data.elasticsearch.core.query.CriteriaQuery in project spring-data-elasticsearch by spring-projects.
the class GeoIntegrationTests method shouldFindAnnotatedGeoMarkersInRangeForGivenCriteriaQuery.
@Test
public void shouldFindAnnotatedGeoMarkersInRangeForGivenCriteriaQuery() {
// given
loadAnnotationBaseEntities();
CriteriaQuery geoLocationCriteriaQuery = new CriteriaQuery(new Criteria("locationAsArray").within("51.001000, 0.10100", "1km"));
// when
SearchHits<LocationMarkerEntity> geoAuthorsForGeoCriteria = operations.search(geoLocationCriteriaQuery, LocationMarkerEntity.class, locationMarkerIndex);
// then
assertThat(geoAuthorsForGeoCriteria).hasSize(3);
}
use of org.springframework.data.elasticsearch.core.query.CriteriaQuery in project spring-data-elasticsearch by spring-projects.
the class GeoIntegrationTests method shouldFindAnnotatedGeoMarkersInRangeForGivenCriteriaQueryUsingGeohashLocation.
@Test
public void shouldFindAnnotatedGeoMarkersInRangeForGivenCriteriaQueryUsingGeohashLocation() {
// given
loadAnnotationBaseEntities();
CriteriaQuery geoLocationCriteriaQuery = new CriteriaQuery(new Criteria("locationAsArray").within("u1044", "3km"));
// when
SearchHits<LocationMarkerEntity> geoAuthorsForGeoCriteria = operations.search(geoLocationCriteriaQuery, LocationMarkerEntity.class, locationMarkerIndex);
// then
assertThat(geoAuthorsForGeoCriteria).hasSize(3);
}
use of org.springframework.data.elasticsearch.core.query.CriteriaQuery in project spring-data-elasticsearch by spring-projects.
the class GeoIntegrationTests method shouldFindAuthorMarkersInBoxForGivenCriteriaQueryUsingGeoBox.
@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))));
// when
SearchHits<AuthorMarkerEntity> geoAuthorsForGeoCriteria3 = operations.search(geoLocationCriteriaQuery3, AuthorMarkerEntity.class, authorMarkerIndex);
// then
assertThat(geoAuthorsForGeoCriteria3).hasSize(2);
assertThat(geoAuthorsForGeoCriteria3.stream().map(SearchHit::getContent).map(AuthorMarkerEntity::getName)).containsExactlyInAnyOrder("Mohsin Husen", "Rizwan Idrees");
}
Aggregations