-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Refactored the GeoBoundsAggregation code from server folder to geo module. #3992
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.