`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:
Kevin Wang 2014-04-04 17:52:31 +11:00 committed by David Pilato
parent 8a09ec0e06
commit f582212c68
2 changed files with 18 additions and 1 deletions

View File

@ -525,7 +525,7 @@ public class GeoPointFieldMapper extends AbstractFieldMapper<GeoPoint> implement
}
} else if (token == XContentParser.Token.VALUE_STRING) {
parsePointFromString(context, sparse, context.parser().text());
} else {
} else if (token != XContentParser.Token.VALUE_NULL) {
parse(context, GeoUtils.parseGeoPoint(context.parser(), sparse), null);
}
}

View File

@ -117,4 +117,21 @@ public class GeohashMappingGeoPointTests extends ElasticsearchTestCase {
GeoPointFieldMapper geoPointFieldMapper = (GeoPointFieldMapper) mapper;
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());
}
}