Skip to content

Commit

Permalink
[GEO] Fix points_only indexing failure for GeoShapeFieldMapper
Browse files Browse the repository at this point in the history
This commit fixes a bug that was introduced in PR elastic#27415 for 6.1
and 7.0 where a change to support MULTIPOINT shapes mucked up
indexing of standalone points.
  • Loading branch information
nknize committed Feb 23, 2018
1 parent 5bb7955 commit 3728c50
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import org.apache.lucene.spatial.prefix.tree.PackedQuadPrefixTree;
import org.apache.lucene.spatial.prefix.tree.QuadPrefixTree;
import org.apache.lucene.spatial.prefix.tree.SpatialPrefixTree;
import org.elasticsearch.ElasticsearchException;
import org.elasticsearch.Version;
import org.elasticsearch.common.Explicit;
import org.elasticsearch.common.geo.GeoUtils;
Expand Down Expand Up @@ -474,13 +475,13 @@ public Mapper parse(ParseContext context) throws IOException {
for (Shape s : shapes) {
indexShape(context, s);
}
return null;
} else if (shape instanceof Point == false) {
throw new MapperParsingException("[{" + fieldType().name() + "}] is configured for points only but a " +
((shape instanceof JtsGeometry) ? ((JtsGeometry)shape).getGeom().getGeometryType() : shape.getClass()) + " was found");
}
} else {
indexShape(context, shape);
}
indexShape(context, shape);
} catch (Exception e) {
if (ignoreMalformed.value() == false) {
throw new MapperParsingException("failed to parse [" + fieldType().name() + "]", e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ public void testPointsOnly() throws Exception {

// test that point was inserted
SearchResponse response = client().prepareSearch("geo_points_only").setTypes("type1")
.setQuery(matchAllQuery())
.setQuery(geoIntersectionQuery("location", shape))
.execute().actionGet();

assertEquals(1, response.getHits().getTotalHits());
Expand Down

0 comments on commit 3728c50

Please sign in to comment.