一、搜索模板
二、多搜索模板
三、搜索分片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 } ] ] }
指定相同的请求,这次使用路由值:
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 } ] ] }
这次搜索只会针对两个分片执行,因为已经指定了路由值。
参数:
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
原文地址:https://www.cnblogs.com/bjlhx/p/8528746.html
时间: 2024-11-10 08:10:40