【ELK】ElasticSearch Kibana入门整理

本文详细介绍了如何在ElasticSearch中进行安装、创建索引、设置副本数、删除索引以及使用Kibana进行查询,包括基本的全量查询、指定字段查询和布尔条件搜索示例。
摘要由CSDN通过智能技术生成

elk安装包
ElasticSearch教程——Kibana简单操作ES
ElasticSearch教程——创建索引、类型、文档

1、 #查询所用索引信息

GET _search
{
  "query": {
    "match_all": {}
  }
}

2、#创建索引

PUT /whclogtest
{
    "settings": {
        "number_of_shards" :   5,
        "number_of_replicas" : 0
    }
}


PUT /testadd
{
    "settings": {
        "number_of_shards" :   5,
        "number_of_replicas" : 0
    }
}

3、#查看索引信息

GET /whclogtest

4、#修改索引副本数

PUT /whclogtest/_settings
{
  "number_of_replicas":2
}

5、#删除索引

DELETE /testadd
#或者
DELETE /testadd*

6、#查询索引所用文档

GET /whclogtest/_search
{
  "query": {
    "match_all": {}
  }
}

7、只查询显示type和host… (GET 或POST)

GET /whclogtest/_search
{
  "query": {
    "match_all": {}
  },
  "_source": ["type","host","message"]
}

8、#返回message包含ccplogin的document

POST /whclogtest/_search
{
  "query": { "match": { "message": "ccplogin" } }
}

9、#返回message包ccplogin和1k的document

POST /whclogtest/_search
{
  "query": {
    "bool": {
      "must": [
        {
          "match": {
            "message": "ccplogin"
          }
        },
        {
           "match": {
            "message": "1k"
          }
        }
      ]
    }
  }
}

10、#返回message包8k或ccplogin的document

POST /whclogtest/_search
{
  "query": {
    "bool": {
      "should": [
        {"match": {
          "message": "whc"}},
        {"match": {
            "message": "ccplogin"}}
      ]
    }
  }
}

Demo

POST /ecommerce/product
{
    "name" : "脉动",
    "desc" :  "this is 脉动 你好",
    "price" :  90,
    "producer" :      "脉动饮料",
    "tags": [ "饮料", "脉动" ]
}
GET /ecommerce/product/_search
{
  "query": {
    "match_all": {}
  }
}

GET /ecommerce/product/1 
GET /ecommerce/product/_search
{
    "query" : {
        "match" : {
            "desc": "哈哈脉"
        }
    }
}
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值