PUT mapping
API容許你向現有索引添加字段,或者僅更改現有字段的搜索設置。segmentfault
PUT twitter {} PUT twitter/_mapping { "properties": { "email": { "type": "keyword" } } }
twitter
的索引,不須要任何映射。PUT mapping
API添加一個名爲email
的新字段。有關如何定義映射的更多信息能夠在映射部分中找到。app
在7.0.0以前,映射定義用於包含類型名稱,雖然如今不同意在請求中指定類型,可是若是設置了請求參數
include_type_name
,仍然能夠提供類型,有關詳細信息,請參見
刪除映射類型。
PUT mapping
API能夠應用於單個請求的多個索引,例如,咱們能夠同時更新twitter-1
和twitter-2
的映射:code
# Create the two indices PUT twitter-1 PUT twitter-2 # Update both mappings PUT /twitter-1,twitter-2/_mapping { "properties": { "user_name": { "type": "text" } } }
twitter-1,twitter-2
)遵循多索引名稱和通配符格式。一般,沒法更新現有字段的映射,這條規則有一些例外,例如:對象
properties
。ignore_above
參數。示例:索引
PUT my_index { "mappings": { "properties": { "name": { "properties": { "first": { "type": "text" } } }, "user_id": { "type": "keyword" } } } } PUT my_index/_mapping { "properties": { "name": { "properties": { "last": { "type": "text" } } }, "user_id": { "type": "keyword", "ignore_above": 100 } } }
name
對象字段下有first
字段,user_id
字段。name
對象字段下添加last
字段。0
更新ignore_above
設置。每一個映射參數指定是否能夠在現有字段上更新其設置。get