Search in sources :

Example 1 with GeoJsonPoint

use of org.springframework.data.elasticsearch.core.geo.GeoJsonPoint in project spring-data-elasticsearch by spring-projects.

the class CriteriaQueryMappingUnitTests method shouldMapNamesInGeoJsonQuery.

// DATAES-931
@Test
@DisplayName("should map names in GeoJson query")
void shouldMapNamesInGeoJsonQuery() throws JSONException {
    GeoJsonPoint geoJsonPoint = GeoJsonPoint.of(1.2, 3.4);
    CriteriaQuery criteriaQuery = new CriteriaQuery(new Criteria("geoShapeField").intersects(geoJsonPoint));
    String base64Query = getBase64EncodedGeoShapeQuery(geoJsonPoint, "geo-shape-field", "intersects");
    String expected = // 
    "{\n" + // 
    "  \"wrapper\": {\n" + "    \"query\": \"" + base64Query + // 
    "\"\n" + // 
    "  }\n" + // 
    "}\n";
    mappingElasticsearchConverter.updateQuery(criteriaQuery, GeoShapeEntity.class);
    String queryString = new CriteriaFilterProcessor().createFilter(criteriaQuery.getCriteria()).toString();
    assertEquals(expected, queryString, false);
}
Also used : CriteriaQuery(org.springframework.data.elasticsearch.core.query.CriteriaQuery) Criteria(org.springframework.data.elasticsearch.core.query.Criteria) GeoJsonPoint(org.springframework.data.elasticsearch.core.geo.GeoJsonPoint) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Aggregations

DisplayName (org.junit.jupiter.api.DisplayName)1 Test (org.junit.jupiter.api.Test)1 GeoJsonPoint (org.springframework.data.elasticsearch.core.geo.GeoJsonPoint)1 Criteria (org.springframework.data.elasticsearch.core.query.Criteria)1 CriteriaQuery (org.springframework.data.elasticsearch.core.query.CriteriaQuery)1