-
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.
Refactored the src and test of GeoBoundsAggregation on GeoPoint from …
…server folder to geo module.(#3980) Signed-off-by: Navneet Verma <navneev@amazon.com>
- Loading branch information
Showing
28 changed files
with
799 additions
and
228 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
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
47 changes: 47 additions & 0 deletions
47
...les/geo/src/internalClusterTest/java/org/opensearch/geo/GeoModulePluginIntegTestCase.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,47 @@ | ||
/* | ||
* 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.geo; | ||
|
||
import org.opensearch.index.mapper.GeoShapeFieldMapper; | ||
import org.opensearch.plugins.Plugin; | ||
import org.opensearch.test.OpenSearchIntegTestCase; | ||
import org.opensearch.test.TestGeoShapeFieldMapperPlugin; | ||
|
||
import java.util.Collection; | ||
import java.util.Collections; | ||
|
||
/** | ||
* This is the base class for all the Geo related integration tests. Use this class to add the features and settings | ||
* for the test cluster on which integration tests are running. | ||
*/ | ||
public abstract class GeoModulePluginIntegTestCase extends OpenSearchIntegTestCase { | ||
/** | ||
* Returns a collection of plugins that should be loaded on each node for doing the integration tests. As this | ||
* geo plugin is not getting packaged in a zip, we need to load it before the tests run. | ||
* | ||
* @return List of {@link Plugin} | ||
*/ | ||
@Override | ||
protected Collection<Class<? extends Plugin>> nodePlugins() { | ||
return Collections.singletonList(GeoModulePlugin.class); | ||
} | ||
|
||
/** | ||
* This was added as a backdoor to Mock the implementation of {@link GeoShapeFieldMapper} which was coming from | ||
* {@link GeoModulePlugin}. Mock implementation is {@link TestGeoShapeFieldMapperPlugin}. Now we are using the | ||
* {@link GeoModulePlugin} in our integration tests we need to override this functionality to avoid multiple mapper | ||
* error. | ||
* | ||
* @return boolean | ||
*/ | ||
@Override | ||
protected boolean addMockGeoShapeFieldMapper() { | ||
return false; | ||
} | ||
} |
59 changes: 59 additions & 0 deletions
59
modules/geo/src/internalClusterTest/java/org/opensearch/geo/search/MissingValueIT.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,59 @@ | ||
/* | ||
* 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.geo.search; | ||
|
||
import org.opensearch.action.search.SearchResponse; | ||
import org.opensearch.geo.GeoModulePluginIntegTestCase; | ||
import org.opensearch.geo.search.aggregations.metrics.GeoBounds; | ||
import org.opensearch.geo.tests.common.AggregationBuilders; | ||
import org.opensearch.test.OpenSearchIntegTestCase; | ||
|
||
import static org.opensearch.test.hamcrest.OpenSearchAssertions.assertAcked; | ||
import static org.opensearch.test.hamcrest.OpenSearchAssertions.assertSearchResponse; | ||
import static org.hamcrest.Matchers.closeTo; | ||
|
||
@OpenSearchIntegTestCase.SuiteScopeTestCase | ||
public class MissingValueIT extends GeoModulePluginIntegTestCase { | ||
|
||
@Override | ||
protected void setupSuiteScopeCluster() throws Exception { | ||
assertAcked(prepareCreate("idx").setMapping("date", "type=date", "location", "type=geo_point", "str", "type=keyword").get()); | ||
indexRandom( | ||
true, | ||
client().prepareIndex("idx").setId("1").setSource(), | ||
client().prepareIndex("idx") | ||
.setId("2") | ||
.setSource("str", "foo", "long", 3L, "double", 5.5, "date", "2015-05-07", "location", "1,2") | ||
); | ||
} | ||
|
||
public void testUnmappedGeoBounds() { | ||
SearchResponse response = client().prepareSearch("idx") | ||
.addAggregation(AggregationBuilders.geoBounds("bounds").field("non_existing_field").missing("2,1")) | ||
.get(); | ||
assertSearchResponse(response); | ||
GeoBounds bounds = response.getAggregations().get("bounds"); | ||
assertThat(bounds.bottomRight().lat(), closeTo(2.0, 1E-5)); | ||
assertThat(bounds.bottomRight().lon(), closeTo(1.0, 1E-5)); | ||
assertThat(bounds.topLeft().lat(), closeTo(2.0, 1E-5)); | ||
assertThat(bounds.topLeft().lon(), closeTo(1.0, 1E-5)); | ||
} | ||
|
||
public void testGeoBounds() { | ||
SearchResponse response = client().prepareSearch("idx") | ||
.addAggregation(AggregationBuilders.geoBounds("bounds").field("location").missing("2,1")) | ||
.get(); | ||
assertSearchResponse(response); | ||
GeoBounds bounds = response.getAggregations().get("bounds"); | ||
assertThat(bounds.bottomRight().lat(), closeTo(1.0, 1E-5)); | ||
assertThat(bounds.bottomRight().lon(), closeTo(2.0, 1E-5)); | ||
assertThat(bounds.topLeft().lat(), closeTo(2.0, 1E-5)); | ||
assertThat(bounds.topLeft().lon(), closeTo(1.0, 1E-5)); | ||
} | ||
} |
Oops, something went wrong.