ElasticSearch6 kibana查询

1、保存数据

PUT /megacorp/employee/2
{
    "first_name" :  "Jane",
    "last_name" :   "Smith",
    "age" :         32,
    "about" :       "I like to collect rock albums",
    "interests":  [ "music" ]
}

PUT /megacorp/employee/3
{
    "first_name" :  "Douglas",
    "last_name" :   "Fir",
    "age" :         35,
    "about":        "I like to build cabinets",
    "interests":  [ "forestry" ]
}




2、设置maping

PUT  /data/http_record/_mapping?pretty
{
  "http_record":{
    "properties":{
       
        "ip": {
          "type": "ip"
        },
        "username": {
          "type": "text"
        },
        "timestamp": {
          "type": "long"
        },
        "host": {
          "type": "text",
          "index": "true"
        },
        "url":{
          "type":"text",
          "index": "true"
        },
        "imei":{
          "type":"text",
          "index":"true"
        },
        "phoneno":{
          "type":"text"
        },
        "user_agent":{
          "type":"text",
          "index":"true"
        }
  
   }
  }
  }

3、条件查询

GET /data/http_record/_search/
  {
  "query": { "term": {"host":"www.mogujie.com"} },//查询host为www.mogujie.com的数据
  "_source": ["url", "host"]//source部分只显示url与host
}

4、全文检索

GET /data/http_record/_search
{
    "query" : {
        "match_phrase" : {
            "url" : "imei"//搜索url字段中包含imei的记录
        }
    }
}


5、聚合操作(对host字段进行聚合操作)

GET /data/http_record/_search
{
    "size" :0,
    "aggs" : { 
        "hosts" : { 
            "terms" : { 
              "field" : "host"
            }
        }
    }
}

elastic search6中文官方文档有详细介绍:https://www.elastic.co/guide/cn/elasticsearch/guide/current/index.html


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值