ES(6): access elasticsearch via curl
curl是一个非常实用的、用来与服务器之间传输数据的工具;支持的协议包括 (DICT, FILE, FTP, FTPS, GOPHER, HTTP, HTTPS, IMAP, IMAPS, LDAP, LDAPS, POP3, POP3S, RTMP, RTSP, SCP, SFTP, SMTP, SMTPS, TELNET and TFTP),curl设计为无用户交互下完成工作,linux curl功能十分强大,命令参数十分多, 可运行“man curl”命令查看
目录:
- 访问ES:_cat系列
- 访问ES:_cluster系列
- 访问ES:_nodes系列
- 访问ES:{index}系列
访问ES:_cat系列
- /_cat/allocation
- /_cat/shards
- /_cat/master
- /_cat/nodes
- /_cat/indices
- /_cat/segments
- /_cat/count
- /_cat/recovery
- /_cat/health
- /_cat/pending_tasks
- /_cat/aliases
- /_cat/thread_pool
- /_cat/plugins
- /_cat/fielddata
- /_cat/XXXX/{index}
- 示例如下图:

访问ES:_cluster系列
- /_cluster/health?pretty (查询设置集群状态, pretty=true表示格式化输出)
- /_cluster/stats?pretty (显示集群系统信息,包括CPU JVM等等)
- /_cluster/state?pretty (集群的详细信息。包括节点、分片等)
- /_cluster/pending_tasks?pretty (获取集群堆积的任务)
- /_cluster/nodes/192.168.1.1/_shutdown (关闭指定节点)
- /_cluster/nodes/_master/_shutdown (关闭主节点)
- /_shutdown?delay=10s (delay=10s表示延迟10秒关闭所有节点)
- /_cluster/nodes/_shutdown 或 /_cluster/nodes/_all/_shutdown (关闭所有节点)
- 修改集群配置, transient 表示临时的,persistent表示永久的, 如下代码
/_cluster/settings -d '{
"persistent" : {
"discovery.zen.minimum_master_nodes" : 2
}
}' 
访问ES:_nodes系列
- /_nodes/stats?pretty=true
- /_nodes/192.168.1.2/stats?pretty=true
- /_nodes/process
- /_nodes/_all/process
- /_nodes/192.168.1.2,192.168.1.3/jvm,process
- /_nodes/192.168.1.2,192.168.1.3/info/jvm,process
- /_nodes/192.168.1.2,192.168.1.3/_all
- /_nodes/hot_threads

访问ES:{index}系列
- 简单创建索引: curl -XPUT 'http://10.0.0.5:12000/test/'
- 删除索引: curl -XDELETE 'http://10.0.0.5:12000/test/'
- 设置mapping,如下示例
curl -XPUT 'http://10.0.0.5:12000/etlstasday' -d '
{
"settings": {
"number_of_shards": 5,
"number_of_replicas": 1
},
"mappings": {
"etlstasday": {
"properties": {
"电站名称": {
"type": "text",
"fields": {
"keyword": {
"ignore_above": 256,
"type": "keyword"
}
}
},
"业务日期": {
"format": "yyyyMMddZ",
"type": "date"
},
"总电量": {
"type": "double"
},
"总收入(元)": {
"type": "double"
}
}
}
}
}' - mapping 字段类型参见:https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-types.html
- 插入数据,如下
curl -XPUT 'http://10.0.0.5:12000/etlstasday/etlstasday/1' -d '
{
"电站名称": "测试数据1",
"业务日期": "20160101+08:00",
"总电量": "",
"总收入(元)": ""
}' - 查询数据:curl -XGET 'http://10.0.0.5:12000/etlstasday/etlstasday/1'

- 查询某个索引下某个类型的所有记录: curl -XGET 'http://10.0.0.5:12000/etlstasday/etlstasday/_search?pretty'
- 查询某个索引下所有数据: curl -XGET 'http://10.0.0.5:12000/etlstasday/_search?pretty'
- 查询所有索引数据: curl -XGET 'http://10.0.0.5:12000/_search?pretty'
- 使用JSON参数的查询: (注意 query 和 term 关键字): $ curl localhost:9200/film/_search -d '{"query" : { "term": { "tag":"bad"}}}'
日常总结:
- 修改索引最大返回记录
PUT /索引名/_settings
{
"index" : {
"max_result_window" : 20000
}
}- 创建索引
ES(6): access elasticsearch via curl的更多相关文章
- ElasticSearch之CURL操作(有空再去整理)
https://www.cnblogs.com/jing1617/p/8060421.html ElasticSearch之CURL操作 CURL的操作 curl是利用URL语法在命令行方式下工 ...
- ES之四、Elasticsearch集群和索引常用命令
REST API用途 elasticsearch支持多种通讯,其中包括http请求响应服务,因此通过curl命令,可以发送http请求,并得到json返回内容. ES提供了很多全面的API,常用的RE ...
- Elasticsearch之curl创建索引库
关于curl的介绍,请移步 Elasticsearch学习概念之curl 启动es,请移步 Elasticsearch的前后台运行与停止(tar包方式) Elasticsearch的前后台运行与停止( ...
- Elasticsearch之CURL命令的DELETE
也可以看我写的下面的博客 Elasticsearch之curl删除 Elasticsearch之curl删除索引库 删除,某一条数据,如下 [hadoop@master elasticsearch-] ...
- Elasticsearch之CURL命令的UPDATE
对于,Elasticsearch之CURL命令的UPDATE包括局部更新和全部更新.可以去看我写的另一篇博客. Elasticsearch之更新(全部更新和局部更新) 总结: ES全部更新,使用PUT ...
- Elasticsearch之CURL命令的GET
这是个查询命令. 前期博客 Elasticsearch之CURL命令的PUT和POST对比 1. 以上是根据员工id查询. 即在任意的查询字符串中添加pretty参数,es可以得到易于我们识别的jso ...
- Elasticsearch之curl删除
扩展下, Elasticsearch之curl删除索引库 [hadoop@djt002 elasticsearch-2.4.3]$ curl -XDELETE 'http://192.168.80.2 ...
- Elasticsearch之curl创建索引库和索引时注意事项
前提, Elasticsearch之curl创建索引库 Elasticsearch之curl创建索引 注意事项 1.索引库名称必须要全部小写,不能以下划线开头,也不能包含逗号 2.如果没有明确指定索引 ...
- Elasticsearch之curl创建索引
前提,是 Elasticsearch之curl创建索引库 [hadoop@djt002 elasticsearch-2.4.3]$ curl -XPUT 'http://192.168.80.200: ...
随机推荐
- 微信小程序跨页面获取数据示例
index.wxml <navigator class="navs" url="{{urls}}"> 中国 </navigator> i ...
- 快速切题 sgu105. Div 3 数学归纳 数位+整除 难度:0
105. Div 3 time limit per test: 0.25 sec. memory limit per test: 4096 KB There is sequence 1, 12, 12 ...
- POJ 2195 Going Home 最小费用流 难度:1
Going Home Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 17955 Accepted: 9145 Descr ...
- Python3 urllib抓取指定URL的内容
最近在研究Python,熟悉了一些基本语法和模块的使用:现在打算研究一下Python爬虫.学习主要是通过别人的博客和自己下载的一下文档进行的,自己也写一下博客作为记录学习自己过程吧.Python代码写 ...
- NodeJS之express的路由浅析
路由路径和请求方法一起定义了请求的端点,它可以是字符串.字符串模式或者正则表达式.后端在获取路由后,可通过一系列类似中间件的函数去执行事务. 可使用字符串的路由路径: // 匹配根路径的请求 app. ...
- 无线Mesh网络技术基础与应用
无线Mesh网络主要包含三类节点,构成了Mesh的基本服务集. 1.与有线网络相连的节点(GateWay节点),其主要负责实现无线Mesh网络和有线网络的数据交换. 2.可以进行Mesh组网并拥有Ro ...
- mybatis左连接需要输出左表的指定内容与筛选
SELECT rpl.ID, rpl.DID, rpl.TRADE_TYPE, rpl.TRADE_TIME, rpl.CALL_TIME, rpl.TRADE_ADDR, rpl.RECEIVE_P ...
- C# winform 编程 向ACCESS数据库导入EXCEL表使用心得
public string MyConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=ErLake.mdb&quo ...
- webstrom git 版本控制
1.配置 2.用法
- 查看Linux下系统资源占用常用命令
一 top命令 1.作用top命令用来显示执行中的程序进程,使用权限是所有用户. 2.格式top [-] [d delay] [q] [c] [S] [s] [i] [n] 3.主要参数d:指定更新的 ...