elasticsearch _search结果解析

kibana中输入:GET /_search 会返回一下结果:

{
  "took": 9, #  took:整个搜索请求花费多少毫秒
  "timed_out": false,
  "_shards": { # shards:shards fail的条件,primary和replica全部挂掉,不影响其他shard。
               # 默认情况,一个搜索请求,会发送到一个index的所有primary shard上;
               # 当然,一个primary shard可能会有多个replica shard,所以请求也可能到其中某个replica shard 上。
    "total": 20,
    "successful": 20,
    "skipped": 0,
    "failed": 0
  },
  "hits": {
    "total": 6, # 本次搜索,返回多少条结果
    "max_score": 1, # 本次搜索结果中最大的相关分数,
                    # 每一条document对于search的相关度,越相关,source分数越大,排位越靠前
    "hits": [ # 默认查询前十条数据,查询完整的数据,以_source降序排序
      {
        "_index": "ecommerce",
        "_type": "product",
        "_id": "2",
        "_score": 1,
        "_source": {
          "name": "jiajieshi yagao",
          "desc": "youxiao fangzhu",
          "price": 25,
          "producer": "jiajieshi producer",
          "tags": [
            "fangzhu"
          ]
        }
      },
      {
        "_index": "test_index",
        "_type": "test_type",
        "_id": "2",
        "_score": 1,
        "_source": {
          "test_field": "test client 1"
        }
      },
      {
        "_index": "ecommerce",
        "_type": "product",
        "_id": "1",
        "_score": 1,
        "_source": {
          "name": "gaolujie yagao",
          "desc": "gaoxiao meibai",
          "price": 30,
          "producer": "gaolujie producer",
          "tags": [
            "meibai",
            "fangzhu"
          ]
        }
      },
      {
        "_index": "my_index",
        "_type": "my_type",
        "_id": "1",
        "_score": 1,
        "_source": {
          "test_field": "test data 1"
        }
      },
      {
        "_index": "test_index",
        "_type": "test_type",
        "_id": "1",
        "_score": 1,
        "_source": {
          "test_field": "test client 1"
        }
      },
      {
        "_index": "ecommerce",
        "_type": "product",
        "_id": "3",
        "_score": 1,
        "_source": {
          "name": "zhonghua yagao",
          "desc": "caoben zhiwu",
          "price": 40,
          "producer": "zhonghua producer",
          "tags": [
            "qingxin"
          ]
        }
      }
    ]
  }
}

 

posted @ 2019-10-28 11:22  a-du  阅读(621)  评论(0编辑  收藏  举报