弹性搜索索引模板创建

时间:2014-11-14 11:22:16

标签: node.js elasticsearch

我对弹性搜索很新,在我的节点程序中我使用的是弹性搜索。在那我想创建一个"Index Template",但我收到错误:

查询:

 client.indices.putTemplate({
       "name":"mfi1",
       "template" : "te*"
}).then(function(res){
    console.log(res);
}, function(error){
    console.log(error);
});

但我收到错误:

  {
    "error": "ElasticsearchParseException[Failed to derive xcontent from org.elasticsearch.common.bytes.BytesArray@1]",
    "status": 400
  }

帮我解决这个问题。谢谢。

1 个答案:

答案 0 :(得分:3)

我发现了一个解决方案:

我将查询重建如下:

{
        name : "mfi3",
        body:{
            "template" : "te*",
            "settings" : {
                "number_of_shards" : 1
            },
            "mappings" : {
                "type1" : {
                    "_source" : { "enabled" : false }
                }
            }
        }
    };

工作正常。

相关问题