Skip to content
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

Support of GeoJson Point for GeoPoint field #4597

Merged
merged 9 commits into from
Oct 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
- Added in-flight cancellation of SearchShardTask based on resource consumption ([#4565](https://github.com/opensearch-project/OpenSearch/pull/4565))
- Apply reproducible builds configuration for OpenSearch plugins through gradle plugin ([#4746](https://github.com/opensearch-project/OpenSearch/pull/4746))
- Add groupId value propagation tests for ZIP publication task ([#4772](https://github.com/opensearch-project/OpenSearch/pull/4772))
- Add support for GeoJson Point type in GeoPoint field ([#4597](https://github.com/opensearch-project/OpenSearch/pull/4597))

### Dependencies
- Bumps `log4j-core` from 2.18.0 to 2.19.0
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
setup:
- do:
indices.create:
index: test_1
body:
settings:
number_of_replicas: 0
mappings:
properties:
location:
type: geo_point

---
"Single point test":
- do:
bulk:
refresh: true
body:
- index:
_index: test_1
_id: 1
- location:
lon: 52.374081
lat: 4.912350
- index:
_index: test_1
_id: 2
- location: "4.901618,52.369219"
- index:
_index: test_1
_id: 3
- location: [ 52.371667, 4.914722 ]
- index:
_index: test_1
_id: 4
- location: "POINT (52.371667 4.914722)"
- index:
_index: test_1
_id: 5
- location: "t0v5zsq1gpzf"
- index:
_index: test_1
_id: 6
- location:
type: Point
coordinates: [ 52.371667, 4.914722 ]

- do:
search:
index: test_1
rest_total_hits_as_int: true
body:
query:
geo_shape:
location:
shape:
type: "envelope"
coordinates: [ [ 51, 5 ], [ 53, 3 ] ]

- match: { hits.total: 6 }

- do:
search:
index: test_1
rest_total_hits_as_int: true
body:
query:
geo_shape:
location:
shape:
type: "envelope"
coordinates: [ [ 151, 15 ], [ 153, 13 ] ]

- match: { hits.total: 0 }

---
"Multi points test":
- do:
bulk:
refresh: true
body:
- index:
_index: test_1
_id: 1
- location:
- {lon: 52.374081, lat: 4.912350}
- {lon: 152.374081, lat: 14.912350}
- index:
_index: test_1
_id: 2
- location:
- "4.901618,52.369219"
- "14.901618,152.369219"
- index:
_index: test_1
_id: 3
- location:
- [ 52.371667, 4.914722 ]
- [ 152.371667, 14.914722 ]
- index:
_index: test_1
_id: 4
- location:
- "POINT (52.371667 4.914722)"
- "POINT (152.371667 14.914722)"
- index:
_index: test_1
_id: 5
- location:
- "t0v5zsq1gpzf"
- "x6skg0zbhnum"
- index:
_index: test_1
_id: 6
- location:
- {type: Point, coordinates: [ 52.371667, 4.914722 ]}
- {type: Point, coordinates: [ 152.371667, 14.914722 ]}

- do:
search:
index: test_1
rest_total_hits_as_int: true
body:
query:
geo_shape:
location:
shape:
type: "envelope"
coordinates: [ [ 51, 5 ], [ 53, 3 ] ]

- match: { hits.total: 6 }

- do:
search:
index: test_1
rest_total_hits_as_int: true
body:
query:
geo_shape:
location:
shape:
type: "envelope"
coordinates: [ [ 151, 15 ], [ 153, 13 ] ]

- match: { hits.total: 6 }
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,11 @@ public GeoPoint resetFromString(String value, final boolean ignoreZValue, Effect
public GeoPoint resetFromCoordinates(String value, final boolean ignoreZValue) {
String[] vals = value.split(",");
if (vals.length > 3) {
throw new OpenSearchParseException("failed to parse [{}], expected 2 or 3 coordinates " + "but found: [{}]", vals.length);
throw new OpenSearchParseException(
"failed to parse [{}], expected 2 or 3 coordinates " + "but found: [{}]",
value,
vals.length
heemin32 marked this conversation as resolved.
Show resolved Hide resolved
);
}
final double lat;
final double lon;
Expand Down
Loading