<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??碼云GVP開源項目 12k star Uniapp+ElementUI 功能強大 支持多語言、二開方便! 廣告
                # Put Mapping /提交映射 原文鏈接 : [https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-put-mapping.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-put-mapping.html) 譯文鏈接 : [Put Mapping /提交映射](/pages/viewpage.action?pageId=4882803)[](https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-put-mapping.html) 貢獻者 : [Le-Mon](/display/~tanwen) 提交映射允許提交自定義的類型映射至一個新的索引,或者增加一個新的類型至一個存在的索引,或者增加某個存在類型的字段。 ``` curl -XPUT 'localhost:9200/twitter ?pretty' -d' { "mappings": { "tweet": { "properties": { "message": { "type": "text" } } } } }' curl -XPUT 'localhost:9200/twitter/_mapping/user ?pretty' -d' { "properties": { "name": { "type": "text" } } }' curl -XPUT 'localhost:9200/twitter/_mapping/tweet ?pretty' -d' { "properties": { "user_name": { "type": "text" } } }' ``` | [![](https://img.kancloud.cn/89/2e/892e2d6105d4361c3e81583c8e019d23_14x15.jpg)](https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-put-mapping.html#CO125-1) | 創建一個名叫?`twitter`?的索引,在 tweet 包含一個字段 `message`?. | | [![](https://img.kancloud.cn/50/46/50466ab92768bfee2306a5da100c7496_14x15.jpg)](https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-put-mapping.html#CO125-2) | 使用 PUT mapping API 增加一個新的類型:?`user`. | | [![](https://img.kancloud.cn/59/09/59090687855ebb833c063fe09e622609_14x15.jpg)](https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-put-mapping.html#CO125-3) | 使用 PUT mapping API 向?`tweet`增加`user_name`?字段. | 有關?[mapping](https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping.html "Mapping")?更多的信息請在該章節查看. ## Multi-index /多索引 PUT mapping API 可以用一個請求支持多個索引.格式如下 ``` PUT /{index}/_mapping/{type} { body } ``` * `{index}`?接受多個?[index](https://www.elastic.co/guide/en/elasticsearch/reference/current/multi-index.html "Multiple Indices")?和通配符. * `{type}`?是更新的 type 名稱. * `{body}?`包含需要更新的字段等. ## Updating field mappings/更新字段映射 一般來說,現有字段的映射不能更新。 這個規則有一些例外。 例如: 可以將新屬性[`properties`](https://www.elastic.co/guide/en/elasticsearch/reference/current/properties.html "properties")?添加到[Object](https://www.elastic.co/guide/en/elasticsearch/reference/current/object.html "Object datatype")數據類型字段中。 新的多字段[multi-fields](https://www.elastic.co/guide/en/elasticsearch/reference/current/multi-fields.html "fields")可以添加到現有字段。 可以禁用[`doc_values`](https://www.elastic.co/guide/en/elasticsearch/reference/current/doc-values.html "doc_values")?,但不能啟用。 可以更新[`ignore_above`](https://www.elastic.co/guide/en/elasticsearch/reference/current/ignore-above.html "ignore_above")?參數。 For example: ``` curl -XPUT 'localhost:9200/my_index ?pretty' -d' { "mappings": { "user": { "properties": { "name": { "properties": { "first": { "type": "text" } } }, "user_id": { "type": "keyword" } } } } }' curl -XPUT 'localhost:9200/my_index/_mapping/user?pretty' -d' { "properties": { "name": { "properties": { "last": { "type": "text" } } }, "user_id": { "type": "keyword", "ignore_above": 100 } } }' ``` | [![](https://img.kancloud.cn/89/2e/892e2d6105d4361c3e81583c8e019d23_14x15.jpg)](https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-put-mapping.html#CO126-1) | 創建有一個?`first`?字段的, ?[Object datatype](https://www.elastic.co/guide/en/elasticsearch/reference/current/object.html "Object datatype")?字段, 和一個 `user_id`?字段. | | [![](https://img.kancloud.cn/50/46/50466ab92768bfee2306a5da100c7496_14x15.jpg)](https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-put-mapping.html#CO126-2) | 加入?`last`字段 在 `name`?object 字段下. | | [![](https://img.kancloud.cn/59/09/59090687855ebb833c063fe09e622609_14x15.jpg)](https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-put-mapping.html#CO126-3) | 更新 `ignore_above`?設置 默認: 0. | 每個?[mapping](https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-params.html "Mapping parameters") 參數指定是否可以在現有字段上更新其設置。 ## Conflicts between fields in different types/多字段/類型的沖突 同一索引中具有相同名稱的兩個不同類型(type)的的字段必須具有相同的映射,因為它們在內部由相同的字段支持。 嘗試更新存在于多個類型中的字段的映射參數將拋出異常,除非您指定update_all_types參數,否則將在同一索引中的同一個名稱的所有字段上更新該參數。 ![Tip](https://img.kancloud.cn/de/e3/dee3f82dc73d84dc4c0ec544b7f0dda7_66x58.jpg)唯一可以免除此規則的參數 - 它們可以設置為每個字段上的不同值 - 可以在“[字段在映射typesedit?](https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping.html#field-conflicts "Fields are shared across mapping typesedit")中共享”一節中找到。 例如 失敗操作: ``` curl -XPUT 'localhost:9200/my_index?pretty' -d' { "mappings": { "type_one": { "properties": { "text": { "type": "text", "analyzer": "standard" } } }, "type_two": { "properties": { "text": { "type": "text", "analyzer": "standard" } } } } }' curl -XPUT 'localhost:9200/my_index/_mapping/type_one ?pretty' -d' { "properties": { "text": { "type": "text", "analyzer": "standard", "search_analyzer": "whitespace" } } }' ``` | [![](https://img.kancloud.cn/89/2e/892e2d6105d4361c3e81583c8e019d23_14x15.jpg)](https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-put-mapping.html#CO127-1)?[![](https://img.kancloud.cn/50/46/50466ab92768bfee2306a5da100c7496_14x15.jpg)](https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-put-mapping.html#CO127-2) | 創建一個兩種類型的索引,它們都包含一個具有相同映射的文本字段。 | | [![](https://img.kancloud.cn/59/09/59090687855ebb833c063fe09e622609_14x15.jpg)](https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-put-mapping.html#CO127-3) | 嘗試更新 `search_analyzer` 對?`type_one`?字段時拋出異常?`"Merge failed with failures..."`. | 但是這樣會成功 ``` curl -XPUT 'localhost:9200/my_index/_mapping/type_one?update_all_types &pretty' -d' { "properties": { "text": { "type": "text", "analyzer": "standard", "search_analyzer": "whitespace" } } }' ``` | [![](https://img.kancloud.cn/89/2e/892e2d6105d4361c3e81583c8e019d23_14x15.jpg)](https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-put-mapping.html#CO128-1) | 添加update_all_types參數會更新type_one和type_two中的文本字段。 |
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看