久久精品人人爽,华人av在线,亚洲性视频网站,欧美专区一二三

Elasticsearch索引模板index templates怎么創建

133次閱讀
沒有評論

共計 1275 個字符,預計需要花費 4 分鐘才能閱讀完成。

這篇文章主要講解了“Elasticsearch 索引模板 index templates 怎么創建”,文中的講解內容簡單清晰,易于學習與理解,下面請大家跟著丸趣 TV 小編的思路慢慢深入,一起來研究和學習“Elasticsearch 索引模板 index templates 怎么創建”吧!

一、

索引模板,定義模板,當新索引創建時,自動匹配,并應用定義的模板

新增索引模板 (index templates)

我們新建一個索引模板 template_1 設置它的主分片為 1 個。類型有 type1 且_source disabled

PUT /_template/template_1
  template :  t-* ,
  settings : {
  number_of_shards :1
 },
  mappings : {
  type1 :{
  _source :{
  enabled :false
 }
 }
 }
POST /t-1
GET /t-1/_mapping
  t-1 : {
  mappings : {
  type1 : {
  _source : {
  enabled : false
 },
  properties : {}
 }
 }
 }
}

例子:我們想再創建某個索引時,還為其創建 alias

PUT /_template/template_2
  template :  s-* ,
  settings : {
  number_of_shards :1
 },
  aliases :{
  alias1 :{
 
 },
  {index}-alias :{
 
 }
 }
POST /s-1
GET /s-1

當創建多個索引模板時,且創建某個索引,被多個索引模板匹配,那么 settings 和 mappings 將會合并到一個配置中,并應用這個索引上,合并的順序由索引模板的 order 屬性來控制。order 大的會覆蓋之前的配置

PUT /_template/template_1
  template : * ,
  order :0,
  settings :{
  number_of_shards :1
 },
  mappings :{
  type1 :{
  _source :{
  enabled :false
 }
 }
 }
PUT /_template/template_2
  template : tt-* ,
  order :1,
  settings :{
  number_of_shards :1
 },
  mappings :{
  type1 :{
  _source :{
  enabled :true
 }
 }
 }
POST /tt-1 =   會被上述兩個模板都匹配,對于_source 屬性  order= 1 的會覆蓋 order=0  即  enabled:true

文件配置:我們可以再 config/templates 目錄下添加 json 的配置文件

感謝各位的閱讀,以上就是“Elasticsearch 索引模板 index templates 怎么創建”的內容了,經過本文的學習后,相信大家對 Elasticsearch 索引模板 index templates 怎么創建這一問題有了更深刻的體會,具體使用情況還需要大家實踐驗證。這里是丸趣 TV,丸趣 TV 小編將為大家推送更多相關知識點的文章,歡迎關注!

正文完
 
丸趣
版權聲明:本站原創文章,由 丸趣 2023-08-16發表,共計1275字。
轉載說明:除特殊說明外本站除技術相關以外文章皆由網絡搜集發布,轉載請注明出處。
評論(沒有評論)
主站蜘蛛池模板: 台州市| 邵阳市| 泰州市| 高阳县| 五家渠市| 石屏县| 正阳县| 林州市| 平潭县| 柞水县| 屯昌县| 克东县| 深泽县| 云梦县| 诸暨市| 肃北| 阳西县| 海门市| 清新县| 治多县| 玉环县| 庆云县| 驻马店市| 九龙坡区| 清原| 财经| 怀柔区| 卢湾区| 通河县| 缙云县| 永济市| 嵊州市| 山阴县| 香港 | 桓台县| 浙江省| 灌云县| 井陉县| 会同县| 抚顺县| 万宁市|