elasticsearch经常使用命令备注

一、检查集群健康状态node

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

二、检查节点健康状态url

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

三、新增一条索引日志

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

四、查询当前索引blog

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

五、在索引中添加文档,本例中添加以下:文档

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

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":"管理员删除客户"}'

六、查询文档:

  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控制匹配经度

相关文章
相关标签/搜索