使用Kibana dev Tools 实现ElasticSearch文档的检索

3 篇文章 0 订阅

1 查询所有索引

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

返回结果如下图所示:

{
  "took" : 46,
  "timed_out" : false,
  "_shards" : {
    "total" : 20,
    "successful" : 20,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : {
      "value" : 10000,
      "relation" : "gte"
    },
    "max_score" : 1.0,
    "hits" : [
      {
        "_index" : ".kibana-event-log-7.8.0-000001",
        "_type" : "_doc",
        "_id" : "S1xHbHMBHlOTuWE2D6Um",
        "_score" : 1.0,
        "_source" : {
          "event" : {
            "provider" : "eventLog",
            "action" : "starting"
          },
          "message" : "eventLog starting",
          "@timestamp" : "2020-07-20T12:51:02.763Z",
          "ecs" : {
            "version" : "1.5.0"
          },
          "kibana" : {
            "server_uuid" : "99afcd1f-c893-4d8b-95ae-626a0771cd82"
          }
        }
      }
    ]
  }
}

在这里插入图片描述

2 返回参数定义:

  • took: 执行搜索耗时,毫秒为单位
  • time_out: 搜索是否超时
  • _shards: 多少分片被搜索,成功多少,失败多少
  • hits: 搜索结果展示
  • hits.total: 匹配条件的文档总数
  • hits.hits: 返回结果展示,默认返回十个
  • hits.max_score:最大匹配得分
  • hits._score: 返回文档的匹配得分(得分越高,匹配程度越高,越靠前)
  • _index 、_type、 _id 作为剥层定位到特定的文档
  • _source 文档源

3 条件查询

3.1 查询所有索引中的地址名称

GET _search
{
    "query": {
        "match": {
            "addressName": "金融大街"
        }
    }
}

返回结果如下:
在这里插入图片描述

3.2 查询指定索引下的地址名称

GET /test_data_jiangsu/_search
{
    "query": {
        "match": {
            "ADDRESSNAME": "江苏省连云港市连云区墟沟街道长宁路长宁路社区4号楼1单元"
        }
    }
}

返回结果如下图:
在这里插入图片描述

3.3 查询指定索引的部分字段

POST /test_data_jiangsu/_search
{
  "query": { 
    "match_all": {
    
  } },
  "_source": ["ADDRESSCODE", "ADDRESSNAME"]
}

返回结果如下图:
在这里插入图片描述

3.4 查询指定索引中地址名称包括A或者B的文档

POST /test_data_jiangsu/_doc/_search
{
  "query": {
    "bool": {
      "should": [
        { "match": { "ADDRESSNAME": "江苏省连云港市1单元"} },
        { "match": { "ADDRESSNAME": "江苏省连云港市连云区墟沟街道长宁路长宁路社区4号楼2单元" } }
      ]
    }
  }
}

返回结果如下:
在这里插入图片描述

3.5 查询指定索引中地址名称包括A和B的文档

POST /test_data_jiangsu/_doc/_search
{
  "query": {
    "bool": {
      "must": [
         { "match": { "ADDRESSNAME": "江苏省连云港市"} },
        { "match": { "ADDRESSNAME": "长宁路社区4号楼2单元" } }
      ]
    }
  }
}

返回结果如下:
在这里插入图片描述

  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值