我在AWS Elasticsearch索引中具有以下映射
"Location": {
"type": "geo_shape",
"tree": "quadtree"
}
以下 geo_shape 查询在我的Kibana控制台上运行正常
GET test/doc/_search
{
"query": {
"geo_shape": {
"Location": {
"shape": {
"type": "point",
"coordinates": [-122.28,37.83]
},
"relation": "intersects"
}
}
}
}
我正在尝试使用 Elasticsearch Java Highest Rest Client 6.6.1
执行类似的查询//Create new CountRequest for index test
CountRequest countRequest = new CountRequest("test");
SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
QueryBuilder qb = QueryBuilders.matchAllQuery();
Coordinate coordinate = new Coordinate(-122.28, 37.83);
List<Coordinate> coordinateList = new ArrayList<>();
coordinateList.add(coordinate);
// ElasticShapeBuilder is my class which extends the the abstract class org.elasticsearch.common.geo.builders.ShapeBuilder
ShapeBuilder shapeBuilder = new ElasticShapeBuilder(coordinateList);
QueryBuilder qb2 = QueryBuilders.geoShapeQuery("Location", shapeBuilder);
QueryBuilder qb3 = QueryBuilders.boolQuery().must(qb).filter(qb2);
searchSourceBuilder.query(qb3);
countRequest.source(searchSourceBuilder);
CountResponse countResponse = highRestClient.count(countRequest, RequestOptions.DEFAULT);
我收到以下错误
com.fasterxml.jackson.core.JsonGenerationException:无法编写 字段名称,需要一个值
禁止: java.lang.IllegalStateException:无法关闭XContentBuilder
原因:java.io.IOException:找到未关闭的对象或数组