[GEO] Fix points_only indexing failure for GeoShapeFieldMapper

This commit fixes a bug that was introduced in PR #27415 for 6.1
and 7.0 where a change to support MULTIPOINT shapes mucked up
indexing of standalone points.
This commit is contained in:
Nicholas Knize 2018-02-21 12:03:12 -06:00
parent 5bb79558e7
commit 3728c50d85
2 changed files with 4 additions and 3 deletions

View File

@ -30,6 +30,7 @@ import org.apache.lucene.spatial.prefix.tree.GeohashPrefixTree;
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;
@ -474,13 +475,13 @@ public class GeoShapeFieldMapper extends FieldMapper {
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);

View File

@ -464,7 +464,7 @@ public class GeoShapeQueryTests extends ESSingleNodeTestCase {
// 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());