2013-01-15 24 views
1

我創造這樣在elasticsearch中,在映射創建過程中完全定義映射有多重要?

"institution" : { 
    "properties" : {   
    "InstitutionCode" : { 
     "type" : "string", 
     "store" : "yes" 
    }, 
    "InstitutionID" : { 
     "type" : "integer", 
     "store" : "yes" 
    }, 
    "Name" : { 
     "type" : "string", 
     "store" : "yes" 
    } 
    } 
} 

但是一個映射,當我進行實際的索引操作的機構,我加入了一個別名屬性(每單位0或多個別名)

"institution" : { 
    "properties" : { 
    "Aliases" : { 
     "dynamic" : "true", 
     "properties" : { 
     "InstitutionAlias" : { 
      "type" : "string" 
     }, 
     "InstitutionAliasTypeID" : { 
      "type" : "long" 
     } 
     } 
    },  
    "InstitutionCode" : { 
     "type" : "string", 
     "store" : "yes" 
    }, 
    "InstitutionID" : { 
     "type" : "integer", 
     "store" : "yes" 
    }, 
    "Name" : { 
     "type" : "string", 
     "store" : "yes" 
    } 
    } 
} 

這實際上是一個簡化的例子,因爲實際上在記錄的實際索引過程中添加的字段不僅僅是別名。

它在創建映射期間完全定義映射有多重要?

我會因索引編制操作期間自動調整映射而受到任何處罰,因爲機構記錄具有附加屬性索引?我期望機構隨着時間的推移獲得更多的財產,我想知道除了機構索引代碼之外,我是否還需要維護映射創建代碼。

回答

3

我相信動態映射的開銷是相當可以忽略的......使用它們不會傷害索引速度。但是,您可能會遇到一些ElasticSearch自動檢測字段類型錯誤的意外情況。

一個常見的例子是檢測整數,因爲字段的第一個示例是一個數字(「25」),實際上該字段的其餘數據是字符串。或者當其餘數據實際上是一個浮點數時看到一個整數。等等。

如果你的數據是很好的標準化,沒有太大的問題。

或者,您可以使用dynamic templates根據正則表達式模式將映射應用於新字段。