Skip to content

Commit

Permalink
geo_point doesn't allow null values
Browse files Browse the repository at this point in the history
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 elastic#5680.
Closes elastic#5681.
(cherry picked from commit f582212)
  • Loading branch information
kzwang authored and dadoonet committed Apr 4, 2014
1 parent 15a917a commit 7de3ebb
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
Expand Up @@ -524,7 +524,7 @@ public void parse(ParseContext context) throws IOException {
}
} 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);
}
}
Expand Down
Expand Up @@ -117,4 +117,21 @@ public void testGeoHashPrecisionAsLength() throws Exception {
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());
}
}

0 comments on commit 7de3ebb

Please sign in to comment.