2021-04-07 14:51:06 +08:00
|
|
|
|
检索服务接口列表
|
|
|
|
|
====
|
|
|
|
|
## 关键词搜索
|
|
|
|
|
----
|
|
|
|
|
### 接口描述
|
|
|
|
|
>对用户输入的关键词进行相关结果的搜索匹配,搜索结果默认按照关键词与文档的相关性得分进行排序。
|
|
|
|
|
|
|
|
|
|
### URL
|
|
|
|
|
```html
|
2021-08-27 15:04:17 +08:00
|
|
|
|
http://127.0.0.1/search
|
2021-04-07 14:51:06 +08:00
|
|
|
|
```
|
|
|
|
|
### Http Method
|
2021-08-27 15:04:17 +08:00
|
|
|
|
POST
|
2021-04-07 14:51:06 +08:00
|
|
|
|
### Http返回格式
|
|
|
|
|
JSON
|
|
|
|
|
### Http请求参数说明
|
|
|
|
|
| 参数 | 类型 | 是否必需 | 描述 |
|
|
|
|
|
| ------------ | ------------ | ------------ | ------------ |
|
|
|
|
|
| appid | int | 是 | appname对应的ID |
|
2021-08-27 15:04:17 +08:00
|
|
|
|
| query | string | 是 | 搜索查询词 |
|
2021-04-07 14:51:06 +08:00
|
|
|
|
| page_index | int | 否 | 页码 |
|
|
|
|
|
| page_size | int | 否 | 每页条数 |
|
|
|
|
|
| sort_type | int | 否 | 排序方式 |
|
|
|
|
|
| sort_field | string | 否 | 排序字段 |
|
|
|
|
|
| fields | string | 否 | 返回指定字段值 |
|
2021-04-07 14:54:50 +08:00
|
|
|
|
|
2021-08-27 15:04:17 +08:00
|
|
|
|
说明:query兼容elasticsearch协议,格式可参考tools/search.json文件。
|
2021-04-07 14:54:50 +08:00
|
|
|
|
|
2021-04-07 14:51:06 +08:00
|
|
|
|
应用的定义及支持的字段类型可参考:[项目配置文件](https://gitee.com/jd-platform-opensource/isearch#%E9%A1%B9%E7%9B%AE%E9%85%8D%E7%BD%AE%E6%96%87%E4%BB%B6)
|
2021-04-07 14:54:50 +08:00
|
|
|
|
|
2021-04-07 14:51:06 +08:00
|
|
|
|
### Http返回结果说明
|
|
|
|
|
| 字段 | 类型 | 描述 |
|
|
|
|
|
| ------------ | ------------ | ------------ |
|
|
|
|
|
| code | int | 执行结果 |
|
|
|
|
|
| count | int | 结果总数 |
|
|
|
|
|
| result | string | 结果内容 |
|
|
|
|
|
### CURL调用示例
|
2021-04-07 14:54:50 +08:00
|
|
|
|
```
|
2021-08-27 15:04:17 +08:00
|
|
|
|
curl -X POST \
|
|
|
|
|
http://127.0.0.1/search \
|
|
|
|
|
-H 'content-type: application/json' \
|
|
|
|
|
-d '{"appid":10064,"query":{"match":{"author_id":"21386"}},"page_index":1,"page_size":3}'
|
2021-04-07 14:51:06 +08:00
|
|
|
|
```
|
|
|
|
|
### 成功返回示例
|
|
|
|
|
```json
|
|
|
|
|
{
|
2021-04-09 13:55:06 +08:00
|
|
|
|
"code": 0,
|
|
|
|
|
"count": 2,
|
|
|
|
|
"result": [{
|
|
|
|
|
"doc_id": "115",
|
|
|
|
|
"score": 20.395478565398534,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"doc_id": "105",
|
|
|
|
|
"score": 20.016650933441753,
|
|
|
|
|
}
|
|
|
|
|
]
|
2021-04-07 14:51:06 +08:00
|
|
|
|
}
|
|
|
|
|
```
|
|
|
|
|
### 错误返回示例
|
|
|
|
|
```json
|
|
|
|
|
{
|
2021-04-07 14:54:50 +08:00
|
|
|
|
"code": -1,
|
|
|
|
|
"message": "keyword is required"
|
2021-04-07 14:51:06 +08:00
|
|
|
|
}
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
## 索引上报
|
|
|
|
|
----
|
|
|
|
|
### 接口描述
|
2021-04-07 14:58:08 +08:00
|
|
|
|
>该接口上传记录至索引服务,生成普通索引表。
|
2021-04-07 14:51:06 +08:00
|
|
|
|
|
|
|
|
|
### URL
|
|
|
|
|
```html
|
2021-08-27 15:04:17 +08:00
|
|
|
|
http://127.0.0.1/insert
|
2021-04-07 14:51:06 +08:00
|
|
|
|
```
|
|
|
|
|
### Http Method
|
|
|
|
|
POST
|
|
|
|
|
### Http返回格式
|
|
|
|
|
JSON
|
|
|
|
|
### Http请求参数说明
|
|
|
|
|
| 参数 | 类型 | 是否必需 | 描述 |
|
|
|
|
|
| ------------ | ------------ | ------------ | ------------ |
|
|
|
|
|
| appid | string | 是 | 用户组id |
|
|
|
|
|
| table_content | object | 是 | 内容对象 |
|
|
|
|
|
#### table_content的参数
|
|
|
|
|
| 参数 | 类型 | 是否必需 | 描述 |
|
|
|
|
|
| ------------ | ------------ | ------------ | ------------ |
|
|
|
|
|
| cmd | string | 是 | 操作类型 |
|
|
|
|
|
| fields | object | 是 | 文章对象 |
|
2021-04-07 14:54:50 +08:00
|
|
|
|
|
2021-04-07 14:51:06 +08:00
|
|
|
|
注:cmd取值包括add,delete,update。
|
2021-04-07 14:54:50 +08:00
|
|
|
|
|
2021-04-07 14:51:06 +08:00
|
|
|
|
#### fields的参数
|
|
|
|
|
| 参数 | 类型 | 是否必需 | 描述 |
|
|
|
|
|
| ------------ | ------------ | ------------ | ------------ |
|
|
|
|
|
| doc_id | string | 是 | 文章ID |
|
|
|
|
|
| weight | int | 是 | 文章权重 |
|
|
|
|
|
| author | string | 是 | 文章作者 |
|
|
|
|
|
| title | string | 是 | 文章标题 |
|
|
|
|
|
| content | string | 是 | 文章内容 |
|
2021-08-27 15:04:17 +08:00
|
|
|
|
|
2021-04-07 14:51:06 +08:00
|
|
|
|
### Http 返回结果说明
|
|
|
|
|
| 参数 | 类型 | 描述 |
|
|
|
|
|
| ------------ | ------------ | ------------ |
|
|
|
|
|
| code | int | 执行结果 |
|
|
|
|
|
| message | string | 信息描述 |
|
2021-08-27 15:04:17 +08:00
|
|
|
|
|
2021-04-07 14:51:06 +08:00
|
|
|
|
### CURL调用示例
|
|
|
|
|
```html
|
|
|
|
|
curl -X POST \
|
|
|
|
|
http://127.0.0.1/index/common \
|
|
|
|
|
-H 'content-type: application/json' \
|
|
|
|
|
-d '{
|
|
|
|
|
"appid": 10001,
|
2021-08-27 15:04:17 +08:00
|
|
|
|
"table_content": {
|
2021-04-07 14:51:06 +08:00
|
|
|
|
"cmd": "add",
|
|
|
|
|
"fields": {
|
|
|
|
|
"doc_id": "28394556",
|
|
|
|
|
"weight": 218,
|
|
|
|
|
"author": "zhangsan",
|
|
|
|
|
"title": " 京东阅读电子阅读器即将上线 ",
|
|
|
|
|
"content": "今天小编得到了一个令人振奋的消息!它是什么呢?京东阅读官方即将推出搭载京东阅读客户端"
|
|
|
|
|
}
|
2021-08-27 15:04:17 +08:00
|
|
|
|
}
|
2021-04-07 14:51:06 +08:00
|
|
|
|
}'
|
|
|
|
|
```
|
|
|
|
|
### 成功返回示例
|
|
|
|
|
```json
|
|
|
|
|
{
|
2021-04-07 14:54:50 +08:00
|
|
|
|
"code": 0
|
2021-04-07 14:51:06 +08:00
|
|
|
|
}
|
|
|
|
|
```
|