# 9.3.5 Search API概览

## Search API

* URI Search
  * 在URL中使用查询参数
* Request Body Search
  * 使用Elasticsearch提供的，基于JSON格式的更加完备的Query Domain Specific Language （DSL）

### 指定查询的索引

![](https://2471267620-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LfNyxSFSDaHeCRaQx74%2F-LoOyjij05x3q2xq9dsd%2F-LoOymI8EnaRJ6drjyw4%2F1568097742808.png?generation=1568098953341307\&alt=media)

### URI查询

* 使用"q"，指定查询字符串
* "query string syntax"，KV键值对

举例

![](https://2471267620-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LfNyxSFSDaHeCRaQx74%2F-LoOyjij05x3q2xq9dsd%2F-LoOymIAfjurM60u67Pk%2F1568097928424.png?generation=1568098954157963\&alt=media)

### Request Body

![](https://2471267620-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LfNyxSFSDaHeCRaQx74%2F-LoOyjij05x3q2xq9dsd%2F-LoOymICabCoLSl8N8v5%2F1568098031540.png?generation=1568098955431934\&alt=media)

### 搜索Response字段说明

![](https://2471267620-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LfNyxSFSDaHeCRaQx74%2F-LoOyjij05x3q2xq9dsd%2F-LoOymIEEFyS7dWDG4vu%2F1568098178099.png?generation=1568098954886692\&alt=media)

## 衡量相关性

* Information Retrieval（检索）
  * Rrecision（查准率） - 尽可能返回较少的无关文档
  * Recall （查全率）- 尽量返回较多的相关文档
  * Ranking - 是否能够按照相关度进行排序

![](https://2471267620-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LfNyxSFSDaHeCRaQx74%2F-LoOyjij05x3q2xq9dsd%2F-LoOymITxeQu1UjecbXO%2F1568098803331.png?generation=1568098960711639\&alt=media)
