首页  

elasticsearch5.0搜索API概述     所属分类 elasticsearch 浏览量 1458
根据原文翻译整理
https://www.elastic.co/guide/en/elasticsearch/reference/5.0/search.html


Most search APIs are multi-index, multi-type, with the exception of the Explain API endpoints.

大多数搜索API支持 多索引 多类型 , Explain API是个例外

When executing a search, 
it will be broadcast to all the index/indices shards (round robin between replicas). 
Which shards will be searched on can be controlled by providing the routing parameter. 

执行搜索时,将广播到所有索引分片(副本之间轮询)。 查询所有分片(轮询选择一个副本)
设置路由参数 ,在指定分片上搜索。

索引 类型 分片 副本 主副本 

索引时指定分片 ?routing=kimchy

if we want to search only on the tweets for a specific user, 
we can specify it as the routing, resulting in the search hitting only the relevant shard
搜索时使用同样的路由

http://localhost:9200/twitter/tweet/_search?routing=kimchy

The routing parameter can be multi valued represented as a comma separated string. 
This will result in hitting the relevant shards where the routing values match to.

路由参数可以指定多个值,逗号分隔


Stats Groups
A search can be associated with stats groups, 
which maintains a statistics aggregation per group. 
It can later be retrieved using the indices stats API specifically. 
For example, here is a search body request that associate the request with two different groups

{
    "query" : {
        "match_all" : {}
    },
    "stats" : ["group1", "group2"]
}

这个具体使用例子?



Global Search Timeout

全局搜索超时时间 

Individual searches can have a timeout as part of the Request Body Search. 
Since search requests can originate from many sources, 
Elasticsearch has a dynamic cluster-level setting for a global search timeout 
that applies to all search requests that do not set a timeout in the Request Body Search. 
The default value is no global timeout. 
The setting key is search.default_search_timeout 
and can be set using the Cluster Update Settings endpoints. 
Setting this value to -1 resets the global search timeout to no timeout.

单个搜索请求可以设置超时
动态的集群级别的全局超时设置
这适用于在请求体搜索中没有设置超时的所有搜索请求。
Cluster Update Settings 端点 可以进行设置
设置成-1 无超时

上一篇     下一篇
elasticsearch5.0词向量信息查询接口

elasticsearch5.0刷新机制

linux之grep命令

elasticsearch5.0搜索API使用概述

elasticsearch5.0基于url的搜索接口

新东方年会《释放自我》歌词