fixed ShapeFetchService. closes #3242

This commit is contained in:
Florian Schilling 2013-06-26 12:12:39 +02:00
parent c3ef49f5b0
commit 42b3f06a32
2 changed files with 41 additions and 0 deletions

View File

@ -73,6 +73,7 @@ public class ShapeFetchService extends AbstractComponent {
parser.nextToken();
return GeoJSONShapeParser.parse(parser);
} else {
parser.nextToken();
parser.skipChildren();
}
}

View File

@ -25,10 +25,12 @@ 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.test.hamcrest.ElasticsearchAssertions.assertHitCount;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.instanceOf;
import java.io.IOException;
import java.util.List;
import java.util.Map;
@ -182,6 +184,44 @@ public class GeoShapeIntegrationTests extends AbstractSharedClusterTest {
assertThat(searchResponse.getHits().getAt(0).id(), equalTo("1"));
}
@Test
public void testParsingMultipleShapes() throws IOException {
String mapping = XContentFactory.jsonBuilder()
.startObject()
.startObject("type1")
.startObject("properties")
.startObject("location1")
.field("type", "geo_shape")
.endObject()
.startObject("location2")
.field("type", "geo_shape")
.endObject()
.endObject()
.endObject()
.endObject()
.string();
prepareCreate("test").addMapping("type1", mapping).execute().actionGet();
ensureYellow();
String p1 = "\"location1\" : {\"type\":\"polygon\", \"coordinates\":[[[-10,-10],[10,-10],[10,10],[-10,10],[-10,-10]]]}";
String p2 = "\"location2\" : {\"type\":\"polygon\", \"coordinates\":[[[-20,-20],[20,-20],[20,20],[-20,20],[-20,-20]]]}";
String o1 = "{" + p1 + ", " + p2 + "}";
client().prepareIndex("test", "type1", "1").setSource(o1).execute().actionGet();
client().admin().indices().prepareRefresh("test").execute().actionGet();
String filter = "{\"geo_shape\": {\"location2\": {\"indexed_shape\": {"
+ "\"id\": \"1\","
+ "\"type\": \"type1\","
+ "\"index\": \"test\","
+ "\"shape_field_name\": \"location2\""
+ "}}}}";
SearchResponse result = client().prepareSearch("test").setQuery(QueryBuilders.matchAllQuery()).setFilter(filter).execute().actionGet();
assertHitCount(result, 1);
}
@Test // Issue 2944
public void testThatShapeIsReturnedEvenWhenExclusionsAreSet() throws Exception {
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type1")