es 的mapping
put mapping操作:
可以用于为索引增加类型(add a new type to an existing index)
可以用于为索引中已经存在的类型,增加新的字段(add new fields to an existing type)
如下实例:
curl -X PUT -H 'Content-Type: application/json' "http://127.0.0.1:9200/twitter/_mapping/user" -d'
{
"properties":{
"name":{
"type" : "text"
}
}
}'
注意:es6已经要求,一个index中只能有一个type。假如twitter索引中已经存在一个 type,则会报status 400。
假如twitter索引中不存在 type,则该操作会新建一个type,名为user。
假如索引中已经存在user类型,但不存在name字段,则以上操作,可以实现向user中追加一个新字段的操作
put mapping操作,还可以实现同时向多个index中增加索引类型,或者增加新字段。
如:
curl -X PUT -H 'Content-Type: application/json' "http://127.0.0.1:9200/twitter-1,twitter-2/_mapping/user" -d'
{
"properties":{
"name":{
"type" : "text"
}
}
}'
更新索引的mapping操作规则。
1,通过新增字段实现更新mapping
2,设置为ignore_above的mapping字段,可以更新
3,。。。。暂时没有理解mutlfileds
查看索引的mapping定义

浙公网安备 33010602011771号