From 316c97c436a2d0edb3df85369402bf1c9b36cf76 Mon Sep 17 00:00:00 2001 From: tangwang Date: Mon, 2 Mar 2026 22:19:25 +0800 Subject: [PATCH] feat: 完整落地多租户 suggestion 能力 --- api/routes/search.py | 2 +- docs/搜索API对接指南.md | 4 ++-- frontend/index.html | 54 +++++++++++++++++++++++++++++++++--------------------- main.py | 2 +- suggestion/README.md | 126 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ suggestion/RUNBOOK.md | 136 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ suggestion/TROUBLESHOOTING.md | 164 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ suggestion/builder.py | 2 +- suggestion/service.py | 2 -- 9 files changed, 464 insertions(+), 28 deletions(-) create mode 100644 suggestion/RUNBOOK.md create mode 100644 suggestion/TROUBLESHOOTING.md diff --git a/api/routes/search.py b/api/routes/search.py index e137da1..770dfcf 100644 --- a/api/routes/search.py +++ b/api/routes/search.py @@ -269,7 +269,7 @@ async def search_by_image(request: ImageSearchRequest, http_request: Request): @router.get("/suggestions", response_model=SearchSuggestResponse) async def search_suggestions( q: str = Query(..., min_length=1, description="搜索查询"), - size: int = Query(10, ge=1, le=20, description="建议数量"), + size: int = Query(10, ge=1, le=200, description="建议数量(1-200)"), language: str = Query("en", description="请求语言,如 zh/en/ar/ru"), with_results: bool = Query(True, description="是否附带每条 suggestion 的直达商品"), result_size: int = Query(3, ge=1, le=10, description="每条 suggestion 直达商品数量"), diff --git a/docs/搜索API对接指南.md b/docs/搜索API对接指南.md index 2f4ed28..3afbbd8 100644 --- a/docs/搜索API对接指南.md +++ b/docs/搜索API对接指南.md @@ -129,7 +129,7 @@ curl -X POST "http://120.76.41.98:6002/search/" \ | 接口 | HTTP Method | Endpoint | 说明 | |------|------|------|------| | 搜索 | POST | `/search/` | 执行搜索查询 | -| 搜索建议 | GET | `/search/suggestions` | 搜索建议(框架,暂未实现) ⚠️ TODO | +| 搜索建议 | GET | `/search/suggestions` | 搜索建议(自动补全/热词,多语言 + 结果直达) | | 即时搜索 | GET | `/search/instant` | 边输入边搜索(框架) ⚠️ TODO | | 获取文档 | GET | `/search/{doc_id}` | 获取单个文档 | | 全量索引 | POST | `/indexer/reindex` | 全量索引接口(导入数据,不删除索引,仅推荐自测使用) | @@ -566,7 +566,7 @@ response = requests.post(url, headers=headers, json={"query": "芭比娃娃"}) | 参数 | 类型 | 必填 | 默认值 | 描述 | |------|------|------|--------|------| | `q` | string | Y | - | 查询字符串(至少 1 个字符) | -| `size` | integer | N | 10 | 返回建议数量(1-20) | +| `size` | integer | N | 10 | 返回建议数量(1-200) | | `language` | string | N | `en` | 请求语言,如 `zh` / `en` / `ar` / `ru`,用于路由到对应语种 suggestion 索引 | | `with_results` | bool | N | `true` | 是否为每条 suggestion 返回商品列表(结果直达) | | `result_size` | integer | N | 3 | 每条 suggestion 返回的商品数量(1-10) | diff --git a/frontend/index.html b/frontend/index.html index 0895098..00855cd 100644 --- a/frontend/index.html +++ b/frontend/index.html @@ -200,8 +200,8 @@