目录
这里使用的是Es 7.x版本;
1、创建表
##创建student表,前提此表不存在
PUT /student
{
"mappings" : {
"properties" : {
"name" : {
"type" : "text"
},
"sex" : {
"type" : "keyword"
},
"birthday" : {
"type" : "date",
"format": "yyyy-MM-dd HH:mm:ss"
},
"age" : {
"type" : "double"
}
}
}
}
2、查询和删除
##查询表结构
GET /student
##查询数据
GET /student/_search
##删除索引
DELETE /student
3、增加数据
##新增数据
POST /student/_doc
{
"name" : "zhangsan" ,
"sex" : "F",
"birthday" : "2000-08-20 22:30:01",
"age" : 21
}
##批量插入数据
POST _bulk
{"index":{"_index":"student","_type":"_doc"}}
{"name":"lisi","sex":"M","birthday":"1999-08-20 22:30:01","age":21}
{"index":{"_index":"student","_type":"_doc"}}
{"name":"wangwu","sex":"F","birthday":"1998-08-20 22:30:01","age":22}