diff --git a/search-core/src/main/java/org/opengroup/osdu/search/util/GeoQueryBuilder.java b/search-core/src/main/java/org/opengroup/osdu/search/util/GeoQueryBuilder.java index 29bacdac31bac62e27de7209114ed208aad8a812..021f673dfba67586c72c431f06d5059481312f35 100644 --- a/search-core/src/main/java/org/opengroup/osdu/search/util/GeoQueryBuilder.java +++ b/search-core/src/main/java/org/opengroup/osdu/search/util/GeoQueryBuilder.java @@ -141,15 +141,13 @@ public final class GeoQueryBuilder { } private static Map<String, Object> createMultiPolygon(List<Polygon> polygons) { - Map<String, Object> geometryCollection = new HashMap<>(); - geometryCollection.put("type", "GeometryCollection"); + Map<String, Object> multiPolygon = new HashMap<>(); + multiPolygon.put("type", "MultiPolygon"); - List<Map<String, Object>> geometriesList = new ArrayList<>(); + List<Object> multiPolygonCoordinates = new ArrayList<>(); for (Polygon polygon : polygons) { checkPolygon(polygon); - Map<String, Object> multiPolygon = new HashMap<>(); - multiPolygon.put("type", "MultiPolygon"); List<List<List<Double>>> polygonCoordinates = new ArrayList<>(); List<List<Double>> coordinates = new ArrayList<>(); @@ -160,14 +158,12 @@ public final class GeoQueryBuilder { polygonCoordinates.add(coordinates); - multiPolygon.put("coordinates", polygonCoordinates); - - geometriesList.add(multiPolygon); + multiPolygonCoordinates.add(polygonCoordinates); } - geometryCollection.put("geometries", geometriesList); + multiPolygon.put("coordinates", multiPolygonCoordinates); - return geometryCollection; + return multiPolygon; } private Query getIntersectionQuery(SpatialFilter spatialFilter) { diff --git a/search-core/src/test/resources/testqueries/expected/intersection-query.json b/search-core/src/test/resources/testqueries/expected/intersection-query.json index d09a13955e87ea0ecae039605e285e4183879c29..2531cfae1170131dcd4fd80bd0ea815b53f9a777 100644 --- a/search-core/src/test/resources/testqueries/expected/intersection-query.json +++ b/search-core/src/test/resources/testqueries/expected/intersection-query.json @@ -1,9 +1,9 @@ { "geo_shape":{ "data.SpatialLocation.Wgs84Coordinates":{ - "shape":"{geometries=[{coordinates=[[[-8.61, 1.02], [-2.48, 1.02], [-2.48, 10.74], [-8.61, 10.74], [-8.61, 1.02]]], type=MultiPolygon}], type=GeometryCollection}", + "shape":"{coordinates=[[[[-8.61, 1.02], [-2.48, 1.02], [-2.48, 10.74], [-8.61, 10.74], [-8.61, 1.02]]]], type=MultiPolygon}", "relation":"intersects" }, "ignore_unmapped":true } -} \ No newline at end of file +} diff --git a/testing/integration-tests/search-test-aws/src/test/resources/features/query/singlecluster/QueryAWS.feature b/testing/integration-tests/search-test-aws/src/test/resources/features/query/singlecluster/QueryAWS.feature index 798acf72f6456959c6614708f41a420c2dda080c..92c0045656a0fe7ed56be647b3332eaebf96b162 100644 --- a/testing/integration-tests/search-test-aws/src/test/resources/features/query/singlecluster/QueryAWS.feature +++ b/testing/integration-tests/search-test-aws/src/test/resources/features/query/singlecluster/QueryAWS.feature @@ -148,6 +148,16 @@ Feature: Search with different queries | "tenant1:search<timestamp>:*:*" | "Harris" | "ZipCode" | -45 | -400 | 1000 | 400 | "Bad Request" | "Invalid parameters were given on search request" | "'longitude' value is out of the range [-360, 360]" | | "tenant1:search<timestamp>:*:*" | "Harris" | "ZipCode" | 4 | 2 | 0 | 400 | "Bad Request" | "Invalid parameters were given on search request" | "'distance' must be greater than 0" | + @default + Scenario Outline: Search data across the kinds with intersection polygon inputs + When I send <query> with <kind> + And I apply geographical query on field <field> + And define intersection polygon with points (<lat1>, <lon1>) and (<lat2>, <lon2>) and (<lat3>, <lon3>) and (<lat4>, <lon4>) and (<lat5>, <lon5>) + Then I should get in response <count> records + Examples: + | kind | query | field | lat1 | lon1 | lat2 | lon2 | lat3 | lon3 | lat4 | lon4 | lat5 | lon5 | count | + | "tenant1:search<timestamp>:test-data--Integration:1.0.1" | None | "data.Location" | 90 | -180 | 90 | 180 | -90 | 180 | -90 | -180 | 90 | -180 | 3 | + @default Scenario Outline: Search data across the kinds When I send <query> with <kind> diff --git a/testing/integration-tests/search-test-azure/src/test/resources/features/query/singlecluster/SingleClusterQuery.feature b/testing/integration-tests/search-test-azure/src/test/resources/features/query/singlecluster/SingleClusterQuery.feature index e198d3f775001c54bebf1d1211c2cfcdeb950e92..caafdc42c239783ac941d376ae10479653181166 100644 --- a/testing/integration-tests/search-test-azure/src/test/resources/features/query/singlecluster/SingleClusterQuery.feature +++ b/testing/integration-tests/search-test-azure/src/test/resources/features/query/singlecluster/SingleClusterQuery.feature @@ -133,6 +133,16 @@ Feature: Search with different queries | "tenant1:search<timestamp>:*:*" | "Harris" | "ZipCode" | -45 | -400 | 1000 | 400 | "Bad Request" | "Invalid parameters were given on search request" | "'longitude' value is out of the range [-360, 360]" | | "tenant1:search<timestamp>:*:*" | "Harris" | "ZipCode" | 4 | 2 | 0 | 400 | "Bad Request" | "Invalid parameters were given on search request" | "'distance' must be greater than 0" | + @default + Scenario Outline: Search data across the kinds with intersection polygon inputs + When I send <query> with <kind> + And I apply geographical query on field <field> + And define intersection polygon with points (<lat1>, <lon1>) and (<lat2>, <lon2>) and (<lat3>, <lon3>) and (<lat4>, <lon4>) and (<lat5>, <lon5>) + Then I should get in response <count> records + Examples: + | kind | query | field | lat1 | lon1 | lat2 | lon2 | lat3 | lon3 | lat4 | lon4 | lat5 | lon5 | count | + | "tenant1:search<timestamp>:test-data--Integration:1.0.1" | None | "data.Location" | 90 | -180 | 90 | 180 | -90 | 180 | -90 | -180 | 90 | -180 | 3 | + @default Scenario Outline: Search data across the kinds When I send <query> with <kind> diff --git a/testing/integration-tests/search-test-core/src/main/resources/features/query/singlecluster/Query.feature b/testing/integration-tests/search-test-core/src/main/resources/features/query/singlecluster/Query.feature index 5361db713aefe810850e6aa6f813bf5fea5e087e..b66535a136521892330fb8a604fa34a87a450a32 100644 --- a/testing/integration-tests/search-test-core/src/main/resources/features/query/singlecluster/Query.feature +++ b/testing/integration-tests/search-test-core/src/main/resources/features/query/singlecluster/Query.feature @@ -151,6 +151,16 @@ Feature: Search with different queries | "tenant1:search<timestamp>:*:*" | "Harris" | "ZipCode" | -45 | -200 | 1000 | 400 | "Bad Request" | "Invalid parameters were given on search request" | "'longitude' value is out of the range [-180, 180]" | | "tenant1:search<timestamp>:*:*" | "Harris" | "ZipCode" | 4 | 2 | 0 | 400 | "Bad Request" | "Invalid parameters were given on search request" | "'distance' must be greater than 0" | + @default + Scenario Outline: Search data across the kinds with intersection polygon inputs + When I send <query> with <kind> + And I apply geographical query on field <field> + And define intersection polygon with points (<lat1>, <lon1>) and (<lat2>, <lon2>) and (<lat3>, <lon3>) and (<lat4>, <lon4>) and (<lat5>, <lon5>) + Then I should get in response <count> records + Examples: + | kind | query | field | lat1 | lon1 | lat2 | lon2 | lat3 | lon3 | lat4 | lon4 | lat5 | lon5 | count | + | "tenant1:search<timestamp>:test-data--Integration:1.0.1" | None | "data.Location" | 90 | -180 | 90 | 180 | -90 | 180 | -90 | -180 | 90 | -180 | 3 | + @default Scenario Outline: Search data across the kinds When I send <query> with <kind>