parent
3087fd8b2a
commit
6e9ad03b27
|
@ -213,6 +213,9 @@ public class GeoShapeFieldMapper extends AbstractFieldMapper<String> {
|
|||
public void parse(ParseContext context) throws IOException {
|
||||
try {
|
||||
ShapeBuilder shape = ShapeBuilder.parse(context.parser());
|
||||
if(shape == null) {
|
||||
return;
|
||||
}
|
||||
Field[] fields = defaultStrategy.createIndexableFields(shape.build());
|
||||
if (fields == null || fields.length == 0) {
|
||||
return;
|
||||
|
|
|
@ -21,18 +21,16 @@ package org.elasticsearch.test.integration.search.geo;
|
|||
|
||||
import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
|
||||
import static org.elasticsearch.index.query.FilterBuilders.geoIntersectionFilter;
|
||||
import static org.elasticsearch.index.query.QueryBuilders.filteredQuery;
|
||||
import static org.elasticsearch.index.query.QueryBuilders.geoShapeQuery;
|
||||
import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery;
|
||||
import static org.elasticsearch.index.query.QueryBuilders.*;
|
||||
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertHitCount;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.hamcrest.Matchers.instanceOf;
|
||||
import static org.hamcrest.Matchers.*;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.elasticsearch.action.get.GetResponse;
|
||||
import org.elasticsearch.action.search.SearchResponse;
|
||||
import org.elasticsearch.common.geo.builders.ShapeBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
|
@ -43,6 +41,21 @@ import org.testng.annotations.Test;
|
|||
|
||||
public class GeoShapeIntegrationTests extends AbstractSharedClusterTest {
|
||||
|
||||
@Test
|
||||
public void testNullShape() throws Exception {
|
||||
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type1")
|
||||
.startObject("properties").startObject("location")
|
||||
.field("type", "geo_shape")
|
||||
.endObject().endObject()
|
||||
.endObject().endObject().string();
|
||||
prepareCreate("test").addMapping("type1", mapping).execute().actionGet();
|
||||
ensureGreen();
|
||||
|
||||
client().prepareIndex("test", "type1", "aNullshape").setSource("{\"location\": null}").execute().actionGet();
|
||||
GetResponse result = client().prepareGet("test", "type1", "aNullshape").execute().actionGet();
|
||||
assertThat(result.getField("location"), nullValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIndexPointsFilterRectangle() throws Exception {
|
||||
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type1")
|
||||
|
|
Loading…
Reference in New Issue