關閉ElasticSearch動態創建mapping


使用ElasticSearch的默認配置會使我們在索引不存在於mapping中的字段時,會自動創建
我們可以設置關閉動態創建mapping
 
執行如下操作:
PUT /索引名/索引類型/_mapping
{
  "dynamic":false
}

 

更嚴格一點可以設置不在mapping中的字段的數據不能寫入ES

{
  "dynamic":"strict"
}

這樣我們之后寫入非手動創建的其他字段數據時會得到如下錯誤:

mapping set to strict, dynamic introduction of [hatae] within [data] is not allowed

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM