`geo_point` doesn't allow null values
After upgrading to 1.1.0, sending null values to geo points produces the following error: ``` MapperParsingException[failed to parse]; nested: ElasticsearchParseException[geo_point expected]; ``` Closes #5680. Closes #5681.
This commit is contained in:
parent
8a09ec0e06
commit
f582212c68
|
@ -525,7 +525,7 @@ public class GeoPointFieldMapper extends AbstractFieldMapper<GeoPoint> implement
|
||||||
}
|
}
|
||||||
} else if (token == XContentParser.Token.VALUE_STRING) {
|
} else if (token == XContentParser.Token.VALUE_STRING) {
|
||||||
parsePointFromString(context, sparse, context.parser().text());
|
parsePointFromString(context, sparse, context.parser().text());
|
||||||
} else {
|
} else if (token != XContentParser.Token.VALUE_NULL) {
|
||||||
parse(context, GeoUtils.parseGeoPoint(context.parser(), sparse), null);
|
parse(context, GeoUtils.parseGeoPoint(context.parser(), sparse), null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -117,4 +117,21 @@ public class GeohashMappingGeoPointTests extends ElasticsearchTestCase {
|
||||||
GeoPointFieldMapper geoPointFieldMapper = (GeoPointFieldMapper) mapper;
|
GeoPointFieldMapper geoPointFieldMapper = (GeoPointFieldMapper) mapper;
|
||||||
assertThat(geoPointFieldMapper.geoHashPrecision(), is(10));
|
assertThat(geoPointFieldMapper.geoHashPrecision(), is(10));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testNullValue() throws Exception {
|
||||||
|
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type")
|
||||||
|
.startObject("properties").startObject("point").field("type", "geo_point").endObject().endObject()
|
||||||
|
.endObject().endObject().string();
|
||||||
|
|
||||||
|
DocumentMapper defaultMapper = MapperTestUtils.newParser().parse(mapping);
|
||||||
|
|
||||||
|
ParsedDocument doc = defaultMapper.parse("type", "1", XContentFactory.jsonBuilder()
|
||||||
|
.startObject()
|
||||||
|
.field("point", (Object) null)
|
||||||
|
.endObject()
|
||||||
|
.bytes());
|
||||||
|
|
||||||
|
assertThat(doc.rootDoc().get("point"), nullValue());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue