您的位置:首页 > 其它

elasticsearch命令curl(学习笔记)

2017-02-17 16:41 316 查看
好记性不如烂笔头,这年头少了笔多了互联网。是个好东西。
先知道一些elasticsearch的命令是干嘛的,才能写代码吧。呵呵

curl -XGET 'localhost:9200/_cat/indices?v&pretty' #查看索引
health status index                  pri rep docs.count docs.deleted store.size pri.store.size

green  open   xxx_xxx_2017-02-10   5   1          0            0      1.5kb           795b

green  open   xxx_xxx_2017-02-17   5   1         10            0      119kb         59.5kb

green  open   xxx_xxx_2017-02-14   5   1          0            0      1.5kb           795b

curl -XGET 'localhost:9200/_cat/nodes?v&pretty' #查看节点状态
host            ip              heap.percent ram.percent  load node.role master name  

192.168.151.190 192.168.151.190           10          83 -1.00 d         m      node-2

192.168.151.190 192.168.151.190            9          83 -1.00 d         *      node-1

192.168.151.190 192.168.151.190           20          83 -1.00 d         m      node-3
curl -XGET http://localhost:9200/_cluster/health?pretty   #查看集群状态
{

  "cluster_name" : "elasticsearch",

  "status" : "green",

  "timed_out" : false,

  "number_of_nodes" : 3,

  "number_of_data_nodes" : 3,

  "active_primary_shards" : 60,

  "active_shards" : 120,

  "relocating_shards" : 0,

  "initializing_shards" : 0,

  "unassigned_shards" : 0,

  "delayed_unassigned_shards" : 0,

  "number_of_pending_tasks" : 0,

  "number_of_in_flight_fetch" : 0,

  "task_max_waiting_in_queue_millis" : 0,

  "active_shards_percent_as_number" : 100.0

}
curl -XGET http://localhost:9200/_all  #查看所有索引信息

{"xxx_xxx_2017-02-17":{"aliases":{},"mappings":{"xxx":{"properties":{"Content":{"type":"string"},"ErrorType":{"type":"string"},"OrderID":{"type":"string"},"RequestType":{"type":"string"},"SessionID":{"type":"string"},"TimeStamp":{"type":"string"},"Type":{"type":"string"}}},"CarQuery":{"properties":{"Content":{"type":"string"},"RequestType":{"type":"string"},"SessionID":{"type":"string"},"TimeStamp":{"type":"string"}}}},"settings":{"index":{"creation_date":"1487297244079","uuid":"RIUMHuf5QROGUWOvxzVCkw","number_of_replicas":"1","number_of_shards":"5","version":{"created":"2030499"}}},"warmers":{}}}


curl -XDELETE 'http://localhost:9200/twitter,fgfg,ghjg/' #删除一个或多个索引 中间用,隔开 _all表示删除所有,并支持通配符*

curl -XGET
'http://localhost:9200/twitter/_settings,_mappings' #支持参数 The available features are
_settings
,
_mappings
,
_warmers
and
_aliases
.


JavaScriptAPI 调用

client.indices.get({index:'_all',feature:'_mappings'},function (error,response) {
//console.log("gel_allindex:"+ JSON.stringify(response));
});
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: