What‘s is Mapping?

自定义mapping


Mapping中的字段类型一旦设定后,禁止直接修改,原因如下:
Lucene实现的倒排索引生成后不允许修改
重新建立新的索引,然后做reindex操作
无法对新增字段进行查询操作

PUT my_index
{
"mappings": {
"doc" : {
"dynamic" : false,
"properties": {
"title" : {
"type":"text"
},
"name": {
"type":"keyword"
},
"age": {
"type": "integer"
}
}
}
}
}
GET my_index/_mapping
copy_to

DELETE my_index
PUT my_index
{
"mappings": {
"doc": {
"properties": {
"first_name": {
"type": "text",
"copy_to": "full_name"
},
"last_name": {
"type": "text",
"copy_to": "full_name"
},
"full_name":{
"type": "text"
}
}
}
}
}
PUT my_index/doc/1
{
"first_name": "John",
"last_name": "Smith"
}
GET my_index/_search
{
"query": {
"match": {
"full_name" : {
"query": "John",
"operator": "and"
}
}
}
}
index
私密信息,节省空间(因为该字段不再使用倒排索引搜索)

index_options

null_value

数据类型
- text分词,keyword不分词

dynamic-mapping

dynamic-mapping 日期与数字识别

Dynamic Templates

索引模板
ES有一些自带的模板,小心和自定义模板引起冲突


随时随地看视频