diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt index 0cf9a191f74..34734c7f5fa 100644 --- a/lucene/CHANGES.txt +++ b/lucene/CHANGES.txt @@ -56,6 +56,9 @@ Improvements * LUCENE-8937: Avoid agressive stemming on numbers in the FrenchMinimalStemmer. (Adrien Gallou via Tomoko Uchida) +* LUCENE-8964: Fix geojson shape parsing on string arrays in properties + (Alexander Reelsen) + Bug fixes * LUCENE-8663: NRTCachingDirectory.slowFileExists may open a file while diff --git a/lucene/core/src/java/org/apache/lucene/geo/SimpleGeoJSONPolygonParser.java b/lucene/core/src/java/org/apache/lucene/geo/SimpleGeoJSONPolygonParser.java index 1e35a3db8c4..d33d11acf5f 100644 --- a/lucene/core/src/java/org/apache/lucene/geo/SimpleGeoJSONPolygonParser.java +++ b/lucene/core/src/java/org/apache/lucene/geo/SimpleGeoJSONPolygonParser.java @@ -295,6 +295,8 @@ class SimpleGeoJSONPolygonParser { o = null; } else if (ch == '-' || ch == '.' || (ch >= '0' && ch <= '9')) { o = parseNumber(); + } else if (ch == '"') { + o = parseString(); } else { throw newParseException("expected another array or number while parsing array, not '" + ch + "'"); } diff --git a/lucene/core/src/test/org/apache/lucene/geo/TestPolygon.java b/lucene/core/src/test/org/apache/lucene/geo/TestPolygon.java index 8ee62718e6d..e9bf265ffb5 100644 --- a/lucene/core/src/test/org/apache/lucene/geo/TestPolygon.java +++ b/lucene/core/src/test/org/apache/lucene/geo/TestPolygon.java @@ -300,4 +300,21 @@ public class TestPolygon extends LuceneTestCase { Exception e = expectThrows(ParseException.class, () -> Polygon.fromGeoJSON(b.toString())); assertTrue(e.getMessage().contains("can only handle type FeatureCollection (if it has a single polygon geometry), Feature, Polygon or MutiPolygon, but got Point")); } + + public void testPolygonPropertiesCanBeStringArrays() throws Exception { + StringBuilder b = new StringBuilder(); + b.append("{\n"); + b.append(" \"type\": \"Polygon\",\n"); + b.append(" \"coordinates\": [\n"); + b.append(" [ [100.0, 0.0], [101.0, 0.0], [101.0, 1.0],\n"); + b.append(" [100.0, 1.0], [100.0, 0.0] ]\n"); + b.append(" ],\n"); + b.append(" \"properties\": {\n"); + b.append(" \"array\": [ \"value\" ]\n"); + b.append(" }\n"); + b.append("}\n"); + + Polygon[] polygons = Polygon.fromGeoJSON(b.toString()); + assertEquals(1, polygons.length); + } }