用Postman在ElasticSearch上简单的增删改查
程序员文章站
2022-06-17 17:22:13
...
Postman下载地址
打开Postman
添加索引
PUT http://192.168.203.132:9200/school
{
"settings":{
"number_of_shards":3,
"number_of_replicas":1
},
"mappings":{
"student":{
"properties":{
"stuName":{"type":"keyword"},
"age":{"type":"integer"},
"resume":{"type":"text","analyzer":"ik_smart"},
"tuition":{"type":"scaled_float","scaling_factor":100},
"hobbies":{"type":"keyword"},
"address":{
"properties":{
"province":{"type":"keyword"},
"city":{"type":"keyword"},
"district":{"type":"keyword"}
}
}
}
}
}
}
创建索引前
点击send就是发送创建索引的请求,下面会显示
{
"acknowledged": true,
"shards_acknowledged": true,
"index": "school"
}
这就是创建成功的意思,这样就会多出一个叫school的索引
新增数据
POST http://192.168.203.132:9200/school/student/1 再按send发送请求
为索引加一个student的类型,在该类下加一个条d是1的数据
{
"stuName":"张三",
"age":18,
"resume":"我是一个喜欢冒险的人,从小到大,阅人无数",
"tutition":26800.00,
"hobbies":["太极","游泳"],
"address":{
"province":"江苏",
"city":"南京",
"district":"雨花"
}
}
可以查询到添加的数据
删除数据
DELETE http://192.168.203.132:9200/school/student/1
修改数据
POST http://192.168.203.132:9200/school/student/1/_update
{
"doc":{
"tutition":16666.00
}
}
具体操作,和上面增加类似,不过把请求方式换成post
参看结果发现修改成功
查询
根据ID查询
GET http://192.168.203.132:9200/school/student/1
上一篇: JS中Attr的用法详解