Commit 2a76641e492929c1c69a6eeeeafe3abceec2257e

Authored by tangwang
1 parent 115047ee

config

... ... @@ -19,7 +19,7 @@ CUSTOMER_ID=customer1
19 19  
20 20 # API Service Configuration
21 21 API_HOST=0.0.0.0
22   -API_PORT=8000
  22 +API_PORT=6002
23 23  
24 24 # Embedding Models
25 25 TEXT_MODEL_DIR=/data/tw/models/bge-m3
... ...
.env.example
... ... @@ -19,7 +19,7 @@ CUSTOMER_ID=customer1
19 19  
20 20 # API Service Configuration
21 21 API_HOST=0.0.0.0
22   -API_PORT=8000
  22 +API_PORT=6002
23 23  
24 24 # Embedding Models
25 25 TEXT_MODEL_DIR=/data/tw/models/bge-m3
... ...
DEPLOYMENT.md
... ... @@ -36,7 +36,7 @@ cd /data/tw/SearchEngine
36 36 ./start_all.sh
37 37 ```
38 38  
39   -然后访问: http://localhost:8080
  39 +然后访问: http://localhost:6003
40 40  
41 41 ### 方式2: 分步启动
42 42  
... ... @@ -88,7 +88,7 @@ DEEPL_AUTH_KEY=c9293ab4-ad25-479b-919f-ab4e63b429ed
88 88  
89 89 CUSTOMER_ID=customer1
90 90 API_HOST=0.0.0.0
91   -API_PORT=8000
  91 +API_PORT=6002
92 92 ```
93 93  
94 94 ## 服务端口
... ... @@ -96,9 +96,9 @@ API_PORT=8000
96 96 | 服务 | 端口 | URL |
97 97 |------|------|-----|
98 98 | Elasticsearch | 9200 | http://localhost:9200 |
99   -| Backend API | 8000 | http://localhost:8000 |
100   -| Frontend Web | 8080 | http://localhost:8080 |
101   -| API Docs | 8000 | http://localhost:8000/docs |
  99 +| Backend API | 6002 | http://localhost:6002 |
  100 +| Frontend Web | 6003 | http://localhost:6003 |
  101 +| API Docs | 6002 | http://localhost:6002/docs |
102 102  
103 103 ## 测试流程
104 104  
... ... @@ -162,10 +162,10 @@ nohup ./scripts/start_backend.sh > logs/backend.log 2>&1 &
162 162 sleep 5
163 163  
164 164 # 测试健康检查
165   -curl http://localhost:8000/admin/health
  165 +curl http://localhost:6002/admin/health
166 166  
167 167 # 测试搜索
168   -curl -X POST http://localhost:8000/search/ \
  168 +curl -X POST http://localhost:6002/search/ \
169 169 -H "Content-Type: application/json" \
170 170 -d '{"query": "消防", "size": 5}'
171 171 ```
... ... @@ -176,7 +176,7 @@ curl -X POST http://localhost:8000/search/ \
176 176 # 启动前端
177 177 ./scripts/start_frontend.sh
178 178  
179   -# 然后在浏览器访问: http://localhost:8080
  179 +# 然后在浏览器访问: http://localhost:6003
180 180 ```
181 181  
182 182 ## 故障排除
... ... @@ -234,8 +234,8 @@ cat .env | grep ES_
234 234 **解决**:
235 235 ```bash
236 236 # 查看占用端口的进程
237   -lsof -i :8000 # 后端
238   -lsof -i :8080 # 前端
  237 +lsof -i :6002 # 后端
  238 +lsof -i :6003 # 前端
239 239  
240 240 # 杀掉进程
241 241 kill -9 <PID>
... ... @@ -246,12 +246,12 @@ kill -9 &lt;PID&gt;
246 246 ## 下一步
247 247  
248 248 1. **测试搜索功能**
249   - - 打开 http://localhost:8080
  249 + - 打开 http://localhost:6003
250 250 - 尝试不同的搜索查询
251 251 - 测试布尔操作符
252 252  
253 253 2. **查看API文档**
254   - - 访问 http://localhost:8000/docs
  254 + - 访问 http://localhost:6002/docs
255 255 - 了解所有可用的API端点
256 256  
257 257 3. **自定义配置**
... ...
HighLevelDesign.md
... ... @@ -112,6 +112,8 @@ if response.status_code == 200:
112 112 支持多种匹配方式,如AND、OR、RANK、NOTAND以及(),优先级从高到低为(),ANDNOT,AND,OR,RANK。
113 113  
114 114 default域的相关性,是代码里面单独计算,是特定的深度定制优化的,暂时不做配置化。
  115 +多语言搜索:
  116 +对外提供的服务 用default域搜索就行,但是内部需要通过配置翻译为多种语言(配置几种目标语言 默认中文、英文,并且设置对应的检索域),然后分别到对应的字段搜索,中文字段到配置的中文title搜索,英文到对应的英文title搜索。
115 117  
116 118 暂时具体实现为 bm25()+0.2*text_embedding_relevence(也就是knn检索表达式的打分)
117 119 bm25打分(base_query):
... ...
IMPLEMENTATION_SUMMARY.md
... ... @@ -251,7 +251,7 @@ python data/customer1/ingest_customer1.py \
251 251 ```bash
252 252 python -m api.app \
253 253 --host 0.0.0.0 \
254   - --port 8000 \
  254 + --port 6002 \
255 255 --customer customer1 \
256 256 --es-host http://localhost:9200
257 257 ```
... ... @@ -260,17 +260,17 @@ python -m api.app \
260 260  
261 261 ```bash
262 262 # Simple Chinese query (auto-translates to English/Russian)
263   -curl -X POST http://localhost:8000/search/ \
  263 +curl -X POST http://localhost:6002/search/ \
264 264 -H "Content-Type: application/json" \
265 265 -d '{"query": "芭比娃娃", "size": 10}'
266 266  
267 267 # Boolean query
268   -curl -X POST http://localhost:8000/search/ \
  268 +curl -X POST http://localhost:6002/search/ \
269 269 -H "Content-Type: application/json" \
270 270 -d '{"query": "toy AND (barbie OR doll) ANDNOT cheap", "size": 10}'
271 271  
272 272 # Query with filters
273   -curl -X POST http://localhost:8000/search/ \
  273 +curl -X POST http://localhost:6002/search/ \
274 274 -H "Content-Type: application/json" \
275 275 -d '{
276 276 "query": "消防",
... ... @@ -279,7 +279,7 @@ curl -X POST http://localhost:8000/search/ \
279 279 }'
280 280  
281 281 # Image search
282   -curl -X POST http://localhost:8000/search/image \
  282 +curl -X POST http://localhost:6002/search/image \
283 283 -H "Content-Type: application/json" \
284 284 -d '{
285 285 "image_url": "https://oss.essa.cn/example.jpg",
... ...
QUICKSTART.md
... ... @@ -46,10 +46,10 @@ python ingest_customer1.py \
46 46  
47 47 # 3. Start API service
48 48 cd ../..
49   -python -m api.app --host 0.0.0.0 --port 8000
  49 +python -m api.app --host 0.0.0.0 --port 6002
50 50  
51 51 # 4. Test search
52   -curl -X POST http://localhost:8000/search/ \
  52 +curl -X POST http://localhost:6002/search/ \
53 53 -H "Content-Type: application/json" \
54 54 -d '{"query": "消防", "size": 5}'
55 55 ```
... ... @@ -72,23 +72,23 @@ python ingest_customer1.py \
72 72 cd ../..
73 73 python -m api.app \
74 74 --host 0.0.0.0 \
75   - --port 8000 \
  75 + --port 6002 \
76 76 --customer customer1 \
77 77 --es-host http://localhost:9200
78 78  
79 79 # 4. Test various searches
80 80 # Simple search
81   -curl -X POST http://localhost:8000/search/ \
  81 +curl -X POST http://localhost:6002/search/ \
82 82 -H "Content-Type: application/json" \
83 83 -d '{"query": "芭比娃娃", "size": 10}'
84 84  
85 85 # Boolean search
86   -curl -X POST http://localhost:8000/search/ \
  86 +curl -X POST http://localhost:6002/search/ \
87 87 -H "Content-Type: application/json" \
88 88 -d '{"query": "toy AND (barbie OR doll)", "size": 10}'
89 89  
90 90 # With filters
91   -curl -X POST http://localhost:8000/search/ \
  91 +curl -X POST http://localhost:6002/search/ \
92 92 -H "Content-Type: application/json" \
93 93 -d '{"query": "娃娃", "size": 10, "filters": {"categoryName_keyword": "芭比"}}'
94 94 ```
... ... @@ -96,8 +96,8 @@ curl -X POST http://localhost:8000/search/ \
96 96 ## API Documentation
97 97  
98 98 Once the service is running, visit:
99   -- **Swagger UI**: http://localhost:8000/docs
100   -- **ReDoc**: http://localhost:8000/redoc
  99 +- **Swagger UI**: http://localhost:6002/docs
  100 +- **ReDoc**: http://localhost:6002/redoc
101 101  
102 102 ## Common Issues
103 103  
... ... @@ -131,33 +131,33 @@ export DEEPL_API_KEY=&quot;your-key&quot;
131 131  
132 132 ### Test Health
133 133 ```bash
134   -curl http://localhost:8000/admin/health
  134 +curl http://localhost:6002/admin/health
135 135 ```
136 136  
137 137 ### Test Configuration
138 138 ```bash
139   -curl http://localhost:8000/admin/config
  139 +curl http://localhost:6002/admin/config
140 140 ```
141 141  
142 142 ### Test Index Stats
143 143 ```bash
144   -curl http://localhost:8000/admin/stats
  144 +curl http://localhost:6002/admin/stats
145 145 ```
146 146  
147 147 ### Test Search
148 148 ```bash
149 149 # Chinese query (auto-translates to English/Russian)
150   -curl -X POST http://localhost:8000/search/ \
  150 +curl -X POST http://localhost:6002/search/ \
151 151 -H "Content-Type: application/json" \
152 152 -d '{"query": "消防套", "size": 5}'
153 153  
154 154 # English query
155   -curl -X POST http://localhost:8000/search/ \
  155 +curl -X POST http://localhost:6002/search/ \
156 156 -H "Content-Type: application/json" \
157 157 -d '{"query": "fire control set", "size": 5}'
158 158  
159 159 # Russian query
160   -curl -X POST http://localhost:8000/search/ \
  160 +curl -X POST http://localhost:6002/search/ \
161 161 -H "Content-Type: application/json" \
162 162 -d '{"query": "Наборы для пожаротушения", "size": 5}'
163 163 ```
... ... @@ -193,4 +193,4 @@ For issues or questions, refer to:
193 193 - **README.md**: Comprehensive documentation
194 194 - **IMPLEMENTATION_SUMMARY.md**: Technical details
195 195 - **CLAUDE.md**: Development guidelines
196   -- **API Docs**: http://localhost:8000/docs
  196 +- **API Docs**: http://localhost:6002/docs
... ...
USER_GUIDE.md
... ... @@ -16,9 +16,9 @@ cd /data/tw/SearchEngine
16 16 4. 启动前端Web界面
17 17  
18 18 启动完成后,访问:
19   -- **前端界面**: http://localhost:8080
20   -- **后端API**: http://localhost:8000
21   -- **API文档**: http://localhost:8000/docs
  19 +- **前端界面**: http://localhost:6003
  20 +- **后端API**: http://localhost:6002
  21 +- **API文档**: http://localhost:6002/docs
22 22  
23 23 ### 停止服务
24 24  
... ... @@ -65,7 +65,7 @@ cd /data/tw/SearchEngine
65 65 ./scripts/start_backend.sh
66 66 ```
67 67  
68   -后端API会在 http://localhost:8000 启动
  68 +后端API会在 http://localhost:6002 启动
69 69  
70 70 ### 4. 启动前端
71 71  
... ... @@ -73,7 +73,7 @@ cd /data/tw/SearchEngine
73 73 ./scripts/start_frontend.sh
74 74 ```
75 75  
76   -前端界面会在 http://localhost:8080 启动
  76 +前端界面会在 http://localhost:6003 启动
77 77  
78 78 ---
79 79  
... ... @@ -100,7 +100,7 @@ CUSTOMER_ID=customer1
100 100  
101 101 # API服务配置
102 102 API_HOST=0.0.0.0
103   -API_PORT=8000
  103 +API_PORT=6002
104 104 ```
105 105  
106 106 ### 修改配置
... ... @@ -143,7 +143,7 @@ API_PORT=8000
143 143 ### 搜索接口
144 144  
145 145 ```bash
146   -curl -X POST http://localhost:8000/search/ \
  146 +curl -X POST http://localhost:6002/search/ \
147 147 -H "Content-Type: application/json" \
148 148 -d '{
149 149 "query": "芭比娃娃",
... ... @@ -156,7 +156,7 @@ curl -X POST http://localhost:8000/search/ \
156 156 ### 图片搜索
157 157  
158 158 ```bash
159   -curl -X POST http://localhost:8000/search/image \
  159 +curl -X POST http://localhost:6002/search/image \
160 160 -H "Content-Type: application/json" \
161 161 -d '{
162 162 "image_url": "https://oss.essa.cn/example.jpg",
... ... @@ -167,19 +167,19 @@ curl -X POST http://localhost:8000/search/image \
167 167 ### 健康检查
168 168  
169 169 ```bash
170   -curl http://localhost:8000/admin/health
  170 +curl http://localhost:6002/admin/health
171 171 ```
172 172  
173 173 ### 查看配置
174 174  
175 175 ```bash
176   -curl http://localhost:8000/admin/config
  176 +curl http://localhost:6002/admin/config
177 177 ```
178 178  
179 179 ### 索引统计
180 180  
181 181 ```bash
182   -curl http://localhost:8000/admin/stats
  182 +curl http://localhost:6002/admin/stats
183 183 ```
184 184  
185 185 ---
... ... @@ -231,7 +231,7 @@ cat .env | grep ES_
231 231 **问题**: CORS错误
232 232  
233 233 **解决**:
234   -- 确保后端在 http://localhost:8000 运行
  234 +- 确保后端在 http://localhost:6002 运行
235 235 - 检查浏览器控制台错误信息
236 236  
237 237 ---
... ... @@ -339,5 +339,5 @@ SearchEngine/
339 339  
340 340 遇到问题请查看:
341 341 - **日志**: `logs/backend.log`
342   -- **API文档**: http://localhost:8000/docs
  342 +- **API文档**: http://localhost:6002/docs
343 343 - **配置**: `config/schema/customer1_config.yaml`
... ...
api/app.py
... ... @@ -2,7 +2,7 @@
2 2 Main FastAPI application for the search service.
3 3  
4 4 Usage:
5   - uvicorn api.app:app --host 0.0.0.0 --port 8000 --reload
  5 + uvicorn api.app:app --host 0.0.0.0 --port 6002 --reload
6 6 """
7 7  
8 8 import os
... ... @@ -161,7 +161,7 @@ if __name__ == &quot;__main__&quot;:
161 161  
162 162 parser = argparse.ArgumentParser(description='Start search API service')
163 163 parser.add_argument('--host', default='0.0.0.0', help='Host to bind to')
164   - parser.add_argument('--port', type=int, default=8000, help='Port to bind to')
  164 + parser.add_argument('--port', type=int, default=6002, help='Port to bind to')
165 165 parser.add_argument('--customer', default='customer1', help='Customer ID')
166 166 parser.add_argument('--es-host', default='http://localhost:9200', help='Elasticsearch host')
167 167 parser.add_argument('--reload', action='store_true', help='Enable auto-reload')
... ...
config/env_config.py
... ... @@ -36,7 +36,7 @@ CUSTOMER_ID = os.getenv(&#39;CUSTOMER_ID&#39;, &#39;customer1&#39;)
36 36  
37 37 # API Service Configuration
38 38 API_HOST = os.getenv('API_HOST', '0.0.0.0')
39   -API_PORT = int(os.getenv('API_PORT', 8000))
  39 +API_PORT = int(os.getenv('API_PORT', 6002))
40 40  
41 41 # Model Directories
42 42 TEXT_MODEL_DIR = os.getenv('TEXT_MODEL_DIR', '/data/tw/models/bge-m3')
... ...
frontend/index.html
... ... @@ -51,7 +51,7 @@
51 51 </div>
52 52  
53 53 <footer>
54   - <p>SearchEngine © 2025 | API服务地址: <span id="apiUrl">http://localhost:8000</span></p>
  54 + <p>SearchEngine © 2025 | API服务地址: <span id="apiUrl">http://localhost:6002</span></p>
55 55 </footer>
56 56  
57 57 <script src="/static/js/app.js"></script>
... ...
frontend/static/js/app.js
1 1 // SearchEngine Frontend JavaScript
2 2  
3 3 // API endpoint
4   -const API_BASE_URL = 'http://localhost:8000';
  4 +const API_BASE_URL = 'http://localhost:6002';
5 5  
6 6 // Update API URL display
7 7 document.getElementById('apiUrl').textContent = API_BASE_URL;
... ... @@ -68,7 +68,7 @@ async function performSearch() {
68 68 <div class="error-message">
69 69 <strong>搜索出错:</strong> ${error.message}
70 70 <br><br>
71   - <small>请确保后端服务正在运行 (http://localhost:8000)</small>
  71 + <small>请确保后端服务正在运行 (http://localhost:6002)</small>
72 72 </div>
73 73 `;
74 74 } finally {
... ...
... ... @@ -151,7 +151,7 @@ def main():
151 151 serve_parser = subparsers.add_parser('serve', help='Start API service')
152 152 serve_parser.add_argument('--customer', default='customer1', help='Customer ID')
153 153 serve_parser.add_argument('--host', default='0.0.0.0', help='Host to bind to')
154   - serve_parser.add_argument('--port', type=int, default=8000, help='Port to bind to')
  154 + serve_parser.add_argument('--port', type=int, default=6002, help='Port to bind to')
155 155 serve_parser.add_argument('--es-host', default='http://localhost:9200', help='Elasticsearch host')
156 156 serve_parser.add_argument('--reload', action='store_true', help='Enable auto-reload')
157 157  
... ...
scripts/frontend_server.py
... ... @@ -12,7 +12,7 @@ import sys
12 12 frontend_dir = os.path.join(os.path.dirname(__file__), '../frontend')
13 13 os.chdir(frontend_dir)
14 14  
15   -PORT = 8080
  15 +PORT = 6003
16 16  
17 17 class MyHTTPRequestHandler(http.server.SimpleHTTPRequestHandler):
18 18 """Custom request handler with CORS support."""
... ...
scripts/start_frontend.sh
... ... @@ -16,13 +16,13 @@ echo -e &quot;${GREEN}========================================${NC}&quot;
16 16 echo -e "${GREEN}Starting Frontend Server${NC}"
17 17 echo -e "${GREEN}========================================${NC}"
18 18  
19   -PORT=8080
  19 +PORT=6003
20 20  
21 21 echo -e "\n${YELLOW}Frontend will be available at:${NC}"
22 22 echo -e " ${GREEN}http://localhost:$PORT${NC}"
23 23 echo ""
24 24 echo -e "${YELLOW}Make sure the backend API is running at:${NC}"
25   -echo -e " ${GREEN}http://localhost:8000${NC}"
  25 +echo -e " ${GREEN}http://localhost:6002${NC}"
26 26 echo ""
27 27  
28 28 python scripts/frontend_server.py
... ...
setup.sh
1 1 #!/bin/bash
2 2  
  3 +source /home/tw/miniconda3/etc/profile.d/conda.sh
  4 +
3 5 # SearchEngine Setup and Startup Script
4 6 # This script sets up the environment and starts all services
5 7  
... ...
start_all.sh
... ... @@ -3,6 +3,8 @@
3 3 # One-click startup script for SearchEngine
4 4 # This script starts everything you need
5 5  
  6 +source /home/tw/miniconda3/etc/profile.d/conda.sh
  7 +
6 8 set -e
7 9  
8 10 cd "$(dirname "$0")"
... ... @@ -67,7 +69,7 @@ echo -e &quot;${YELLOW}等待后端服务启动...${NC}&quot;
67 69 sleep 5
68 70  
69 71 # Check if backend is running
70   -if curl -s http://localhost:8000/admin/health > /dev/null 2>&1; then
  72 +if curl -s http://localhost:6002/admin/health > /dev/null 2>&1; then
71 73 echo -e "${GREEN}✓ 后端服务运行正常${NC}"
72 74 else
73 75 echo -e "${RED}✗ 后端服务启动失败,请检查日志: logs/backend.log${NC}"
... ... @@ -81,9 +83,9 @@ echo -e &quot;${GREEN}所有服务启动完成!${NC}&quot;
81 83 echo -e "${GREEN}========================================${NC}"
82 84 echo ""
83 85 echo -e "访问地址:"
84   -echo -e " ${GREEN}前端界面: http://localhost:8080${NC}"
85   -echo -e " ${GREEN}后端API: http://localhost:8000${NC}"
86   -echo -e " ${GREEN}API文档: http://localhost:8000/docs${NC}"
  86 +echo -e " ${GREEN}前端界面: http://localhost:6003${NC}"
  87 +echo -e " ${GREEN}后端API: http://localhost:6002${NC}"
  88 +echo -e " ${GREEN}API文档: http://localhost:6002/docs${NC}"
87 89 echo ""
88 90 echo -e "日志文件:"
89 91 echo -e " 后端: logs/backend.log"
... ...