当前位置: 动力学知识库 > 问答 > 编程问答 >

Elasticsearch: use command curl -XPUT over several indexes begining with the same word

问题描述:

I want to run the following script over several indexes called index1-%{+YYYY.MM.dd}:

curl -XPUT http://localhost:9200/index1* -d '

{

"mappings" : {

"index1" : {

"properties" : {

"location": {

"type": "geo_point"

}

}

}

}

}'

But the previous script doesn't work to due '*'.

Do you know how to solve that?

Regards

网友答案:

Do you want to put the same mapping to all the indexs??

if so, you can create a template. and put the index1* in it, so it will aply to all indexes starting with 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"
        },
        ...
网友答案:

You need to call the _mapping endpoint instead since the indices index1* already exist:

curl -XPUT http://localhost:9200/index1*/_mapping/index1 -d '{
    "properties" : {
        "location": {
            "type": "geo_point"
        }
    }
}'
分享给朋友:
您可能感兴趣的文章:
随机阅读: