//查看_cat支持的信息kibana: GET /_catbash: curl -XGET -u elastic:26tBktGolYCyZD2pPISW'http://192.168.31.215:9201/_cat' //查看主节点信息kibana: GET /_cat/master?vbash: curl -XGET -u elastic:26tBktGolYCyZD2pPISW'http://192.168.31.215:9201/_cat/master?v' //查看集群所有节点kibana: GET /_cat/nodes?vbash: curl -XGET -u elastic:26tBktGolYCyZD2pPISW'http://192.168.31.215:9201/_cat/nodes?v' //查看所有索引信息kibana: GET /_cat/indices?vbash: curl -XGET -u elastic:26tBktGolYCyZD2pPISW'http://192.168.31.215:9201/_cat/indices?v' //查看单个索引信息kibana: GET /_cat/indices/movies?vbash: curl -XGET -u elastic:26tBktGolYCyZD2pPISW'http://192.168.31.215:9201/_cat/indices/movies?v' //查看所有分片信息kibana: GET /_cat/shards?vbash: curl -XGET -u elastic:26tBktGolYCyZD2pPISW'http://192.168.31.215:9201/_cat/shards?v' //查看单个索引分片信息kibana: GET /_cat/shards/movies?vbash: curl -XGET -u elastic:26tBktGolYCyZD2pPISW'http://192.168.31.215:9201/_cat/shards/movies?v' //查看集群健康状态
kibana: GET /_cat/health?vkibana: GET _cluster/healthbash: curl -XGET -u elastic:26tBktGolYCyZD2pPISW'http://192.168.31.215:9201/_cat/health?v'bash: curl -XGET -u elastic:26tBktGolYCyZD2pPISW'http://192.168.31.215:9201/_cluster/health?pretty' //查看插件kibana: GET /_cat/plugins?vbash: curl -XGET -u elastic:26tBktGolYCyZD2pPISW'http://192.168.31.215:9201/_cat/plugins?v' //查看所有索引文档总数kibana: GET _all/_countbash: curl -XGET -u elastic:26tBktGolYCyZD2pPISW'http://192.168.31.215:9201/_all/_count?pretty' //查看指定索引文档总数kibana: GET movies/_countbash: curl -XGET -u elastic:26tBktGolYCyZD2pPISW'http://192.168.31.215:9201/movies/_count?pretty' //查看所有模板kibana: GET _cat/templatesbash: curl -XGET -u elastic:26tBktGolYCyZD2pPISW'http://192.168.31.215:9201/_cat/templates?v' //查看状态为绿的索引kibana: GET /_cat/indices?v&health=greenbash: curl -XGET -u elastic:26tBktGolYCyZD2pPISW'http://192.168.31.215:9201/_cat/indices?v&health=green' //查看movies索引元数据kibana: GET moviesbash: curl -XGET -u elastic:26tBktGolYCyZD2pPISW'http://192.168.31.215:9201/movies?pretty' //按照文档数量排序索引kibana: GET _cat/indices?v&s=docs.count:descbash: curl -XGET -u elastic:26tBktGolYCyZD2pPISW'http://192.168.31.215:9201/_cat/indices?v&s=docs.count:desc' //查看各个索引占用内存大小并进行排序kibana:bash: curl -XGET -u elastic:26tBktGolYCyZD2pPISW'http://192.168.31.215:9201/_cat/indices?v&h=i,tm&s=tm:desc'
Elasticsearch CURD语法
CURD
请求方式
主体
说明
Create
PUT
/index/_create/id
指定Document ID,创建文档,如果ID已存在,则失败
Create
POST
/index/_create/id
指定Document ID,创建文档,如果ID已存在,则失败
Create
POST
/index/_doc
自动生成ID,不会重复,重复提交则创建多个文档,文档版本都为1
Index
PUT
/index/_doc/id
如果ID不存在,则创建新的文档,如果ID存在,则删除现有文档后创建新的文档,版本+1,ID相同
Index
POST
/index/_doc/id
如果ID不存在,则创建新的文档,如果ID存在,则删除现有文档后创建新的文档,版本+1,ID相同
Read
GET
/index/_doc/id
查看Document ID为1的文档
Update
POST
/index/_doc/id
文档必须存在,否则更新失败,只能增量修改字段,不能减少字段,字段值可以随意修改,版本加1
Delete
Delete
/index/_doc/id
文档必须存在,否则删除返回"not_found"
Delete
Delete
/index
删除索引,索引内的文档也会被随之而删除,要删除的索引必须存在,否则返回 "404"
Create创建索引及文档
Create一个文档时,Elasticsearch支持自动生成文档ID和指定文档ID两种方式。
1.通过调用 POST /index/_doc 语法,系统自动生成文档Document ID。此种方法,即使创建的JSON文档重复,Document ID也不一致,如果重复使用POST多次提交,Elasticsearch将会创建多个内容重复但ID不一致的文档。2.通过调用 POST /index/_create/id或PUT /index/_create/id语法,则手动指定生成Document ID,此种方法,如果我们指定ID的文档已存在,则创建失败,反正创建文档。
GET _mget{"docs":[//docs为mget格式{"_index":"bulk_index",//指定要读取文档的索引"_id":1//指定读取文档的ID},{"_index":"bulk_index",//同一索引内的不同ID联合读取"_id":2},{"_index":"index",//不同索引中的不同ID联合读取"_id":1}]}
结果如下:
MSEARCH 批量查询
msearch全称 Multi Serach API是一个可以进行条件匹配查询的语法 GET //_msearch