diff --git a/src/main/java/org/opensearch/geospatial/index/mapper/xypoint/XYPoint.java b/src/main/java/org/opensearch/geospatial/index/mapper/xypoint/XYPoint.java index f5fdbd4dc9..cc06be1d8c 100644 --- a/src/main/java/org/opensearch/geospatial/index/mapper/xypoint/XYPoint.java +++ b/src/main/java/org/opensearch/geospatial/index/mapper/xypoint/XYPoint.java @@ -160,7 +160,7 @@ private XYPoint resetFromWKT(String value, boolean ignoreZValue) { throw new OpenSearchParseException("[xy_point] supports only POINT among WKT primitives, but found [{}]", geometry.type()); } Point point = (Point) geometry; - return reset(point.getY(), point.getX()); + return reset(point.getX(), point.getY()); } /** diff --git a/src/main/java/org/opensearch/geospatial/index/mapper/xypoint/XYPointParser.java b/src/main/java/org/opensearch/geospatial/index/mapper/xypoint/XYPointParser.java index 62c22bd31a..191ece8354 100644 --- a/src/main/java/org/opensearch/geospatial/index/mapper/xypoint/XYPointParser.java +++ b/src/main/java/org/opensearch/geospatial/index/mapper/xypoint/XYPointParser.java @@ -157,9 +157,9 @@ private static XYPoint parseXYPointArray(XContentParser subParser, final boolean } element++; if (element == 1) { - y = subParser.doubleValue(); - } else if (element == 2) { x = subParser.doubleValue(); + } else if (element == 2) { + y = subParser.doubleValue(); } else if (element == 3) { XYPoint.assertZValue(ignoreZValue, subParser.doubleValue()); } else { diff --git a/src/test/java/org/opensearch/geospatial/index/mapper/xypoint/XYPointParsingTests.java b/src/test/java/org/opensearch/geospatial/index/mapper/xypoint/XYPointParsingTests.java index 1704fca0f4..a99d654187 100644 --- a/src/test/java/org/opensearch/geospatial/index/mapper/xypoint/XYPointParsingTests.java +++ b/src/test/java/org/opensearch/geospatial/index/mapper/xypoint/XYPointParsingTests.java @@ -170,7 +170,7 @@ private XContentParser xyAsString(double x, double y) throws IOException { private XContentParser xyAsArray(double x, double y) throws IOException { XContentBuilder content = JsonXContent.contentBuilder(); - content.startArray().value(y).value(x).endArray(); + content.startArray().value(x).value(y).endArray(); XContentParser parser = createParser(JsonXContent.jsonXContent, BytesReference.bytes(content)); parser.nextToken(); return parser; @@ -178,7 +178,7 @@ private XContentParser xyAsArray(double x, double y) throws IOException { private XContentParser xyAsWKT(double x, double y) throws IOException { XContentBuilder content = JsonXContent.contentBuilder(); - content.value("POINT (" + y + " " + x + ")"); + content.value("POINT (" + x + " " + y + ")"); XContentParser parser = createParser(JsonXContent.jsonXContent, BytesReference.bytes(content)); parser.nextToken(); return parser;