use of org.springframework.data.elasticsearch.core.geo.GeoPoint in project spring-data-elasticsearch by spring-projects.
the class CustomMethodRepositoryIntegrationTests method shouldExecuteCustomMethodWithGeoPointAndString.
@Test
public void shouldExecuteCustomMethodWithGeoPointAndString() {
// given
String documentId = nextIdAsString();
SampleEntity sampleEntity = new SampleEntity();
sampleEntity.setId(documentId);
sampleEntity.setType("test");
sampleEntity.setRate(10);
sampleEntity.setMessage("foo");
sampleEntity.setLocation(new GeoPoint(45.7806d, 3.0875d));
repository.save(sampleEntity);
documentId = nextIdAsString();
sampleEntity = new SampleEntity();
sampleEntity.setId(documentId);
sampleEntity.setType("test");
sampleEntity.setRate(10);
sampleEntity.setMessage("foo");
sampleEntity.setLocation(new GeoPoint(48.7806d, 3.0875d));
repository.save(sampleEntity);
// when
Page<SampleEntity> page = repository.findByLocationAndMessage(new GeoPoint(45.7806d, 3.0875d), "foo", PageRequest.of(0, 10));
// then
assertThat(page).isNotNull();
assertThat(page.getTotalElements()).isEqualTo(1L);
}
use of org.springframework.data.elasticsearch.core.geo.GeoPoint in project spring-data-elasticsearch by spring-projects.
the class CustomMethodRepositoryIntegrationTests method shouldCountCustomMethodWithNearBox.
// DATAES-106
@Test
public void shouldCountCustomMethodWithNearBox() {
// given
String documentId = nextIdAsString();
SampleEntity sampleEntity = new SampleEntity();
sampleEntity.setId(documentId);
sampleEntity.setType("test");
sampleEntity.setRate(10);
sampleEntity.setMessage("foo");
sampleEntity.setLocation(new GeoPoint(45.7806d, 3.0875d));
repository.save(sampleEntity);
documentId = nextIdAsString();
SampleEntity sampleEntity2 = new SampleEntity();
sampleEntity2.setId(documentId);
sampleEntity2.setType("test2");
sampleEntity2.setRate(10);
sampleEntity2.setMessage("foo");
sampleEntity2.setLocation(new GeoPoint(30.7806d, 0.0875d));
repository.save(sampleEntity2);
// when
long count = repository.countByLocationNear(new Box(new Point(3d, 46d), new Point(4d, 45d)));
// then
assertThat(count).isEqualTo(1L);
}
use of org.springframework.data.elasticsearch.core.geo.GeoPoint in project spring-data-elasticsearch by spring-projects.
the class CustomMethodRepositoryIntegrationTests method shouldExecuteCustomMethodWithNearPointAndDistance.
@Test
public void shouldExecuteCustomMethodWithNearPointAndDistance() {
// given
String documentId = nextIdAsString();
SampleEntity sampleEntity = new SampleEntity();
sampleEntity.setId(documentId);
sampleEntity.setType("test");
sampleEntity.setRate(10);
sampleEntity.setMessage("foo");
sampleEntity.setLocation(new GeoPoint(45.7806d, 3.0875d));
repository.save(sampleEntity);
// when
Page<SampleEntity> page = repository.findByLocationNear(new Point(3.0875d, 45.7806d), new Distance(2, Metrics.KILOMETERS), PageRequest.of(0, 10));
// then
assertThat(page).isNotNull();
assertThat(page.getTotalElements()).isEqualTo(1L);
}
Aggregations