首页 > 其他分享 >elasticsearch中使用curl进行的简单查询

elasticsearch中使用curl进行的简单查询

时间:2022-08-20 01:55:05浏览次数:85  
标签:http -- ip 查询 elasticsearch pretty curl port

curl:
-X :指定http的请求方式,有HEAD、GET、POST、PUT、DELETE
-d :指定要传输的数据
-H :指定http的请求头信息
curl -XPUT http://ip:port/索引名?pretty-- 创建索引
curl -XGET http://ip:port/_cat/indices?v --查看当前es的所有索引信息
curl -XGET http://ip:port/索引名?pretty --查看单个索引信息
curl -XDELETE http://ip:port/索引名?pretty --删除索引
curl -H "Content-Type:application/json" -XPOST http://ip:port/索引名/_doc/01?pretty -d '{"id":"34234","name":"李四"}' --新增修改一条document文档信息,documentId为01
curl -XGET http://ip:port/索引名/_doc/01?pretty --查询documentId为01的一条数据
curl -H "Content-Type:application/json" -XPOST http://ip:port/索引名/_update/1?pretty -d '{"id":"34234"}' --修改documentId为1的指定一个字段
curl -XDELETE http://ip:port/索引名/_doc/1?pretty --删除指定documentId的一条数据
curl -H "Content-Type:application/json" -XPOST http://ip:port/索引名/_doc/_delete_by_query?pretty -d '{"query":{"match":{"name":"赵"}}}' --条件删除
curl -XGET http://ip:port/索引名/_search?pretty --查询指定所有库的所有数据
curl -XGET http://ip:port/索引名/_search?_source=name?pretty --查询指定索引库的所有数据记录的name值
curl -XGET 'http://ip:port/索引名/01?_source=name&pretty' --查询documentId为01的数据记录的name值

curl -H "Content-Type:application/json" -XGET http://ip:port/索引名/_search?pretty -d '{"query":{"match_all":{}}}' -- 查询所有数据
curl -H "Content-Type:application/json" -XGET http://ip:port/索引名/_search?pretty -d '{"query":{"match_all":{}},"size":2}' -- 指定条数
curl -H "Content-Type:application/json" -XGET http://ip:port/索引名/_search?pretty -d '{"query":{"match_all":{}},"from":0,"size":2}' -- 分页查询
curl -H "Content-Type:application/json" -XGET http://ip:port/索引名/_search?pretty -d '{"query":{"match_all":{}},"_source":["name","id"]}' -- 查询指定列
curl -H "Content-Type:application/json" -XGET http://ip:port/索引名/_search?pretty -d '{"query":{"match_all":{}},"sort":{"price":{"order":"desc"}}}' -- 分页查询
curl -H "Content-Type:application/json" -XGET http://ip:port/索引名/_search?pretty -d '{"query":{"match":{"name":"赵"}}}' --模糊匹配 match
curl -H "Content-Type:application/json" -XGET http://ip:port/索引名/_search?pretty -d '{"query":{"bool":{"must":{"match":{"name":"赵"}}}}}' --多条件查询 bool must:必须满足的条件,must_not:必须不能满足的条件,should:应该,可有可无,或者
curl -H "Content-Type:application/json" -XGET http://ip:port/索引名/_search?pretty -d '{"query":{"term":{"name":"赵雷"}}}' --精准查询term
curl -H "Content-Type:application/json" -XGET http://ip:port/索引名/_search?pretty -d '{"query":{"terms":{"name":["赵雷",""]}}}' --精准多个词匹配
curl -H "Content-Type:application/json" -XGET http://ip:port/索引名/_search?pretty -d '{"query":{"range":{"age":{"gt":"20","lte":"25"}}}}' --范围查询
curl -XGET http://ip:port/索引名/mapping --查看映射
curl -XGET http://ip:port/cluster/health --查看集群状态
————————————————
版权声明:本文为CSDN博主「浅谈
」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/wangqinyi574110/article/details/107900826

标签:http,--,ip,查询,elasticsearch,pretty,curl,port
From: https://www.cnblogs.com/dhcc/p/16607035.html

相关文章