# elasticsearch中的三种模式
# 第一种动态模式 默认就是dynamic模式
PUT mapping
{
"mappings": {
"properties": {
"name":{
"type": "keyword"
},
"age":{
"type": "long"
}
}
}
}
PUT mapping/_doc/1
{
"name":"蔡恒",
"age":28
}
GET mapping
PUT mapping/_doc/2
{
"name":"你好",
"age":24,
"company":"武汉"
}
# 第二种静态模式
PUT mapping2
{
"mappings": {
"dynamic":false,
"properties": {
"name":{
"type": "text"
},
"age":{
"type": "long"
}
}
}
}
GET mapping2
PUT mapping2/_doc/1
{
"name":"caiheng",
"age":28,
"company":"wuhan"
}
GET mapping2/_search
# 第三种严格模式
PUT mapping3
{
"mappings": {
"dynamic":"strict",
"properties": {
"name":{
"type": "text"
},
"age":{
"type": "long"
}
}
}
}
PUT mapping3/_doc/1
{
"name":"hahah",
"age":25,
"company":"五哈"
}
GET mapping3