Elasticsearch索引模板indextemplates怎么創(chuàng)建

這篇文章主要講解了“Elasticsearch索引模板index templates怎么創(chuàng)建”,文中的講解內(nèi)容簡單清晰,易于學(xué)習(xí)與理解,下面請大家跟著小編的思路慢慢深入,一起來研究和學(xué)習(xí)“Elasticsearch索引模板index templates怎么創(chuàng)建”吧!

10余年的秀英網(wǎng)站建設(shè)經(jīng)驗,針對設(shè)計、前端、開發(fā)、售后、文案、推廣等六對一服務(wù),響應(yīng)快,48小時及時工作處理。全網(wǎng)營銷推廣的優(yōu)勢是能夠根據(jù)用戶設(shè)備顯示端的尺寸不同,自動調(diào)整秀英建站的顯示方式,使網(wǎng)站能夠適用不同顯示終端,在瀏覽器中調(diào)整網(wǎng)站的寬度,無論在任何一種瀏覽器上瀏覽網(wǎng)站,都能展現(xiàn)優(yōu)雅布局與設(shè)計,從而大程度地提升瀏覽體驗。創(chuàng)新互聯(lián)從事“秀英網(wǎng)站設(shè)計”,“秀英網(wǎng)站推廣”以來,每個客戶項目都認(rèn)真落實執(zhí)行。

一、

索引模板,定義模板,當(dāng)新索引創(chuàng)建時,自動匹配,并應(yīng)用定義的模板

新增索引模板(index templates)

我們新建一個索引模板template_1 設(shè)置它的主分片為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": {}
         }
      }
   }
}

例子:我們想再創(chuàng)建某個索引時,還為其創(chuàng)建alias

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

POST /s-1

GET /s-1

當(dāng)創(chuàng)建多個索引模板時,且創(chuàng)建某個索引,被多個索引模板匹配,那么settings和mappings將會合并到一個配置中,并應(yīng)用這個索引上,合并的順序由索引模板的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怎么創(chuàng)建”的內(nèi)容了,經(jīng)過本文的學(xué)習(xí)后,相信大家對Elasticsearch索引模板index templates怎么創(chuàng)建這一問題有了更深刻的體會,具體使用情況還需要大家實踐驗證。這里是創(chuàng)新互聯(lián),小編將為大家推送更多相關(guān)知識點的文章,歡迎關(guān)注!

網(wǎng)站題目:Elasticsearch索引模板indextemplates怎么創(chuàng)建
當(dāng)前路徑:http://www.muchs.cn/article28/ippicp.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站制作、企業(yè)網(wǎng)站制作定制網(wǎng)站、服務(wù)器托管品牌網(wǎng)站制作、商城網(wǎng)站

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

外貿(mào)網(wǎng)站制作