2016-07-26 82 views
0

我想通過幾個指標稱爲index1-%{+YYYY.MM.dd}運行以下腳本begining:Elasticsearch:使用命令捲曲-XPUT在多個指標與同字

curl -XPUT http://localhost:9200/index1* -d ' 
{ 
    "mappings" : { 
     "index1" : { 
     "properties" : { 
      "location": { 
       "type": "geo_point" 
       } 
      } 
     } 
    } 
}' 

但前面的腳本不工作,由於'*'

你知道如何解決嗎?

問候

回答

2

你想要把相同的映射到所有的指數法?

如果是這樣,您可以創建一個模板。並將index1 *放在它中,所以它將適用於以index1開頭的所有索引。

curl -XPUT http://localhost:9200/_template/template_name -d ' 
{ 
    "template": "index1*", 
    "settings": { 
    .... 
    }, 
    "mappings" : { 
    "name_mapping" : { 
     "properties" : { 
     "geometry" : { 
      "type":"geo_shape", 
      "tree":"quadtree", 
      "precision":"1m" 
     }, 
     ... 
+0

好的一點,請注意,這不會修改現有的索引,但只適用於未來的索引。要修改現有的索引,請使用其他答案。 – Val

1

您需要改爲調用_mapping終點,因爲指數index1*已經存在:

curl -XPUT http://localhost:9200/index1*/_mapping/index1 -d '{ 
    "properties" : { 
     "location": { 
      "type": "geo_point" 
     } 
    } 
}'