ES中搜索结果各属性说明介绍,以及搜索中的timeout机制讲解(来自学习资料,34节)

1、属性说明和介绍

执行命令:

GET /test_index/test_type/_search?timeout=1s

运行后的结果如下:

{
  "took": 4,
  "timed_out": false,
  "_shards": {
    "total": 3,
    "successful": 3,
    "failed": 0
  },
  "hits": {
    "total": 11,
    "max_score": 1,
    "hits": [
      {
        "_index": "test_index",
        "_type": "test_type",
        "_id": "5",
        "_score": 1,
        "_source": {
          "test_field": "test3"
        }
      },
      {
        "_index": "test_index",
        "_type": "test_type",
        "_id": "6",
        "_score": 1,
        "_source": {
          "test_field": "test6"
        }
      },
      {
        "_index": "test_index",
        "_type": "test_type",
        "_id": "7",
        "_score": 1,
        "_source": {
          "test_field": "test7"
        }
      },
      {
        "_index": "test_index",
        "_type": "test_type",
        "_id": "2",
        "_score": 1,
        "_source": {
          "test_field": "test2"
        }
      },
      {
        "_index": "test_index",
        "_type": "test_type",
        "_id": "4",
        "_score": 1,
        "_source": {
          "test_field": "test4"
        }
      },
      {
        "_index": "test_index",
        "_type": "test_type",
        "_id": "AWPE334kH290KcMbohDu",
        "_score": 1,
        "_source": {
          "test_content": "my test2"
        }
      },
      {
        "_index": "test_index",
        "_type": "test_type",
        "_id": "AWPE4LcyH290KcMbohDx",
        "_score": 1,
        "_source": {
          "test_content": "my test2"
        }
      },
      {
        "_index": "test_index",
        "_type": "test_type",
        "_id": "AWPE4ARFH290KcMbohDv",
        "_score": 1,
        "_source": {
          "test_content": "my test2"
        }
      },
      {
        "_index": "test_index",
        "_type": "test_type",
        "_id": "AWPE4JVHH290KcMbohDw",
        "_score": 1,
        "_source": {
          "test_content": "my test2"
        }
      },
      {
        "_index": "test_index",
        "_type": "test_type",
        "_id": "3",
        "_score": 1,
        "_source": {
          "test_field": "test3"
        }
      }
    ]
  }
}

属性介绍:
took:整个搜索花费了多少毫秒

hits.total:本次搜索,返回几条结果
hits.max_score:本次搜索的所有结果中,最大的相关度分数是多少,每一条document对于search的相关度,越相关,_score分数越大,排位越靠前
hits.hits:默认查询前10条数据,完整数据,_score降序排序。
**shards:**shards fail的条件(primary和replica全部挂掉),不影响其他shard。默认情况下来说,一个搜索请求,会打到一个index的所有primary shard上去,当然了,每个primary shard都可能会有一个或多个replic shard,所以请求也可以到primary shard的其中一个replica shard上去。

2、timeout图解介绍

这里写图片描述

timeout:默认无timeout,,latency平衡completeness,手动指定timeout,timeout查询执行机制
timeout的单位可以是:毫秒,秒,分。
例:

timeout=10ms,timeout=1s,timeout=1m

GET /test_index/test_type/_search?timeout=1ms

猜你喜欢

转载自blog.csdn.net/toto1297488504/article/details/80700150
今日推荐