最近更新时间:2024-06-11 19:52:29
在Kibana控制台中,创建一个名称为school的索引,类型为student,包含4个字段,分别是name、address、age和date。关于字段类型说明,可查看官方文档 Field Datatypes。
PUT school
{
"settings":{
"number_of_shards": 3,
"number_of_replicas": 1
},
"mappings":{
"student":{
"properties":{
"name":{
"type":"text"
},
"address":{
"type":"keyword"
},
"age":{
"type":"integer"
},
"date":{
"type":"date",
"format":"yyyy-MM-dd HH:mm:ss"
}
}
}
}
}
如果返回显示"errors" : false,说明数据插入成功。
POST /school/student/_bulk
{"index":{}}
{"name":"张三","address":"山东济南","age":"22","date":"2020-01-19 08:10:00"}
{"index":{}}
{"name":"李四","address":"北京海淀","age":"21","date":"2020-02-19 09:00:00"}
{"index":{}}
{"name":"王五","address":"吉林长春","age":"23","date":"2020-02-19 10:00:00"}
GET /school/_search
{
"query": {
"match": {
"address": "北京海淀"
}
}
}
纯净模式