🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
# Search(搜索) 搜索API允许您执行搜索查询并获取与查询匹配的文档。查询可以使用简单的[查询字符串参数](URI_Search.md)或[使用请求体](Request_Body_Search.md)。 ## 多索引、多类型 所有搜索API可以跨索引中的多种类型应用,并跨多个索引并支持[多索引语法](../API_Conventions/Multiple_Indices.md)。例如,我们可以搜索`twitter`索引中所有类型的所有文档: ``` GET /twitter/_search?q=user:kimchy ``` 我们也可以指定类型进行搜索: ``` GET /twitter/tweet,user/_search?q=user:kimchy ``` 我们还可以通过多个索引搜索带有某个标签的所有推文(例如,每个用户都有自己的索引): ``` GET /kimchy,elasticsearch/tweet/_search?q=tag:wow ``` 或者我们可以使用`_all`占位符搜索所有可用索引的所有推文: ``` GET /_all/tweet/_search?q=tag:wow ``` 甚至搜索所有索引库和所有类型: ``` GET /_search?q=tag:wow ``` 默认情况下,`elasticsearch`不会根据请求匹配的分片数拒绝任何搜索请求。虽然elasticsearcg将优化协调节点上的搜索执行,但是大量的分片可以显着影响CPU和内存。组织数据通常是一个更好的主意,这样一来,更小的分片就越少。如果您想要配置软限制,则可以更新`action.search.shard_count.limit`的群集设置,以便拒绝匹配太多分片的搜索请求。 The search's `max_concurrent_shard_requests` request parameter can be used to control the maximum number of concurrent shard requests the search API will execute for this request. This parameter should be used to protect a singe request from overloading a cluster ie. a default request will hit all indices in a cluster which could cause shard request rejections if the number of shards per node is high. This default is based on the number of data nodes in the cluster but at most `256`. > my note > > 如何操作 > 设计的俩个参数`action.search.shard_count.limit`和`max_concurrent_shard_requests`