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

无所事事1年前日常记录376

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

标签: Elasticsearch

相关文章

ElasticSearch搜索建议与上下文提示

ElasticSearch搜索建议与上下文提示

搜索建议通过Suggester Api实现原理是将输入的文本分解为Token,然后在词典中查找类似的Term返回根据不同场景,ElasticSearch设计了4中类别的Suggesters。Term...

Elasticsearch之中文分词器插件es-ik的自定义词库

【 ik 自定义词库步骤】1:创建词典首先在 ik 插件的 config/custom 目录下创建一个文件 zhouls.dic (当然这个你可以自己命名,如my.dic都行)在文件中添加词语即可,...

elasticsearch 开机自启动——/etc/init.d

开机自启动,就是在系统启动后,自行启动elasticsearch,无需手动启动。一、查看已存在的开机启动项[root@qf01 ~]# chkconfig --list显...

帝国CMS7.5基于es(Elasticsearch)7.x的全文搜索插件

帝国CMS7.5基于es(Elasticsearch)7.x的全文搜索插件

一、插件演示地址后台演示地址:https://ecms.gxecms.cf/e/admin/index.php用户名:demo密码:demo前台演示页面:https://ecms.gxecms.cf/...

Elasticsearch配置IK分词器的远程词库

Elasticsearch配置IK分词器的远程词库

我们把es和ik分词器安装完毕后,即可开始配置词库,在es中默认有提供一些词库,过滤一些语气词等;在安装的es的根路径下有一个\plugins\ik\config路径,下面有一个IKAnalyzer....

发表评论    

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。