elasticsearch学习心得

来源:互联网 发布:linux tweak yool 编辑:程序博客网 时间:2024/06/11 15:11
 elasticsearch索引的增删改查有一个类似的格式,总结如下:
  curl -X<REST Verb> <Node>:<Port>/<Index>/<Type>/<ID>/<operation>   //其中operation可为:_update、_search
  <REST Verb>:REST风格的语法谓词
  <Node>:节点ip
  <port>:节点端口号,默认9200
  <Index>:索引名
  <Type>:索引类型
  <ID>:操作对象的ID号


//REST Verb 可为DELETE、POST、PUT




//查询特定区域内的数据
curl -XPOST '192.168.211.50:9200/users/_search?pretty' -d '{"query": { "match_all": {} },"from":10,"size": 10}'
//查询特定区域内且降序排列的数据
curl -XPOST '192.168.211.50:9200/users/_search?pretty' -d '{"query": { "match_all": {} },"from":10,"size": 10,"sort": { "age": { "order": "desc" } }}'
//查询匹配字段
curl -XPOST '192.168.211.50:9200/users/_search?pretty' -d '{"query": { "match": {"age":80} }}'
//删除索引
curl -XDELETE '192.168.211.50:9200/users?pretty'
//查看索引
curl '192.168.211.50:9200/_cat/indices?v'
//创建索引
curl -XPUT '192.168.211.50:9200/users?pretty'
//查看节点列表
curl '192.168.211.50:9200/_cat/nodes?v'
//查看集群是否健康

curl '192.168.211.50:9200/_cat/health?v'



安装Elasticsearch注意的地方:

> vim /etc/elasticsearch/elasticsearch.yml
加上如下三句:
network.host: 192.168.20.50   
http.port: 9200
bootstrap.system_call_filter: false  # 针对 system call filters failed to install

复制代码
> vim /etc/security/limits.conf 
文件最后加上如下两句:siem是仅次于root权限的用户
siem hard nofile 65536  # 针对 max file descriptors
siem soft nproc 2048    # 针对 max number of threads
 
> vim /etc/sysctl.conf
vm.max_map_count=262144











原创粉丝点击