支持用户权限认证、POST请求携带参数
检查es是否运行正常:
➔ curl http://localhost:9200
{
"name" : "-4IiLdf",
"cluster_name" : "elasticsearch",
"cluster_uuid" : "8IP_wotKSqyf5ZCCrOTzVw",
"version" : {
"number" : "5.5.3",
"build_hash" : "9305a5e",
"build_date" : "2017-09-07T15:56:59.599Z",
"build_snapshot" : false,
"lucene_version" : "6.6.0"
},
"tagline" : "You Know, for Search"
}
所有_cat API:
➔ curl http://localhost:9200/_cat
=^.^=
/_cat/allocation
/_cat/shards
/_cat/shards/{index}
/_cat/master
/_cat/nodes
/_cat/tasks
/_cat/indices
....(省略)
查看所有索引:
➔ curl http://localhost:9200/_cat/indices
yellow open slicejobs-legacy NsHD8V9MRMeRhlDowTtDiA 5 1 55621 16912 47.4mb 47.4mb
yellow open msgcenter YiCEcTFmT1KUd_kThuSHFQ 5 1 2066 0 619.6kb 619.6kb
yellow open devmsgcenter 1htAavGWQB6JKODvlKEqjQ 5 1 0 0 970b 970b
yellow open users ONcogqIIRDGJQXJAp8ph3w 5 1 2808 53 2.6mb 2.6mb
查看一个索引的mapping:
➔ curl 'http://localhost:9200/devorders/_mapping?pretty'
{
"devorders": {
"mappings": {
"order": {
"dynamic": "false",
"date_detection": false,
"properties": {
"adminid": {
"type": "integer"
},
"adminname": {
"type": "keyword"
},
"advertise": {
"type": "byte"
},
"appointuserid": {
"type": "integer"
},
}
}
}
}
}
示例1:
curl -u username:password -X PUT 'http://es-svc-dev:9200/devorders/order?pretty' -H 'Content-Type: application/json;charset=UTF-8' --data-binary '{"name":"dsfsfadfasf","undertake_license_tpl":"fasdfsaf","delegate_license_tpl":"sfadfdasfasdf"}'
示例2:
curl -X POST 'http://es-svc-dev:9200/devorders/order/_search?pretty' --header 'Content-Type: application/json' --data "@/root/data.json"
/root/data.json文件内容:
{
"size": 0,
"query": {
"bool": {
"must": [
{
"term": {
"batchid": 4868
}
}
]
}
},
"aggs": {
"group_by_batchid": {
"terms": {
"field": "batchid",
"size": "1000000"
},
"aggs": {
"group_by_status": {
"terms": {
"field": "status"
}
}
}
}
}
}