elasticsearch _search結果解析

kibana中輸入:GET /_search 會返回一下結果:spa

{
  "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"
          ]
        }
      }
    ]
  }
}
相關文章
相關標籤/搜索