# 情境
今天在使用elasticsearch 7.93,在进行创建索引的时候,出现的问题
# 有问题的创建语句 (本人使用的是elasticsearch-head谷歌插件)
http://192.168.2.155:9200/
book PUT方式
{
"settings":{
"number_of_shards": 5,
"number_of_replicas": 1
},
"mappings":{
"novel":{
"properties":{
"name":{
"type": "text",
"analyzer": "ik_max_word",
"index": true,
"store": false
},
"author":{
"type": "keyword"
},
"count":{
"type": "long"
},
"date":{
"type": "date",
"format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis"
},
"desc":{
"type": "text",
"analyzer": "ik_max_word",
"index": true,
"store": false
}
}
}
}
}
# 问题原因
elasticsearch7之后,去掉了类型这个数据结构 (也就是novel)
# 正确如下
{
"settings":{
"number_of_shards": 5,
"number_of_replicas": 1
},
"mappings":{
"properties":{
"name":{
"type": "text",
"analyzer": "ik_max_word",
"index": true,
"store": false
},
"author":{
"type": "keyword"
},
"count":{
"type": "long"
},
"date":{
"type": "date",
"format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis"
},
"desc":{
"type": "text",
"analyzer": "ik_max_word",
"index": true,
"store": false
}
}
}
}