@@ -50,7 +50,7 @@ class ApplicationConfiguration {
|
||||
|
||||
// Save data sample
|
||||
|
||||
List<Conference> documents = Arrays.asList(
|
||||
var documents = Arrays.asList(
|
||||
Conference.builder().date("2014-11-06").name("Spring eXchange 2014 - London")
|
||||
.keywords(Arrays.asList("java", "spring")).location(new GeoPoint(51.500152D, -0.126236D)).build(), //
|
||||
Conference.builder().date("2014-12-07").name("Scala eXchange 2014 - London")
|
||||
|
||||
@@ -54,16 +54,16 @@ class ElasticsearchOperationsTest {
|
||||
@Test
|
||||
void textSearch() throws ParseException {
|
||||
|
||||
String expectedDate = "2014-10-29";
|
||||
String expectedWord = "java";
|
||||
CriteriaQuery query = new CriteriaQuery(
|
||||
var expectedDate = "2014-10-29";
|
||||
var expectedWord = "java";
|
||||
var query = new CriteriaQuery(
|
||||
new Criteria("keywords").contains(expectedWord).and(new Criteria("date").greaterThanEqual(expectedDate)));
|
||||
|
||||
SearchHits<Conference> result = operations.search(query, Conference.class, IndexCoordinates.of("conference-index"));
|
||||
var result = operations.search(query, Conference.class, IndexCoordinates.of("conference-index"));
|
||||
|
||||
assertThat(result).hasSize(3);
|
||||
|
||||
for (SearchHit<Conference> conference : result) {
|
||||
for (var conference : result) {
|
||||
assertThat(conference.getContent().getKeywords()).contains(expectedWord);
|
||||
assertThat(format.parse(conference.getContent().getDate())).isAfter(format.parse(expectedDate));
|
||||
}
|
||||
@@ -72,11 +72,11 @@ class ElasticsearchOperationsTest {
|
||||
@Test
|
||||
void geoSpatialSearch() {
|
||||
|
||||
GeoPoint startLocation = new GeoPoint(50.0646501D, 19.9449799D);
|
||||
String range = "330mi"; // or 530km
|
||||
CriteriaQuery query = new CriteriaQuery(new Criteria("location").within(startLocation, range));
|
||||
var startLocation = new GeoPoint(50.0646501D, 19.9449799D);
|
||||
var range = "330mi"; // or 530km
|
||||
var query = new CriteriaQuery(new Criteria("location").within(startLocation, range));
|
||||
|
||||
SearchHits<Conference> result = operations.search(query, Conference.class, IndexCoordinates.of("conference-index"));
|
||||
var result = operations.search(query, Conference.class, IndexCoordinates.of("conference-index"));
|
||||
|
||||
assertThat(result).hasSize(2);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user