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"
}
}