elasticsearch常用命令备注

1、检查集群健康状态

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

2、检查节点健康状态

  curl 'localhost:9200/_cat/nodes?v'

3、新增一条索引

  curl -XPUT 'localhost:9200/fred_log?pretty'

4、查询当前索引

  curl 'localhost:9200/_cat/indices?v'

5、在索引中添加文档,本例中添加如下:

备注:fred_log为索引名称、log为type

curl -XPUT 'localhost:9200/fred_log/log/1?pretty' -d '{"name": "Fredric"}'
    curl -XPUT 'localhost:9200/fred_log/log/2?pretty' -d '{"name": "Sinny"}'
    curl -XPUT 'localhost:9200/fred_log/log/3?pretty' -d '{"name": "故障企业日志"}'
    curl -XPUT 'localhost:9200/fred_log/log/4?pretty' -d '{"name": "业务企业日志"}'
    curl -XPUT 'localhost:9200/fred_log/log/5?pretty' -d '{"title": "企业日志", "type":"CRM模块", "content":"管理员添加客户"}'
    curl -XPUT 'localhost:9200/fred_log/log/6?pretty' -d '{"title": "企业日志", "type":"CRM模块", "content":"管理员删除客户"}'

6、查询文档:

  curl -XGET 'localhost:9200/fred_log/log/4?pretty'  

  

  curl -XGET 'localhost:9200/fred_log/log/_search' -d '{ "query": { "match": {"name": "企业"}}}'

  curl -XGET 'localhost:9200/fred_log/log/_search' -d '{"query": {"bool": {"must": [{ "match": { "type": "CRM" }},{ "match": { "content": "删除" }}]}}}'

备注:若将must改变为should则条件不为必须满足,但可以通过minimum_should_match控制匹配经度

原文地址:https://www.cnblogs.com/Fredric-2013/p/7447859.html