#创建索引
a.put创建
curl -XPUT http://localhost:9200/shb01/student/1-d'{"name":"jack","age":30,"info":"Ilove you"}'
返回:{"_index":"shb01","_type":"student","_id":"1","_version":1,"created":true}
执行put后有返回值
_index索引名称
_type类型名
_version版本号
created:true表示是新创建的。
上面的命令每执行一次version就会加1,-XPUT必须制定id。

b.post创建
curl -XPOST http://localhost:9200/shb01/student -d'{"name":"tom","age":21,"info":"tom"}'
返回:{"_index":"shb01","_type":"student","_id":"AVadzuNgxskBS1Rg2tdp","_version":1,"created":true}

#查看es集群状态
http://ip:port/_cat/health?v

#集群节点健康查看
http://ip:port/_cat/nodes?v

#查询所有索引,pretty:格式化
curl -XGET 'localhost:9200/_cat/indices?v&pretty'

#查询返回最近10条
curl -XPOST 'localhost:9200/logstash-zhifubao-2018.09.18/_search?pretty' -d '{"query": { "match_all": {} },"from": 10,"size": 10}'

#查询索引状态
curl -XGET http://localhost:9200/logstash-zhifubao-2018.08.15/_status

#查询某一个索引
curl -XGET http://localhost:9200/logstash-zhifubao-2018.08.15/message/0ea1b2df-caa4-457c-8cc1-294f5e9284c7/_search?pretty

#根据business_no查询,多个条件用逗号拼接
curl -XGET http://localhost:9200/logstash-zhifubao-2018.08.15/_search?q=message:0ea1b2df-caa4-457c-8cc1-294f5e9284c7
#根据business_no查询,只返回特定字段
curl -XGET http://localhost:9200/logstash-zhifubao-2018.08.15/_search?q=message:0ea1b2df-caa4-457c-8cc1-294f5e9284c7?_source=message

#查询集群状态
Curl –XGET http://localhost:9200/_cluster/health?pretty
http://localhost:9200/_cluster/health?pretty

#多索引,多类型查询,分页查询,超时
Curl:curl -XGET http://localhost:9200/shb01,shb02/stu,tea/_search?pretty
curl -XGET http://localhost:9200/_all/stu,tea/_search?pretty

#分页
curl -XGET http://localhost:9200/shb01/stu/_search?size=2&from=0

#更新部分字段
crul –XPUT http:localhost:9200/shb01/student/1/_update?version=1
–d ‘{“doc”:{“name”:”updatename”}

#根据id删除
curl -XDELETE http://localhost:9200/shb01/student/AVad05EExskBS1Rg2tdq

#删除所有的索引库中名称为tom的文档
curl -XDELETE http://localhost:9200/_all/_query?q=name:tom

#批处理
a.在/usr/local/下新建t.txt文件,文件内容为
{"index":{"_index":"shb01","_type":"student","_id":"1"}}
{"name":"st01","age":"10","info":"st01"}
{"create":{"_index":"shb100","_type":"student","_id":"2"}}
{"name":"tea01","age":"10","info":"tea01"}
{"delete":{"_index":"shb01","_type":"student","_id":"AVadzuNgxskBS1Rg2tdp"}
{"update":{"_index":"shb02","_type":"tea","_id":"1"}}
{"doc":{"name":"zszszszs"}}
b.执行批处理命令,关键字_bulk
curl -XPUThttp://localhost:9200/_bulk --data-binary @/usr/local/t

#_cluster系列
1、查询设置集群状态
curl -XGET localhost:9200/_cluster/health?pretty=true
pretty=true表示格式化输出
level=indices 表示显示索引状态
level=shards 表示显示分片信息
2、curl -XGET localhost:9200/_cluster/stats?pretty=true
显示集群系统信息,包括CPU JVM等等
3、curl -XGET localhost:9200/_cluster/state?pretty=true
集群的详细信息。包括节点、分片等。
3、curl -XGET localhost:9200/_cluster/pending_tasks?pretty=true
获取集群堆积的任务

#索引参数相关
URL 说明
/index/_search 不解释
/_aliases 获取或操作索引的别名
/index/
/index/type/ 创建或操作类型
/index/_mapping 创建或操作mapping
/index/_settings 创建或操作设置(number_of_shards是不可更改的)
/index/_open 打开被关闭的索引
/index/_close 关闭索引
/index/_refresh 刷新索引(使新加内容对搜索可见)
/index/_flush
刷新索引
将变动提交到lucene索引文件中
并清空elasticsearch的transaction log,
与refresh的区别需要继续研究
/index/_optimize 优化segement,个人认为主要是对segement进行合并
/index/_status 获得索引的状态信息
/index/_segments 获得索引的segments的状态信息
/index/_explain 不执行实际搜索,而返回解释信息
/index/_analyze 不执行实际搜索,根据输入的参数进行文本分析
/index/type/id 操作指定文档,不解释
/index/type/id/_create 创建一个文档,如果该文件已经存在,则返回失败
/index/type/id/_update 更新一个文件,如果改文件不存在,则返回失败

#集群参数相关
URL 说明
/_cluster/nodes 获得集群中的节点列表和信息
/_cluster/health 获得集群信息
/_cluster/state 获得集群里的所有信息(集群信息、节点信息、mapping信息等)

#Nodes参数相关
URL 说明
/_nodes/process 我主要看file descriptor 这个信息
/_nodes/process/stats 统计信息(内存、CPU能)
/_nodes/jvm 获得各节点的虚拟机统计和配置信息
/_nodes/jvm/stats 更详细的虚拟机信息
/_nodes/http 获得各个节点的http信息(如ip地址)
/_nodes/http/stats 获得各个节点处理http请求的统计情况
/_nodes/thread_pool
获得各种类型的线程池
(elasticsearch分别对不同的操作提供不同的线程池)的配置信息
/_nodes/thread_pool/stats 获得各种类型的线程池的统计信息

以上这些操作和可以通过如
/_nodes/${nodeId}/jvm/stats
/_nodes/${nodeip}/jvm/stats
/_nodes/${nodeattribute}/jvm/stats
的形式针对指定节点的操作。

elasticSearch curl 语法总结的更多相关文章

  1. elasticsearch curl operation

    Elastic Search API Index.简单的介绍了使用Elastic Search 如何建立索引. ElasticSearch-API-Index 索引创建API允许初始化一个索引.Ela ...

  2. ElasticSearch 查询语法

    ElasticSearch是基于lucene的开源搜索引擎,它的查询语法关键字跟lucene一样,如下: 分页:from/size 字段:fields 排序:sort 查询:query 过滤:filt ...

  3. Elasticsearch CURL命令

    1.查看集群状态 curl '10.18.37.223:9200/_cat/health?v'绿色表示一切正常, 黄色表示所有的数据可用但是部分副本还没有分配,红色表示部分数据因为某些原因不可用 2. ...

  4. elasticsearch 基础 语法总结

    1. es 使用 restful 风格的 api 备注: es 的 api  格式  基本是这个样     请求方式    /索引名/文档名/id?参数   ,但是 还有 很多不是这样的 请求,比如 ...

  5. Elasticsearch基本语法

    match和match_phrase区别 match: 索引中只要有任意一个匹配拆分后词就可以出现在结果中,只是匹配度越高的排越前面 match_phrase: 索引中必须同时匹配拆分后词就可以出现在 ...

  6. elasticsearch基本概念与查询语法

    序言 后面有大量类似于mysql的sum, group by查询 elk === elk总体架构 https://www.elastic.co/cn/products Beat 基于go语言写的轻量型 ...

  7. Elasticsearch基本CURD操作语法讲解

    当我们的ES集群搭建完成以后,我怎么能看到集群中各个节点状态以及主节点和健康情况呢,如下讲解使用curl命令来与ES集群进行交互.分别有查询主节点情况.集群状态.以及创建索引查看索引.查看分片以及对E ...

  8. Elasticsearch学习总结 (Centos7下Elasticsearch集群部署记录)

    一.  ElasticSearch简单介绍 ElasticSearch是一个基于Lucene的搜索服务器.它提供了一个分布式多用户能力的全文搜索引擎,基于RESTful web接口.Elasticse ...

  9. 02.Elasticsearch入门

        Elasticsearch支持Http类型的Restful风格API请求,需要打开9200端口.Elasticsearch服务会监听两个端口9200和9300,9200提供Http Restf ...

随机推荐

  1. Action Bar

    1.显示隐藏Action Bar 1.配置上 在application 上的 android:theme="@style/AppTheme"全局配置ActionBar在某个acti ...

  2. [PHP] 商品类型规格属性后台管理(代码流程备忘)

    实现界面 涉及到四张表,type(商品类型表),type_spec(商品类型规格关联表),attribute(商品属性表),attribute_value(商品属性值表) 新建基控制器BaseCont ...

  3. 分析Ethernet标准和Ieee802.3标准规定的MAC层帧结构

    分析所用软件下载:Wireshark-win32-1.10.2.exe 阅读导览 1. 学习Wireshark的安装与使用 2. 熟悉Wireshark的操作界面与功能 3. 设计应用以获取以太网链路 ...

  4. js 数组删除元素,并获得真实长度

    前言:js数组删除一般采用数组的 splice 方法和 delete 方法,但是采用 delete 方法后直接数组.kength 来获取数组长度是获取不了真实长度的,下面详细讲解一下. 一.splic ...

  5. 纠错帖:Zuul & Spring Cloud Gateway & Linkerd性能对比 (转载)

    纠错帖:Zuul & Spring Cloud Gateway & Linkerd性能对比  Spring Cloud  Spring Cloud Spring Cloud Gatew ...

  6. Linux 调试: systemtap

    安装与配置 在ubuntu下直接用apt-get install之后不能正常使用,提示缺少调试信息或者编译探测代码时有问题. 1. 采用官网上的解决方法 2. 可以自己重新编译一次内核,然后再手工编译 ...

  7. js移动终端浏览器版本

    //当要在不同移动终端浏览器中运行不同的代码时,需要对各个终端浏览器进行判断 //判断浏览器 var browser = { versions: function () { var u = navig ...

  8. mysqli 更新&插入操作及事务

    $mysqli = new mysqli('localhost', 'root', '1234', 'shop'); $query1 = " update sw_goods set good ...

  9. 关于redux

    react将dom解耦,不用直接操作dom,使用了状态机制,当状态改变时视图就会相应更新.我们知道在react中,父组件可以将一些状态传递给子组件,让子组件的视图相应更新,这时我们会发现,只有有关联的 ...

  10. Object hashcode

    java jvm怎么找到一个对象? 一个对象有一个独一无二的hashcode,这样就可以找到这个对象了. 但java 的hashcode 实现的不好,有可能两个不同的对象有一个相同的hashcode, ...