对索引模板的部分更新

时间:2015-12-09 15:09:37

标签: elasticsearch

在ElasticSearch中,是否可以对索引模板进行部分更新?

例如,我尝试使用以下内容更改默认分析器(使用Sense):

PUT /_template/testtemplate/_update
{
    "settings": {
        "index":{
            "analysis": {
               "analyzer": {
                  "default": {
                     "type": "whitespace"
                  }
               }
            }
        }
    }    
}

Bu没有用,我收到的错误是Invalid index name [_template], must not start with '_'

我是否必须使用PUT再次传递完整模板,或者还有其他方式进行部分更新?

1 个答案:

答案 0 :(得分:3)

部分更新仅适用于文档(在某种程度上适用于映射类型),不适用于索引模板。因此,我确认您需要再次存储完整的索引模板,而不仅仅是要更新它的一小部分。

正如您在RestUpdateAction.java的源代码中所看到的,_update REST端点需要{index}名称,{type}名称和{id}。因此,在上面的示例中,该端点认为_template是索引名称并抱怨。

同样,在用于创建索引模板的REST端点RestPutIndexTemplateAction.java中,您可以看到_template路径根本不支持_update端点。