Elasticsearch geo_bounding_box 无法导出 xcontent

Elasticsearch geo_bounding_box failed to derive xcontent

我在 Elasticsearch 中存储了一些文档,每个文档都包含一个坐标数组,用于在 Google 地图上画一条线。在这些文件上,我想做一个地理边界框查询,以了解哪些与用户在地图上查看的位置相关。 当我尝试这样做时,出现错误 "Failed to derive xcontent".

这是其中一个文档的外观示例(可以包含数百个坐标):

{
    "type" : "Feature",
    "properties" : {
      "Type" : "Path",
      "Name" : "An example line"
    },
    "geometry" : {
      "type" : "LineString",
      "coordinates" : [ [ 14.998659698781326, 59.83282967919488 ], [ 14.998221382378132, 59.832346163020866 ], [ 14.997889000000002, 59.83210100000001 ], [ 14.997201215918253, 59.83165390720879 ], [ 14.996313, 59.83200200000001 ] ]
    }
}

这是我 运行 使用 curl 的查询(为便于阅读而进行了美化,否则在一行中没有空格):

curl.exe http://11.11.111.111:9200/map/path/_search?pretty -d'
{
    "query": {
        "geo_bounding_box": {
            "location": {
                "top_left": {
                    "lat": 60.50,
                    "lon": 14.30
                },
                "bottom_right": {
                    "lat": 59.86,
                    "lon": 16.06
                }
            }
        }
    }
}'

这是上述查询的响应:

{
  "error" : {
    "root_cause" : [ {
      "type" : "parse_exception",
      "reason" : "Failed to derive xcontent"
    } ],
    "type" : "search_phase_execution_exception",
    "reason" : "all shards failed",
    "phase" : "query",
    "grouped" : true,
    "failed_shards" : [ {
      "shard" : 0,
      "index" : "map",
      "node" : "ye2EayFlRFCM6xGWjzcfwQ",
      "reason" : {
        "type" : "parse_exception",
        "reason" : "Failed to derive xcontent"
      }
    } ]
  },
  "status" : 400
}

这是在 Elasticsearch 中找到的日志:

[2016-07-31 10:23:10,268][DEBUG][action.search            ] [one] [map][2], node[ye2EayFlRFCM6xGWjzcfwQ], [P], v[2], s[STARTED], a[id=Ptvmzu-2R6WHH89BLifz6g]: Failed to execute [org.elasticsearch.action.search.SearchRequest@866697a] lastShard [true]
RemoteTransportException[[one][10.3.0.4:9300][indices:data/read/search[phase/query]]]; nested: SearchParseException[failed to parse search source [_na_]]; nested: ElasticsearchParseException[Failed to derive xcontent];
Caused by: SearchParseException[failed to parse search source [_na_]]; nested: ElasticsearchParseException[Failed to derive xcontent];
        at org.elasticsearch.search.SearchService.parseSource(SearchService.java:855)
        at org.elasticsearch.search.SearchService.createContext(SearchService.java:654)
        at org.elasticsearch.search.SearchService.createAndPutContext(SearchService.java:620)
        at org.elasticsearch.search.SearchService.executeQueryPhase(SearchService.java:371)
        at org.elasticsearch.search.action.SearchServiceTransportAction$SearchQueryTransportHandler.messageReceived(SearchServiceTransportAction.java:368)
        at org.elasticsearch.search.action.SearchServiceTransportAction$SearchQueryTransportHandler.messageReceived(SearchServiceTransportAction.java:365)
        at org.elasticsearch.transport.TransportRequestHandler.messageReceived(TransportRequestHandler.java:33)
        at org.elasticsearch.transport.RequestHandlerRegistry.processMessageReceived(RequestHandlerRegistry.java:75)
        at org.elasticsearch.transport.TransportService.doRun(TransportService.java:376)
        at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:37)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at java.lang.Thread.run(Thread.java:745)
Caused by: ElasticsearchParseException[Failed to derive xcontent]
        at org.elasticsearch.common.xcontent.XContentFactory.xContent(XContentFactory.java:240)
        at org.elasticsearch.search.SearchService.parseSource(SearchService.java:824)

JSON 本身验证为 correct.Other 查询正常工作,我可以通过 ID 获取特定的查询并检索所有查询。只有这个查询给我带来了一些麻烦。

我试过使用 documentations 页面上的过滤器进行查询,但这也不起作用,给出了与我上面提到的相同的错误。 我在 Linux.

上使用 Elasticsearch 2.3.1

使该查询起作用需要什么?在这种情况下,错误 "Failed to derive xcontent" 是什么意思,我该如何解决?

以防其他人遇到同样的问题,这是我找到的解决方案。 在 curl 查询中,我写了 -d'[JSON]' 并简单地删除 [JSON] 周围的 ' 就可以了。现在 Elasticsearch 可以读取查询。 我已经开始尝试使用 geo_shape 查询来代替 pickypg 的建议。

CORRECT: -d [JSON] 
INCORRECT: -d '[JSON]'