-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support for geo_distance queries on geo_shape fields (#2516)
Adds support for using the geo_distance query on geo_shape field types by lifting the geo_point restriction in the QueryBuilder. Distance query integration tests are abstracted to test both geo_point and geo_shape field types. Signed-off-by: Nicholas Walter Knize <[email protected]>
- Loading branch information
Showing
5 changed files
with
194 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
...r/src/internalClusterTest/java/org/opensearch/search/geo/GeoDistanceQueryGeoPointsIT.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
*/ | ||
|
||
package org.opensearch.search.geo; | ||
|
||
import org.junit.Before; | ||
import org.opensearch.common.xcontent.XContentBuilder; | ||
|
||
import java.io.IOException; | ||
|
||
/** Tests geo_distance queries on geo_point field types */ | ||
public class GeoDistanceQueryGeoPointsIT extends AbstractGeoDistanceIT { | ||
|
||
@Before | ||
public void setupTestIndex() throws IOException { | ||
indexSetup(); | ||
} | ||
|
||
@Override | ||
public XContentBuilder addGeoMapping(XContentBuilder parentMapping) throws IOException { | ||
return parentMapping.startObject("location").field("type", "geo_point").endObject(); | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
...r/src/internalClusterTest/java/org/opensearch/search/geo/GeoDistanceQueryGeoShapesIT.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
*/ | ||
|
||
package org.opensearch.search.geo; | ||
|
||
import org.junit.Before; | ||
import org.opensearch.common.xcontent.XContentBuilder; | ||
|
||
import java.io.IOException; | ||
|
||
/** Tests geo_distance queries on geo_shape field types */ | ||
public class GeoDistanceQueryGeoShapesIT extends AbstractGeoDistanceIT { | ||
|
||
@Before | ||
public void setupTestIndex() throws IOException { | ||
indexSetup(); | ||
} | ||
|
||
@Override | ||
public XContentBuilder addGeoMapping(XContentBuilder parentMapping) throws IOException { | ||
parentMapping = parentMapping.startObject("location").field("type", "geo_shape"); | ||
if (randomBoolean()) { | ||
parentMapping.field("strategy", "recursive"); | ||
} | ||
return parentMapping.endObject(); | ||
} | ||
|
||
@AwaitsFix(bugUrl = "https://github.com/opensearch-project/OpenSearch/issues/2515") | ||
@Override | ||
public void testDistanceScript() { | ||
// no-op; todo script support for distance calculation on shapes cannot be added until GeoShapeDocValues is added | ||
} | ||
|
||
@AwaitsFix(bugUrl = "https://github.com/opensearch-project/OpenSearch/issues/2515") | ||
@Override | ||
public void testGeoDistanceAggregation() { | ||
// no-op; todo aggregation support for distance calculation on shapes cannot be added until GeoShapeDocValues is added | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.