tsukahara  
                (tsukahara)
               
                 
              
                  
                    December 26, 2018,  6:32am
                   
                   
              1 
               
             
            
              現在 Elasticsearch6.2.2を使用しております。 
登録済みの templateのうち一部変更したいのですが 
上書きで templateを定義しなおすのではなく 
変更箇所のみ指定する方法はありますでしょうか。
登録例
PUT _template/t_aa
{
    "index_patterns": [
      "aa"
    ],
    "settings": {
      "index": {
        "refresh_interval": "-1",
        "number_of_shards": "5",
        "number_of_replicas": "0"
      }
    }
}
 
#実際には mappingsの定義が5000行程度あります。
上記の定義のうち、以下のみ変更したいのです。 
"number_of_replicas": "1"
KibanaのDev Toolsで templateの定義をGETで出力して、 
上記 number_of_replicasの定義のみ変更して上書きすることはできたのですが、 
変更箇所のみ指定する方法があればそうしたいと思い 
質問させていただきました。
             
            
               
               
               
            
            
           
          
            
              
                tsgkdt  
                (tsgkdt)
               
              
                  
                    December 26, 2018,  1:00pm
                   
                   
              2 
               
             
            
              こんにちわ。
登録されたdocumentには_updateがありますが、index templateにはなさそうです。 
ですので、_template/t_aaにPOSTやPUTで部分更新するのは難しそうです。
  
  
    
      /*
 * Licensed to Elasticsearch under one or more contributor
 * license agreements. See the NOTICE file distributed with
 * this work for additional information regarding copyright
 * ownership. Elasticsearch licenses this file to you under
 * the Apache License, Version 2.0 (the "License"); you may
 * not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */
package org.elasticsearch.rest.action.admin.indices;
 
  This file has been truncated. show original 
   
  
    
    
  
  
 
"number_of_replicas": "1"
 
が適用されるようにしたい、ということであれば、何もindex tempalteを上書きしなくても、複数マッピングを定義すれば良いと思います。
Multiple Templates Matching
ここにある order に着目していただいて、orderの値を増やしたtemplateで値を上書きすればできると思います。
こちらでは、こんな感じで確認しています。
PUT /_template/template_1
{
    "index_patterns" : ["hogehoge"],
    "settings" : {
        "number_of_shards" : 1,
        "number_of_replicas": 1
    },
    "mappings" : {
        "doc" : {
            "_source" : { "enabled" : false },
            "properties": {
              "value": {
                "type": "integer"
              },
              "fugafuga": {
                "type": "keyword"
              }
            }
        }
    }
}
PUT /_template/template_2
{
    "index_patterns" : ["hogehoge"],
    "order" : 1,
    "settings" : {
        "number_of_replicas" : 0
    }
}
 
この状態でhogehogeインデックスを作成すれば、tempalte_1とtemplate_2が適用され、 
template_2の方がorderが大きいので優先され、number_of_replicasは0が適用されます。 
(order未指定時は0になるため、template_2のorder:1が勝つイメージ)
もし、KibanaのDevToolsがお手元にあれば、上のindex_templateを作成していただいたのち、 
下記を実行いただければ、動作が確認できるかと思います。
# tempalte_1とtemplate_2が適用されるindexを作成
PUT hogehoge
# 元のtempalte_1の設定が生きていることを確認。
GET hogehoge/_mapping
# number_of_replicas が 0になっていることを確認
GET hogehoge/_settings
 
ご参考になれば幸いです。
             
            
               
               
               
            
            
           
          
            
              
                tsukahara  
                (tsukahara)
               
              
                  
                    January 7, 2019, 12:16am
                   
                   
              3 
               
             
            
              回答ありがとうございます。 
連絡遅れてすみません。 
tempateのupdate不可情報、orderでの上書き確認ありがとうございます。
せっかく情報をいただいたのですが、管理を簡単にしたいので 
1種類のindexには1つのtemplateの定義としたく、 
今回は定義しなおすことで対応したいと思います。
             
            
               
               
               
            
            
           
          
            
              
                system  
                (system)
                  Closed 
               
              
                  
                    February 4, 2019, 12:16am
                   
                   
              4 
               
             
            
              This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.