1.首先创建一个索引
PUT /lib5/
#Object类型
{
"settings":{
"index":{
"number_of_shards": 5,
"number_of_replicas": 0
}
}
}
2.插入数据
PUT /lib5/person/1
{
"name":"Tom",
"age":25,
"birthday":"1985-12-12",
"address":{
"country":"china",
"province":"guangdong",
"city":"shenzhen"
}
}
3.查看自动创建的mapping
GET /lib5/person/_mapping
{
"lib5": {
"mappings": {
"person": {
"properties": {
"address": {
"properties": {
"city": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"country": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"province": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
}
}
},
"age": {
"type": "long"
},
"birthday": {
"type": "date"
},
"name": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
}
}
}
}
}
}
4.底层存储格式
{
"name":["Tom"],
"age":[25],
"birthday":["1985-12-12"],
" address.country":["china"],
"address.province":["guangdong"],
"address.city":["shenzhen"]
}
5.手动创建mapping
PUT /lib6
{
"settings": {
"number_of_shards": 3,
"number_of_replicas": 0
},
"mappings": {
"books":{
"properties": {
"title":{"type": "text"},
"name":{"type": "text","analyzer": "standard"},
#index:false,禁止倒排索引
"publish_date":{"type": "date","index": false},
"price":{"type": "double"},
"number":{"type": "integer"}
}
}
}
}