1. 程式人生 > >elasticsearch 筆記十一:搜尋請求和timeout

elasticsearch 筆記十一:搜尋請求和timeout

{
  "took": 10,   //花費多少ms
  "timed_out": false,
  "_shards": {
    "total": 9,   //到多少shard
    "successful": 9,
    "failed": 0
  },
  "hits": {
    "total": 7,
    "max_score": 1,
    "hits": [
      {
        "_index": ".kibana",
        "_type": "config",
        "_id": "5.2.0",
        "_score": 1,
        "_source": {
          "buildNum": 14695
        }
      },
      {
        "_index": "test_index",
        "_type": "test_type",
        "_id": "7",
        "_score": 1,
        "_source": {
          "test_field": "test test"
        }
      },
      {
        "_index": "ecommerce",
        "_type": "product",
        "_id": "2",
        "_score": 1,
        "_source": {
          "name": "jiajieshi yagao",
          "desc": "youxiao fangzhu",
          "price": 25,
          "producer": "jiajieshi producer",
          "tags": [
            "fangzhu"
          ]
        }
      },
      {
        "_index": "ecommerce",
        "_type": "product",
        "_id": "4",
        "_score": 1,
        "_source": {
          "name": "heiren",
          "desc": "xiren yagao",
          "price": 50,
          "producer": "jiajieshi yagao",
          "tags": [
            "heiren"
          ]
        }
      },
      {
        "_index": "test_index",
        "_type": "test_type",
        "_id": "10",
        "_score": 1,
        "_source": {
          "test_field": "test test",
          "test_field1": "test test"
        }
      },
      {
        "_index": "ecommerce",
        "_type": "product",
        "_id": "1",
        "_score": 1,
        "_source": {
          "name": "heiren",
          "desc": "xiren yagao",
          "price": 50,
          "producer": "jiajieshi yagao",
          "tags": [
            "heiren"
          ]
        }
      },
      {
        "_index": "ecommerce",
        "_type": "product",
        "_id": "3",
        "_score": 1,
        "_source": {
          "name": "zhonghua yagao",
          "desc": "caoben zhiwu",
          "price": 40,
          "producer": "zhonghua producer",
          "tags": [
            "qingxin"
          ]
        }
      }
    ]
  }
}

hits.total 本次搜尋返回幾條結果

hits.max_score:本次搜尋的所有的結果中,最大的相關度分數是多少

hits.hits:預設查詢前10條資料,完整資料,_score降序

timeout機制

timeout 機制,指定每個shard,就只能在timeout時間範圍內將搜尋到的資料返回。而不是等到全部資料全部檢索出來才返回。

GET /_search?timeout=1ms