2017-05-03 214 views
0

我一直在遇到這個問題,我得到failed to find geo_point field [location]如何在elasticsearch中將位置設置爲geo_point?

這是我的流程。

  1. 導入CSV

    input { 
        file { 
         path => "test.csv" 
         start_position => "beginning" 
         sincedb_path => "/dev/null" 
        } 
    } 
    
    filter { 
        csv { 
        separator => "," 
        #zip,lat, lon 
        columns => [ "zip" , "lat", "lon"] 
        } 
    
        mutate { 
        convert => { "zip" => "integer" } 
        convert => { "lon" => "float" } 
        convert => { "lat" => "float" } 
        } 
    
        mutate { 
        rename => { 
         "lon" => "[location][lon]" 
         "lat" => "[location][lat]" 
        } 
        } 
    
        mutate { convert => { "[location]" => "float" } } 
    } 
    
    output { 
        elasticsearch { 
         hosts => "cluster:80" 
         index => "data" 
        } 
        stdout {} 
    } 
    
  2. 測試記錄

    GET data 
    
    "hits": [ 
    { 
        "_index": "data", 
        "_type": "logs", 
        "_id": "AVvQcOfXUojnX", 
        "_score": 1, 
        "_source": { 
        "zip": 164283216, 
        "location": { 
         "lon": 71.34, 
         "lat": 40.12 
        } 
        } 
    }, 
    ... 
    

如果我嘗試運行geo_distance查詢我得到failed to find geo_point field [location]

然後我嘗試運行

PUT data 
{ 
    "mappings": { 
     "location": { 
      "properties": { 
       "pin": { 
        "properties": { 
         "location": { 
          "type": "geo_point" 
         } 
        } 
       } 
      } 
     } 
    } 
} 

,但我得到index [data/3uxAJ4ISKy_NyVDNC] already exists

如何轉換我到location一個geo_point這樣我就可以在其上運行的查詢?

編輯:

我想我的索引東西之前種植的模板,但還是同樣的錯誤

PUT _template/template 
{ 
    "template": "base_map_template", 
    "order": 1, 
    "settings": { 
    "number_of_shards": 1 
    }, 
    "mappings": { 
    "node_points": { 
     "properties": { 
     "location": { 
      "type": "geo_point" 
     } 
     } 
    } 
    } 
} 

回答

0

您需要命名模板data而不是base_map_template,因爲這是你的指數是如何命名的。此外,類型名稱需要爲logs,而不是node_points

PUT _template/template 
{ 
    "template": "data",    <--- change this 
    "order": 1, 
    "settings": { 
    "number_of_shards": 1 
    }, 
    "mappings": { 
    "logs": {      <--- and this 
     "properties": { 
     "location": { 
      "type": "geo_point" 
     } 
     } 
    } 
    } 
} 
+0

做到了。謝謝。 – Patrioticcow

+0

很酷,很高興它幫助! – Val

相關問題