Skip to content

Commit 0503897

Browse files
authored
[Backport 2.x]Support of GeoJson Point for GeoPoint field (#4597) (#4842)
* 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) * Run geojson yaml test for 2.4 and above only Signed-off-by: Heemin Kim <heemin@amazon.com> Signed-off-by: Heemin Kim <heemin@amazon.com>
1 parent a273f27 commit 0503897

File tree

8 files changed

+530
-132
lines changed

8 files changed

+530
-132
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
1919
- Introduce experimental searchable snapshot API ([#4680](https://github.com/opensearch-project/OpenSearch/pull/4680))
2020
- Introduce Remote translog feature flag([#4158](https://github.com/opensearch-project/OpenSearch/pull/4158))
2121
- Add groupId value propagation tests for ZIP publication task ([#4848](https://github.com/opensearch-project/OpenSearch/pull/4848))
22+
- Add support for GeoJson Point type in GeoPoint field ([#4597](https://github.com/opensearch-project/OpenSearch/pull/4597))
23+
2224
### Dependencies
2325
- Bumps `com.diffplug.spotless` from 6.9.1 to 6.10.0
2426
- Bumps `xmlbeans` from 5.1.0 to 5.1.1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
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+
- skip:
16+
version: " - 2.3.99"
17+
reason: "geojson format is supported in 2.4 and above"
18+
- do:
19+
bulk:
20+
refresh: true
21+
body:
22+
- index:
23+
_index: test_1
24+
_id: 1
25+
- location:
26+
lon: 52.374081
27+
lat: 4.912350
28+
- index:
29+
_index: test_1
30+
_id: 2
31+
- location: "4.901618,52.369219"
32+
- index:
33+
_index: test_1
34+
_id: 3
35+
- location: [ 52.371667, 4.914722 ]
36+
- index:
37+
_index: test_1
38+
_id: 4
39+
- location: "POINT (52.371667 4.914722)"
40+
- index:
41+
_index: test_1
42+
_id: 5
43+
- location: "t0v5zsq1gpzf"
44+
- index:
45+
_index: test_1
46+
_id: 6
47+
- location:
48+
type: Point
49+
coordinates: [ 52.371667, 4.914722 ]
50+
51+
- do:
52+
search:
53+
index: test_1
54+
rest_total_hits_as_int: true
55+
body:
56+
query:
57+
geo_shape:
58+
location:
59+
shape:
60+
type: "envelope"
61+
coordinates: [ [ 51, 5 ], [ 53, 3 ] ]
62+
63+
- match: { hits.total: 6 }
64+
65+
- do:
66+
search:
67+
index: test_1
68+
rest_total_hits_as_int: true
69+
body:
70+
query:
71+
geo_shape:
72+
location:
73+
shape:
74+
type: "envelope"
75+
coordinates: [ [ 151, 15 ], [ 153, 13 ] ]
76+
77+
- match: { hits.total: 0 }
78+
79+
---
80+
"Multi points test":
81+
- skip:
82+
version: " - 2.3.99"
83+
reason: "geojson format is supported in 2.4 and above"
84+
- do:
85+
bulk:
86+
refresh: true
87+
body:
88+
- index:
89+
_index: test_1
90+
_id: 1
91+
- location:
92+
- {lon: 52.374081, lat: 4.912350}
93+
- {lon: 152.374081, lat: 14.912350}
94+
- index:
95+
_index: test_1
96+
_id: 2
97+
- location:
98+
- "4.901618,52.369219"
99+
- "14.901618,152.369219"
100+
- index:
101+
_index: test_1
102+
_id: 3
103+
- location:
104+
- [ 52.371667, 4.914722 ]
105+
- [ 152.371667, 14.914722 ]
106+
- index:
107+
_index: test_1
108+
_id: 4
109+
- location:
110+
- "POINT (52.371667 4.914722)"
111+
- "POINT (152.371667 14.914722)"
112+
- index:
113+
_index: test_1
114+
_id: 5
115+
- location:
116+
- "t0v5zsq1gpzf"
117+
- "x6skg0zbhnum"
118+
- index:
119+
_index: test_1
120+
_id: 6
121+
- location:
122+
- {type: Point, coordinates: [ 52.371667, 4.914722 ]}
123+
- {type: Point, coordinates: [ 152.371667, 14.914722 ]}
124+
125+
- do:
126+
search:
127+
index: test_1
128+
rest_total_hits_as_int: true
129+
body:
130+
query:
131+
geo_shape:
132+
location:
133+
shape:
134+
type: "envelope"
135+
coordinates: [ [ 51, 5 ], [ 53, 3 ] ]
136+
137+
- match: { hits.total: 6 }
138+
139+
- do:
140+
search:
141+
index: test_1
142+
rest_total_hits_as_int: true
143+
body:
144+
query:
145+
geo_shape:
146+
location:
147+
shape:
148+
type: "envelope"
149+
coordinates: [ [ 151, 15 ], [ 153, 13 ] ]
150+
151+
- 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)