映射<mapping>
创建
字符串类型: keyword 关键字 关键词 、text 一段文本
数字类型:integer long
小数类型:float double
布尔类型:boolean
日期类型:date
# 1.创建索引&映射
PUT /products
{
"settings": {
"number_of_shards": 1,
"number_of_replicas": 0
},
"mappings": {
"properties": {
"title":{
"type": "keyword"
},
"price":{
"type": "double"
},
"created_at":{
"type": "date"
},
"description":{
"type": "text"
}
}
}
}
说明: ES中支持字段类型非常丰富,如:text、keyword、integer、long、ip 等。更多参见Field data types | Elasticsearch Guide [7.15] | Elastic
查询
# 1.查看某个索引的映射
- GET /索引名/_mapping =====> GET /products/_mapping