mapping 詳解4(mapping setting)

來源:互聯網
上載者:User

標籤:

mapping type

映射設定一般發生在:

1. 增加新的 index 的時候,添加 mapping type,對 fields 的映射進行設定

PUT twitter {  "mappings": {    "tweet": {      "properties": {        "message": {          "type": "string"        }      }    }  }}

 

2. 為 index 增加新的 mapping type,對 fields 的映射進行設定

PUT twitter/_mapping/user {  "properties": {    "name": {      "type": "string"    }  }}

 

3. 為已有 mapping type 增加新的 fields 映射設定

PUT twitter/_mapping/tweet {  "properties": {    "user_name": {      "type": "string"    }  }}

 

設定方式

1. 在 PUT 請求體中給出完整的 mapping 設定

PUT twitter {  "mappings": {                         //mappings 對象,說明進行 mapping 設定    "tweet": {                          //指定 mapping type      "properties": {                   //指定 mapping type 的 properties 設定        "message": {                    //對欄位 message 的映射進行設定          "type": "string"              //mapping 參數配置        }      }    }  }}

 

增加 index 的時候,除了可以設定 mapping type,還可以對 index 進行設定,比如配置自訂 analyzer、索引分區個數設定等

PUT /my_index{  "settings": {    "analysis": {      "analyzer": {        "autocomplete": {           "type": "custom",          "tokenizer": "standard",          "filter": [            "lowercase",            "autocomplete_filter"          ]        }      }    }  },  "mappings": {    "my_type": {      "properties": {        "text": {          "type": "string",          "analyzer": "autocomplete"        }      }    }  }}

 

2. 在 PUT 請求 URI 中指定 type,並在請求體中給出 type 的各項設定

PUT twitter/_mapping/user {  "properties": {                   //指定 mapping type 的 properties 設定    "name": {                       //對欄位 message 的映射進行設定      "type": "string"              //mapping 參數配置    }  }}

 

3. 一個完整的 mapping type 設定包括:Meta-fields 和 Fields 或者 properties 設定

PUT my_index{  "mappings": {    "type_1": {       "properties": {...}           //properties 設定    },    "type_2": {       "_all": {                     //meta-fields 設定        "enabled": false      },      "properties": {...}    }  }}

 

mapping 詳解4(mapping setting)

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.