elasticsearch5.0索引映射管理
所属分类 elasticsearch
浏览量 1438
根据原文翻译整理
https://www.elastic.co/guide/en/elasticsearch/reference/5.0/indices-put-mapping.html
add a new type to an existing index
add new fields to an existing type
给存在的索引添加 type
给存在的TYPE 添加字段
Creates an index called twitter with the message field in the tweet mapping type
PUT twitter
{
"mappings": {
"tweet": {
"properties": {
"message": {
"type": "text"
}
}
}
}
}
Uses the PUT mapping API to add a new mapping type called user.
添加新的TYPE user
PUT twitter/_mapping/user
{
"properties": {
"name": {
"type": "text"
}
}
}
add a new field called user_name to the tweet mapping type
给tweet新增一个字段 user_name
PUT twitter/_mapping/tweet
{
"properties": {
"user_name": {
"type": "text"
}
}
}
the mapping for existing fields cannot be updated.
new properties can be added to Object datatype fields.
new multi-fields can be added to existing fields.
doc_values can be disabled, but not enabled.
the ignore_above parameter can be updated.
doc_values可以被禁用 但不能被启用
ignore_above 字节数 超过指定长度的不会被处理
Lucene 字节长度限制 32766
如果使用 utf8 将这个限制设置成 32766 / 3 = 10922 ,一个 UTF-8 字符可能最多占用 3 个字节。
Fields in the same index with the same name in two different types must have the same mapping
同一个索引下的同名字段必须有同样的映射
Trying to update a mapping parameter for a field
which exists in more than one type will throw an exception,
unless you specify the update_all_types parameter,
in which case it will update that parameter across all fields
with the same name in the same index.
修改已存在同名字段的类型 使用 update_all_types
PUT my_index/_mapping/type_one?update_all_types
获取 mapping 信息
GET /twitter/_mapping/tweet
GET /_mapping/tweet,kimchy
GET /_all/_mapping/tweet,book
GET /_all/_mapping
GET /_mapping
http://127.0.0.1:9200/_mapping
获取字段mapping信息
GET /twitter/_mapping/tweet/field/message
http://127.0.0.1:9200/twitter/_mapping/tweet/field/message
GET /twitter,kimchy/_mapping/field/message
GET /_all/_mapping/tweet,book/field/message,user.id
GET /_all/_mapping/tw*/field/*.id
使用 head 操作判断 type 是否存在
HEAD twitter/_mapping/tweet
上一篇
下一篇
plantUML安装使用
通过男女关系形象解读大数据技术
elasticsearch5.0索引别名
elasticsearch5.0索引设置
elasticsearch5.0索引监控
elasticsearch5.0索引状态管理