Skip to content

Commit 87406fd

Browse files
committed
Support of GeoJson Point for GeoPoint field (#4597)
* Support of GeoJson Point for GeoPoint field See opensearch-project/geospatial#152 Signed-off-by: Heemin Kim <heemin@amazon.com> (cherry picked from commit a282d39)
1 parent 785e4a6 commit 87406fd

File tree

8 files changed

+524
-132
lines changed

8 files changed

+524
-132
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
1717
- Support for labels on version bump PRs, skip label support for changelog verifier ([#4391](https://github.com/opensearch-project/OpenSearch/pull/4391))
1818
- Add a new node role 'search' which is dedicated to provide search capability ([#4689](https://github.com/opensearch-project/OpenSearch/pull/4689))
1919
- Introduce experimental searchable snapshot API ([#4680](https://github.com/opensearch-project/OpenSearch/pull/4680))
20+
- Add support for GeoJson Point type in GeoPoint field ([#4597](https://github.com/opensearch-project/OpenSearch/pull/4597))
21+
2022
### Dependencies
2123
- Bumps `com.diffplug.spotless` from 6.9.1 to 6.10.0
2224
- Bumps `xmlbeans` from 5.1.0 to 5.1.1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
setup:
2+
- do:
3+
indices.create:
4+
index: test_1
5+
body:
6+
settings:
7+
number_of_replicas: 0
8+
mappings:
9+
properties:
10+
location:
11+
type: geo_point
12+
13+
---
14+
"Single point test":
15+
- do:
16+
bulk:
17+
refresh: true
18+
body:
19+
- index:
20+
_index: test_1
21+
_id: 1
22+
- location:
23+
lon: 52.374081
24+
lat: 4.912350
25+
- index:
26+
_index: test_1
27+
_id: 2
28+
- location: "4.901618,52.369219"
29+
- index:
30+
_index: test_1
31+
_id: 3
32+
- location: [ 52.371667, 4.914722 ]
33+
- index:
34+
_index: test_1
35+
_id: 4
36+
- location: "POINT (52.371667 4.914722)"
37+
- index:
38+
_index: test_1
39+
_id: 5
40+
- location: "t0v5zsq1gpzf"
41+
- index:
42+
_index: test_1
43+
_id: 6
44+
- location:
45+
type: Point
46+
coordinates: [ 52.371667, 4.914722 ]
47+
48+
- do:
49+
search:
50+
index: test_1
51+
rest_total_hits_as_int: true
52+
body:
53+
query:
54+
geo_shape:
55+
location:
56+
shape:
57+
type: "envelope"
58+
coordinates: [ [ 51, 5 ], [ 53, 3 ] ]
59+
60+
- match: { hits.total: 6 }
61+
62+
- do:
63+
search:
64+
index: test_1
65+
rest_total_hits_as_int: true
66+
body:
67+
query:
68+
geo_shape:
69+
location:
70+
shape:
71+
type: "envelope"
72+
coordinates: [ [ 151, 15 ], [ 153, 13 ] ]
73+
74+
- match: { hits.total: 0 }
75+
76+
---
77+
"Multi points test":
78+
- do:
79+
bulk:
80+
refresh: true
81+
body:
82+
- index:
83+
_index: test_1
84+
_id: 1
85+
- location:
86+
- {lon: 52.374081, lat: 4.912350}
87+
- {lon: 152.374081, lat: 14.912350}
88+
- index:
89+
_index: test_1
90+
_id: 2
91+
- location:
92+
- "4.901618,52.369219"
93+
- "14.901618,152.369219"
94+
- index:
95+
_index: test_1
96+
_id: 3
97+
- location:
98+
- [ 52.371667, 4.914722 ]
99+
- [ 152.371667, 14.914722 ]
100+
- index:
101+
_index: test_1
102+
_id: 4
103+
- location:
104+
- "POINT (52.371667 4.914722)"
105+
- "POINT (152.371667 14.914722)"
106+
- index:
107+
_index: test_1
108+
_id: 5
109+
- location:
110+
- "t0v5zsq1gpzf"
111+
- "x6skg0zbhnum"
112+
- index:
113+
_index: test_1
114+
_id: 6
115+
- location:
116+
- {type: Point, coordinates: [ 52.371667, 4.914722 ]}
117+
- {type: Point, coordinates: [ 152.371667, 14.914722 ]}
118+
119+
- do:
120+
search:
121+
index: test_1
122+
rest_total_hits_as_int: true
123+
body:
124+
query:
125+
geo_shape:
126+
location:
127+
shape:
128+
type: "envelope"
129+
coordinates: [ [ 51, 5 ], [ 53, 3 ] ]
130+
131+
- match: { hits.total: 6 }
132+
133+
- do:
134+
search:
135+
index: test_1
136+
rest_total_hits_as_int: true
137+
body:
138+
query:
139+
geo_shape:
140+
location:
141+
shape:
142+
type: "envelope"
143+
coordinates: [ [ 151, 15 ], [ 153, 13 ] ]
144+
145+
- match: { hits.total: 6 }

server/src/main/java/org/opensearch/common/geo/GeoPoint.java

+5-1
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,11 @@ public GeoPoint resetFromString(String value, final boolean ignoreZValue, Effect
119119
public GeoPoint resetFromCoordinates(String value, final boolean ignoreZValue) {
120120
String[] vals = value.split(",");
121121
if (vals.length > 3) {
122-
throw new OpenSearchParseException("failed to parse [{}], expected 2 or 3 coordinates " + "but found: [{}]", vals.length);
122+
throw new OpenSearchParseException(
123+
"failed to parse [{}], expected 2 or 3 coordinates " + "but found: [{}]",
124+
value,
125+
vals.length
126+
);
123127
}
124128
final double lat;
125129
final double lon;

0 commit comments

Comments
 (0)