1. 程式人生 > >015-elasticsearch【五】-搜索模板,多搜索模板,

015-elasticsearch【五】-搜索模板,多搜索模板,

cat closed def min 索引 zed using 問題 separate

一、搜索模板

查看地址

二、多搜索模板

查看地址

三、搜索分片API

  搜索分片api返回將執行搜索請求的索引和分片。這可以提供有用的反饋,用於解決問題或使用路由和分片首選項進行規劃優化。使用過濾別名時,過濾器將作為索引部分的一部分返回。

  索引和類型參數可以是單個值,也可以逗號分隔。

  類型參數已棄用【5.1.0】

示例:

GET /twitter/_search_shards
技術分享圖片
{
  "nodes": ...,
  "indices" : {
    "twitter": { }
  },
  "shards": [
    [
      {
        
"index": "twitter", "node": "JklnKbD7Tyqi9TP3_Q_tBg", "primary": true, "shard": 0, "state": "STARTED", "allocation_id": {"id":"0TvkCyF7TAmM1wHP4a42-A"}, "relocating_node": null } ], [ { "index": "twitter",
"node": "JklnKbD7Tyqi9TP3_Q_tBg", "primary": true, "shard": 1, "state": "STARTED", "allocation_id": {"id":"fMju3hd1QHWmWrIgFnI4Ww"}, "relocating_node": null } ], [ { "index": "twitter", "node": "JklnKbD7Tyqi9TP3_Q_tBg",
"primary": true, "shard": 2, "state": "STARTED", "allocation_id": {"id":"Nwl0wbMBTHCWjEEbGYGapg"}, "relocating_node": null } ], [ { "index": "twitter", "node": "JklnKbD7Tyqi9TP3_Q_tBg", "primary": true, "shard": 3, "state": "STARTED", "allocation_id": {"id":"bU_KLGJISbW0RejwnwDPKw"}, "relocating_node": null } ], [ { "index": "twitter", "node": "JklnKbD7Tyqi9TP3_Q_tBg", "primary": true, "shard": 4, "state": "STARTED", "allocation_id": {"id":"DMs7_giNSwmdqVukF7UydA"}, "relocating_node": null } ] ] }
View Code

指定相同的請求,這次使用路由值:

GET /twitter/_search_shards?routing=foo,baz
技術分享圖片
{
  "nodes": ...,
  "indices" : {
      "twitter": { }
  },
  "shards": [
    [
      {
        "index": "twitter",
        "node": "JklnKbD7Tyqi9TP3_Q_tBg",
        "primary": true,
        "shard": 0,
        "state": "STARTED",
        "allocation_id": {"id":"0TvkCyF7TAmM1wHP4a42-A"},
        "relocating_node": null
      }
    ],
    [
      {
        "index": "twitter",
        "node": "JklnKbD7Tyqi9TP3_Q_tBg",
        "primary": true,
        "shard": 1,
        "state": "STARTED",
        "allocation_id": {"id":"fMju3hd1QHWmWrIgFnI4Ww"},
        "relocating_node": null
      }
    ]
  ]
}
View Code

這次搜索只會針對兩個分片執行,因為已經指定了路由值。

參數:

  

routing

A comma-separated list of routing values to take into account when determining which shards a request would be executed against.

在確定要執行的請求分片時要考慮的路由值的逗號分隔列表。

preference

Controls a preference of which shard replicas to execute the search request on. By default, the operation is randomized between the shard replicas. See the preferencedocumentation for a list of all acceptable values.

控制哪個分片副本在其上執行搜索請求的首選項。默認情況下,該操作在碎片副本之間隨機化。請參閱首選項文檔以獲取所有可接受值的列表。

local

A boolean value whether to read the cluster state locally in order to determine where shards are allocated instead of using the Master node’s cluster state.

一個布爾值,是否在本地讀取群集狀態以確定分配分片的位置,而不是使用主節點的群集狀態。

四、建議功能

參看地址

五、多搜索API

查看地址

015-elasticsearch【五】-搜索模板,多搜索模板,