2014-12-20 22 views

回答

6

你有幾個選項,都將工作。就我個人而言,我會選擇前兩種。如果是每日指數,那麼第二個指數是更好的選擇。

  • 定義預先映射和禁用動態字段。這是迄今爲止最安全的方法,它可以幫助您避免錯誤,並防止後來添加字段。

    { 
        "mappings": { 
        "_default_": { 
         "_all": { 
         "enabled": false 
         } 
        }, 
        "mytype" : { 
         "dynamic" : "strict", 
         "properties" : { 
         ... 
         } 
        } 
        } 
    } 
    
  • Create an index template禁用動態領域,而且可以持續不斷地用相同的映射(S)推出新的指數。

    您可以創建分層索引模板,以便多於一個適用於任何給定的索引。

    { 
        "template": "mytimedindex-*", 
        "settings": { 
        "number_of_shards": 2 
        }, 
        "mappings": { 
        "_default_": { 
         "_all": { 
         "enabled": false 
         } 
        }, 
        "mytype" : { 
         "dynamic" : "strict", 
         "properties" : { 
         ... 
         } 
        } 
        } 
    } 
    
  • Create a dynamic mapping,允許新的領域,但默認所有的string s到not_analyzed

    "dynamic_templates" : [ { 
        "strings" : { 
        "mapping" : { 
         "index" : "not_analyzed", 
         "type" : "string" 
        }, 
        "match" : "*", 
        "match_mapping_type" : "string" 
        } 
    } ] 
    

    這將允許你動態字段添加到映射。

相關問題