2013-04-22 172 views
0

這是我的問題。我有一些數據存儲在索引字段"location"。 這裏的映射無法使用geo_distance進行過濾查詢。 Elasticsearch

{ 
    "data":{ 
     "properties":{ 
     ... 
     "location":{ 
      "type": "geo_point", 
      "lat_lon": true, 
      "store": "yes" 
     }, 
     ... 
     } 
    } 
} 

這裏是在索引

{ 
    "metadata": { 
    "total": 2887, 
    "maxScore": 4.8634477 
    }, 
    "data": [ 
    { 
     "_index": "data", 
     "_type": "data", 
     "_id": "8-HtWNILQrqrobwchhgNIQ", 
     "_score": 4.8634477, 
     "_source": { 
     "generique": "Chemin", 
     "_datasetId": "5175b2b4a652945a0500000d", 
     "liaison": "", 
     "specifique": "Sainte-Foy", 
     "direction": "", 
     "nomTopo": "Chemin Sainte-Foy", 
     "ville": "Québec", 
     "arrond": "Sainte-Foy-Sillery-Cap-Rouge", 
     "location": { 
      "lon": -71.322135, 
      "lat": 46.768526 
     } 
     } 
    }, 
    { 
     "_index": "data", 
     "_type": "data", 
     "_id": "sSZ3u-uDQIuPDc2qnPir0g", 
     "_score": 4.8634477, 
     "_source": { 
     "generique": "Chemin", 
     "_datasetId": "5175b2b4a652945a0500000d", 
     "liaison": "", 
     "specifique": "Sainte-Foy", 
     "direction": "", 
     "nomTopo": "Chemin Sainte-Foy", 
     "ville": "Québec", 
     "arrond": "Sainte-Foy-Sillery-Cap-Rouge", 
     "location": { 
      "lon": -71.286977, 
      "lat": 46.784508 
     } 
     } 
    } 
    ] 
} 

數據存在的一個例子,如果我想執行與geo_distance一個請求,它返回不相關的數據。

這裏的請求

{ 
    "query": { 
    "filtered": { 
     "query_string": { 
     "query": "_datasetId:5175b2b4a652945a0500000d" 
     }, 
     "filter": { 
     "geo_distance": { 
      "location": { 
      "lat": 46.815569, 
      "lon": -71.208401 
      }, 
      "distance": "1km" 
     } 
     } 
    } 
    } 
} 

收到不包含正確"_datasetId"的數據,不包含"location"接近從查詢中給出的一個。

我希望我很清楚 謝謝。

回答

相關問題