elasticsearch常用命令

1.查看es版本

curl IP:9200

2.查看es集群节点列表

[root@bogon plugins]# curl '192.168.142.2:9400/_cat/nodes?v'
host                  ip            heap.percent ram.percent load node.role master name         
bogon                 192.168.142.2           41          47 0.00 d         *      172.22.7.52  
localhost.localdomain 127.0.0.1               24          30 0.00 d         m      172.22.7.53  
localhost.localdomain 127.0.0.1               23          29 0.10 d         m      172.22.28.87 
localhost.localdomain 127.0.0.1               25          30 0.00 d         m      172.22.7.54  
localhost.localdomain 127.0.0.1               29          29 0.10 d         m      172.22.28.86 
bogon                 192.168.142.2           28          47 0.00 d         m      172.22.28.88 

3.修改索引的副本个数

curl -XPUT ip:9200/ezview/_settings -d '{"number_of_replicas" : 3}'

查看副本个数

http://ip:9200/ezview/_settings/

4.更改刷新机制:不刷新

curl -XPUT ip:9200/ezview0816/_settings?pretty -d '{ "index" : { "refresh_interval" : "-1" } }'

5.清空数据:

#username:password目标机器的用户名 密码;index_name、type_name 以实际为准
curl -u username:password -XPOST 'ip:9200/index_name/type_name/_delete_by_query?refresh&slices=20&pretty' -H 'Content-Type: application/json' -d' {"query": {"match_all":{}}}'

6.es的text字段默认禁用,开启text({“acknowledged”:true},说明开启成功)

#index_name 索引名称                
#t_prop_vehicle 类型type                           
#F_START_TIME 需要开启的字段
curl -XPUT ip:9200/index_name/_mapping/t_prop_vehicle -d '{"properties": {"F_START_TIME": { "type":"text","fielddata": true}}}'

7.es查询和sql语法类比

sql elasticsearch
= {"term:{“SBBH”:“450200150036”}}
in {“terms”:{“SBBH”:[“450200150036”,“450200150037”]}}
like {“wildcard”:{“HPHM”:“桂3333”}}
between and {“range”:{“JGSJ”:{“gte”:“2016-01-01 00:00:00.000”,“lte”:“2016-01-31 23:59:59.000”}}}

8.es缓存查看

curl -XPOST 'http://ip:9200/indexname/_cache/clear'	#清除某一索引缓存
curl -XPOST 'ip:9200/_cache/_cache/clear'			#清除全部缓存
curl -XPOST 'ip:9200/indexname/_refresh'			#刷新
curl -XGET 'ip:9200/_stats/query_cache?pretty'		#查看缓存使用大小

9.查看mapping

curl -XGET 'ip:9200/indexname/_mapping?pretty'		#查看mapping

10.清除部分数据

curl  -XPOST '10.255.229.102:9200/kafka_es/b_bk_jgcl/_delete_by_query' -d '{"query":{"bool":{"must":[{"term":{"HPHM":"桂B3Y979"}}],"must_not":[],"should":[]}}}'

你可能感兴趣的:(elasticsearch)