Blame view

docs/QUICKSTART.md 3.35 KB
42e3aea6   tangwang   tidy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
  # 开发者快速上手
  
  新人入口文档:环境、服务、模块、请求示例一页搞定。
  
  ## 1. 环境
  
  ```bash
  source activate.sh
  # 首次:./scripts/create_venv.sh 或 conda env create -f environment.yml
  ```
  
  依赖:Python 3.8+、Elasticsearch 8.x、MySQL、Redis(可选)。详见 `docs/环境配置说明.md`
  
  ## 2. 服务与端口
  
  | 服务 | 端口 | 默认启动 | 说明 |
  |------|-----:|:--------:|------|
  | backend | 6002 | ✓ | 搜索 API |
  | indexer | 6004 | ✓ | 索引 API |
  | frontend | 6003 | ✓ | 调试 UI |
  | embedding | 6005 | - | 向量服务 |
  | translator | 6006 | - | 翻译服务 |
  | reranker | 6007 | - | 重排服务 |
  
  ```bash
  ./run.sh
  # 全功能:START_EMBEDDING=1 START_TRANSLATOR=1 START_RERANKER=1 ./run.sh
  ./scripts/service_ctl.sh status
  ./scripts/stop.sh
  ```
  
  ## 3. 模块与请求
  
  ### 3.1 搜索 API(backend 6002)
  
  ```bash
  # 文本搜索
  curl -X POST http://localhost:6002/search/ \
    -H "Content-Type: application/json" \
    -H "X-Tenant-ID: 162" \
    -d '{"query": "玩具", "size": 10}'
  
  # 图片搜索
  curl -X POST http://localhost:6002/search/image \
    -H "Content-Type: application/json" \
    -H "X-Tenant-ID: 162" \
    -d '{"image_url": "https://example.com/img.jpg", "size": 10}'
  
  # 建议
  curl "http://localhost:6002/search/suggestions?q=玩&size=5" -H "X-Tenant-ID: 162"
  ```
  
  API 文档:http://localhost:6002/docs
  
  ### 3.2 索引 API(indexer 6004)
  
  ```bash
  # 创建租户索引
  ./scripts/create_tenant_index.sh 162
  
  # 全量索引
  curl -X POST http://localhost:6004/indexer/reindex \
    -H "Content-Type: application/json" \
    -d '{"tenant_id": "162", "batch_size": 500}'
  
  # 构建文档(不写 ES,供上游调用)
  curl -X POST http://localhost:6004/indexer/build-docs \
    -H "Content-Type: application/json" \
    -d '{"tenant_id": "162", "items": [{"spu": {...}, "skus": [...], "options": [...]}]}'
  ```
  
  ### 3.3 向量服务(embedding 6005)
  
  ```bash
  ./scripts/start_embedding_service.sh
  
  # 文本向量
  curl -X POST http://localhost:6005/embed/text \
    -H "Content-Type: application/json" \
    -d '["衣服", "Bohemian Maxi Dress"]'
  
  # 图片向量(URL 列表)
  curl -X POST http://localhost:6005/embed/image \
    -H "Content-Type: application/json" \
    -d '["https://example.com/img.jpg"]'
  ```
  
  ### 3.4 翻译服务(translator 6006)
  
  ```bash
  ./scripts/start_translator.sh
  
  curl -X POST http://localhost:6006/translate \
    -H "Content-Type: application/json" \
    -d '{"text": "商品名称", "target_lang": "en", "source_lang": "zh"}'
  ```
  
  ### 3.5 重排服务(reranker 6007)
  
  ```bash
  ./scripts/start_reranker.sh
  
  curl -X POST http://localhost:6007/rerank \
    -H "Content-Type: application/json" \
    -d '{"query": "wireless mouse", "docs": ["logitech mx master", "usb cable"]}'
  ```
  
  ## 4. 配置
  
  - **主配置**`config/config.yaml`(搜索行为、字段权重、分面等)
  - **服务 provider**`config/config.yaml` 的 `services` 块(翻译/向量/重排的 provider 与 URL)
  - **环境变量**`.env`(DB、ES、Redis、API Key 等)
  
  ## 5. 延伸阅读
  
  | 文档 | 用途 |
  |------|------|
  | `docs/Usage-Guide.md` | 运维:日志、多环境、故障排查 |
  | `docs/搜索API速查表.md` | 搜索 API 参数速查 |
  | `docs/搜索API对接指南.md` | 搜索 API 完整说明 |
  | `docs/PROVIDER_ARCHITECTURE.md` | 翻译/向量/重排 provider 扩展 |
  | `indexer/README.md` | 索引模块职责与接口 |