fixed ShapeFetchService. closes #3242
This commit is contained in:
parent
c3ef49f5b0
commit
42b3f06a32
|
@ -73,6 +73,7 @@ public class ShapeFetchService extends AbstractComponent {
|
||||||
parser.nextToken();
|
parser.nextToken();
|
||||||
return GeoJSONShapeParser.parse(parser);
|
return GeoJSONShapeParser.parse(parser);
|
||||||
} else {
|
} else {
|
||||||
|
parser.nextToken();
|
||||||
parser.skipChildren();
|
parser.skipChildren();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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.filteredQuery;
|
||||||
import static org.elasticsearch.index.query.QueryBuilders.geoShapeQuery;
|
import static org.elasticsearch.index.query.QueryBuilders.geoShapeQuery;
|
||||||
import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery;
|
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.MatcherAssert.assertThat;
|
||||||
import static org.hamcrest.Matchers.equalTo;
|
import static org.hamcrest.Matchers.equalTo;
|
||||||
import static org.hamcrest.Matchers.instanceOf;
|
import static org.hamcrest.Matchers.instanceOf;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
@ -182,6 +184,44 @@ public class GeoShapeIntegrationTests extends AbstractSharedClusterTest {
|
||||||
assertThat(searchResponse.getHits().getAt(0).id(), equalTo("1"));
|
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
|
@Test // Issue 2944
|
||||||
public void testThatShapeIsReturnedEvenWhenExclusionsAreSet() throws Exception {
|
public void testThatShapeIsReturnedEvenWhenExclusionsAreSet() throws Exception {
|
||||||
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type1")
|
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type1")
|
||||||
|
|
Loading…
Reference in New Issue