## **搜索API**
运行检索有两种基本方式:一种是通过发送搜索参数[REST请求URI](https://www.elastic.co/guide/en/elasticsearch/reference/6.4/search-uri-request.html)和其他通过发送他们[REST请求主体](https://www.elastic.co/guide/en/elasticsearch/reference/6.4/search-request-body.html)。
[REST请求URI](https://www.elastic.co/guide/en/elasticsearch/reference/6.4/search-uri-request.html)
```
GET /orders/_search?q=*&sort=_id:asc&pretty
```
对于响应,我们看到以下部分:
* `took`– Elasticsearch执行搜索的时间(以毫秒为单位)
* `timed_out`–告诉我们搜索是否超时
* `_shards`–告诉我们搜索了多少个分片,以及成功/失败的搜索分片的数量
* `hits`\- 搜索结果
* `hits.total`–符合我们搜索条件的文件总数
* `hits.hits`–搜索结果的实际数组(默认为前10个文档)
* `hits.sort`\-结果的排序键(如果按得分排序则丢失)
* `hits._score`并且`max_score`\-现在暂时忽略这些字段
[REST请求主体](https://www.elastic.co/guide/en/elasticsearch/reference/6.4/search-request-body.html)
```
GET /orders/_search
{
"query": { "match_all": {} },
"sort": [
{ "_id": "asc" }
]
}
```
> 上面两种请求方式等价