我已經存儲在Elasticsearch幾個文件,每個都包含座標的數組借鑑谷歌地圖的線路。在這些文件中,我想要做一個地理邊界框查詢來了解哪些地圖與用戶在地圖上查找的相關。 當我嘗試這個時,我得到錯誤「無法派生xcontent」。Elasticsearch geo_bounding_box未能獲得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.100000001 ], [ 14.997201215918253, 59.83165390720879 ], [ 14.996313, 59.83200200000001 ] ]
}
}
這是我使用捲曲運行查詢(美化了可讀性,否則在一行中沒有空格):
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 [[email protected]] 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$4.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。
需要什麼,使這個查詢的工作?在這種情況下,「導出xcontent失敗」的錯誤是什麼意思,我該如何解決?
與您所面臨的問題無關,但'geo_bounding_box'僅適用於地理點,不適用於地理形狀。 – pickypg
文檔確實會說「過濾器可以處理每個文檔的多個位置/點,一旦一個位置/點與過濾器匹配,文檔將包含在過濾器中」。 一個線串本質上是一串點通過它繪製一條線,或者我誤解了? – Motsols
我相信你會曲解。你可以有一個點陣列,這與一條線不同。 – pickypg