elasticsearch,kibana,Node.js,elasticsearch,Kibana" /> elasticsearch,kibana,Node.js,elasticsearch,Kibana" />

Node.js 如何从弹性API创建具有自定义模式ID的新索引模式?

Node.js 如何从弹性API创建具有自定义模式ID的新索引模式?,node.js,elasticsearch,kibana,Node.js,elasticsearch,Kibana,我使用ES Node.js API创建了新索引,并在其中插入了一些文档。 现在,我想在首次创建索引时自动创建索引模式要在创建时创建到特定索引的映射,您需要使用index_patterns参数设置模板 PUT _template/fruits { "index_patterns": ["banana*", "apple*"], "settings": { "number_of_shards": 2 }, "mappings": { "_source": {

我使用ES Node.js API创建了新索引,并在其中插入了一些文档。
现在,我想在首次创建索引时自动创建索引模式

要在创建时创建到特定索引的映射,您需要使用index_patterns参数设置模板

PUT _template/fruits
{
  "index_patterns": ["banana*", "apple*"],
  "settings": {
    "number_of_shards": 2
  },
  "mappings": {
    "_source": {
      "enabled": false
    },
    "properties": {
      "name": {
        "type": "text"
      },
      "time_of_my_life": {
        "type": "date",
        "format": "yyyy-MM-dd HH:mm:ss"
      }
    }
  }
} 
现在,当您创建索引banana1或apple_7时,它将具有您在模板中创建的预定义映射

PUT banana1
GET banana1/_mapping

{
  "banana1" : {
    "mappings" : {
      "_source" : {
        "enabled" : false
      },
      "properties" : {
        "name" : {
          "type" : "text"
        },
        "time_of_my_life" : {
          "type" : "date",
          "format" : "yyyy-MM-dd HH:mm:ss"
        }
      }
    }
  }
}

实际上,我想要实现的是在Kibana UI上创建一个索引模式,而无需手动操作。反正是Tnx