ES的几个简单restful接口

1、查看es版本和状态

curl --user username:password localhost:9200

2、查看索引

curl --user username:password localhost:9200/_cat/indices?v

3、删除索引

curl --user username:password -X DELETE localhost:9200/scbb_prd_zl_new

4、查看ES节点

curl --user username:password localhost:9200/_cat/nodes?v

5、修改索引参数

curl --user username:password -H "Content-Type: application/json" -X PUT localhost:9200/scbb_prd_zl/_settings -d '{ "index.max_result_window" :"1000000"}'

6、查看索引设置

curl --user username:password localhost:9200/index_name/_settings

7、查询所有数据

curl --user username:password localhost:9200/index_name/_search

8、根据id查询数据

curl --user username:password localhost:9200/index_name/id

curl localhost:9200/index_name/_doc/id

9、查看索引mapping

curl --user xxx:xxx http://localhost:9200/index?pretty

10、创建索引模板

curl --user xxx:xxx -X PUT localhost:9200/_index_template/my_test_logs -H 'Content-Type: application/json' -d \
'{"index_patterns":["applog-*"],"template":{"settings":{"number_of_shards":1},"mappings":{"_source":{"enabled":true},"properties":{"service_name":{"type":"keyword"},"log_datetime":{"type":"date","format": "yyyy-MM-dd HH:mm:ss.SSS"},"log_level":{"type":"keyword"},"thread_name":{"type":"keyword"},"interface_name":{"type":"keyword"},"line":{"type":"integer"},"message":{"type":"text"}}},"aliases":{"mydata":{}}},"priority":500,"version":3,"_meta":{"description":"my custom"}}'

11、创建索引

curl --user username:pwd -H "Content-Type: application/json" -X PUT localhost:9200/sckb_sms_prd -d '{"mappings":{"properties":{"city_code":{"type":"text"},"create_time":{"type":"date"},"function_type":{"type":"text"},"id":{"type":"keyword"},"parent_code":{"type":"text"},"receivers_count":{"type":"long"},"school_id":{"type":"long"},"type_id":{"type":"long"}}}}'

12、插入数据

curl -X POST "localhost:9200/logs-my_app-default/_doc?pretty" -H 'Content-Type: application/json' -d'
{
  "@timestamp": "2099-05-06T16:21:15.000Z",
  "event": {
    "original": "192.0.2.42 - - [06/May/2099:16:21:15 +0000] \"GET /images/bg.jpg HTTP/1.0\" 200 24736"
  }
}
'
POST logs-my_app-default/_doc
{
  "@timestamp": "2099-05-06T16:21:15.000Z",
  "event": {
    "original": "192.0.2.42 - - [06/May/2099:16:21:15 +0000] \"GET /images/bg.jpg HTTP/1.0\" 200 24736"
  }
}

  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值