之前我们介绍有java api 操作elasticsearch,今天我们介绍下使用curl的方式进行操作elasticsearch,这里主要在head插件里面进行操作
一、索引相关
1)创建索引
请求地址是:http://192.168.31.20:9200/test
请求方式是:put
请求body是:
{
"settings": {
"index": {
"number_of_shards": "2",
"number_of_replicas": "1"
}
},
"mappings": {
"properties": {
"name": {
"type": "text"
},
"model": {
"type": "keyword"
}
}
},
"aliases": {}
}2)查看索引
请求地址是:http://192.168.31.20:9200/test/_settings 请求方式是:GET
3)修改索引
请求地址:http://192.168.31.20:9200/test/_settings
请求方式:put
请求body:
{
"number_of_replicas": "2"
}4)删除索引
请求地址:http://192.168.31.20:9200/test 请求方式:DELETE
二、插入数据
1)插入一条数据
请求地址:http://192.168.31.20:9200/test/_doc
请求方式:post
请求body:
{
"name": "zhangsan",
"password": "123456"
}三、查询数据
1)查询全部
请求地址:http://192.168.31.20:9200/_search 请求方式:POST
2)在单个index里面查询
请求地址:http://192.168.31.20:9200/test/_doc/_search 请求方式:post
3)根据条件进行查询
请求地址:http://192.168.31.20:9200/test/_doc/_search
请求方式:post
请求body:
{
"query": {
"bool": {
"must": [
{
"term": {
"password": "123456"
}
}
]
}
}
}四、更新数据
1)更新数据
请求地址:http://192.168.31.20:9200/test/_doc/q2Z7zYEBa29IIbHz2kaZ/_update
请求方式:post
请求body:
{
"doc": {
"password": "111"
}
}五、删除数据
请求地址:http://192.168.31.20:9200/test/_doc/q2Z7zYEBa29IIbHz2kaZ 请求方式:DELETE

还没有评论,来说两句吧...