Commit a7920e17d2c4bbb4dd781a612acf3b71c7d0a928
1 parent
1589c4f8
项目名称和部署路径修改
Showing
50 changed files
with
202 additions
and
135 deletions
Show diff stats
.cursor/plans/es-query-25a9f060.plan.检索表达式优化.ES_function表达式.md
| ... | ... | @@ -48,7 +48,7 @@ |
| 48 | 48 | |
| 49 | 49 | ### 2. 文件修改清单 |
| 50 | 50 | |
| 51 | -#### `/home/tw/SearchEngine/search/multilang_query_builder.py` | |
| 51 | +#### `/home/tw/saas-search/search/multilang_query_builder.py` | |
| 52 | 52 | |
| 53 | 53 | **修改 `build_multilang_query` 方法**(约156-190行): |
| 54 | 54 | |
| ... | ... | @@ -165,9 +165,9 @@ def _build_score_functions(self) -> List[Dict[str, Any]]: |
| 165 | 165 | return functions |
| 166 | 166 | ``` |
| 167 | 167 | |
| 168 | -#### `/home/tw/SearchEngine/search/ranking_engine.py` | |
| 168 | +#### `/home/tw/saas-search/search/ranking_engine.py` | |
| 169 | 169 | |
| 170 | -**重命名为** `/home/tw/SearchEngine/search/rerank_engine.py` | |
| 170 | +**重命名为** `/home/tw/saas-search/search/rerank_engine.py` | |
| 171 | 171 | |
| 172 | 172 | **修改类名和文档**: |
| 173 | 173 | |
| ... | ... | @@ -194,7 +194,7 @@ class RerankEngine: |
| 194 | 194 | self.parsed_terms = self._parse_expression(ranking_expression) |
| 195 | 195 | ``` |
| 196 | 196 | |
| 197 | -#### `/home/tw/SearchEngine/search/__init__.py` | |
| 197 | +#### `/home/tw/saas-search/search/__init__.py` | |
| 198 | 198 | |
| 199 | 199 | 更新导入: |
| 200 | 200 | |
| ... | ... | @@ -202,7 +202,7 @@ class RerankEngine: |
| 202 | 202 | from .rerank_engine import RerankEngine # 原 RankingEngine |
| 203 | 203 | ``` |
| 204 | 204 | |
| 205 | -#### `/home/tw/SearchEngine/search/searcher.py` | |
| 205 | +#### `/home/tw/saas-search/search/searcher.py` | |
| 206 | 206 | |
| 207 | 207 | **修改初始化**(约88行): |
| 208 | 208 | |
| ... | ... | @@ -245,7 +245,7 @@ if enable_rerank and self.rerank_engine.enabled: |
| 245 | 245 | ) |
| 246 | 246 | ``` |
| 247 | 247 | |
| 248 | -#### `/home/tw/SearchEngine/config/schema/tenant1/config.yaml` | |
| 248 | +#### `/home/tw/saas-search/config/schema/tenant1/config.yaml` | |
| 249 | 249 | |
| 250 | 250 | **添加配置项**(254行后): |
| 251 | 251 | |
| ... | ... | @@ -274,7 +274,7 @@ function_score: |
| 274 | 274 | weight: 1.1 |
| 275 | 275 | ``` |
| 276 | 276 | |
| 277 | -#### `/home/tw/SearchEngine/config/tenant_config.py` | |
| 277 | +#### `/home/tw/saas-search/config/tenant_config.py` | |
| 278 | 278 | |
| 279 | 279 | **更新配置类**: |
| 280 | 280 | ... | ... |
.cursor/plans/es-query-25a9f060.plan.检索表达式优化.ES_function表达式.基于ES_fuction_score原生能力优化.md
| ... | ... | @@ -30,7 +30,7 @@ |
| 30 | 30 | |
| 31 | 31 | ## 配置设计(简化版) |
| 32 | 32 | |
| 33 | -### `/home/tw/SearchEngine/config/schema/tenant1/config.yaml` | |
| 33 | +### `/home/tw/saas-search/config/schema/tenant1/config.yaml` | |
| 34 | 34 | |
| 35 | 35 | ```yaml |
| 36 | 36 | # Function Score配置(ES层打分规则) |
| ... | ... | @@ -131,7 +131,7 @@ rerank: |
| 131 | 131 | |
| 132 | 132 | ### 1. 定义配置模型 |
| 133 | 133 | |
| 134 | -**文件**: `/home/tw/SearchEngine/config/models.py`(新建或更新tenant_config.py) | |
| 134 | +**文件**: `/home/tw/saas-search/config/models.py`(新建或更新tenant_config.py) | |
| 135 | 135 | |
| 136 | 136 | ```python |
| 137 | 137 | from dataclasses import dataclass, field |
| ... | ... | @@ -186,7 +186,7 @@ class RerankConfig: |
| 186 | 186 | |
| 187 | 187 | ### 2. 修改 MultiLanguageQueryBuilder |
| 188 | 188 | |
| 189 | -**文件**: `/home/tw/SearchEngine/search/multilang_query_builder.py` | |
| 189 | +**文件**: `/home/tw/saas-search/search/multilang_query_builder.py` | |
| 190 | 190 | |
| 191 | 191 | **修改 init 方法**: |
| 192 | 192 | |
| ... | ... | @@ -276,13 +276,13 @@ if fs_config and fs_config.max_boost: |
| 276 | 276 | |
| 277 | 277 | ### 3. 更新配置加载器 |
| 278 | 278 | |
| 279 | -**文件**: `/home/tw/SearchEngine/config/__init__.py` 或 `config/loader.py` | |
| 279 | +**文件**: `/home/tw/saas-search/config/__init__.py` 或 `config/loader.py` | |
| 280 | 280 | |
| 281 | 281 | 确保正确加载 `function_score` 和 `rerank` 配置段 |
| 282 | 282 | |
| 283 | 283 | ### 4. 更新示例配置 |
| 284 | 284 | |
| 285 | -**文件**: `/home/tw/SearchEngine/config/schema/tenant1/config.yaml` | |
| 285 | +**文件**: `/home/tw/saas-search/config/schema/tenant1/config.yaml` | |
| 286 | 286 | |
| 287 | 287 | 在 `ranking` 配置后添加新配置(参见上面完整YAML) |
| 288 | 288 | ... | ... |
.github/workflows/test.yml
CHANGES.md
CLAUDE.md
| ... | ... | @@ -23,11 +23,12 @@ This is a **production-ready Multi-Tenant E-Commerce Search SaaS** platform spec |
| 23 | 23 | |
| 24 | 24 | ## Development Environment |
| 25 | 25 | |
| 26 | -**Required Environment Setup:** | |
| 26 | +**Required Environment Setup:** Use project root `activate.sh` (activates conda env `searchengine` and loads `.env`). On a new machine, set `CONDA_ROOT` if conda is not at default path. | |
| 27 | 27 | ```bash |
| 28 | -source /home/tw/miniconda3/etc/profile.d/conda.sh | |
| 29 | -conda activate searchengine | |
| 28 | +# Optional on new machine: if conda is ~/anaconda3/bin/conda → export CONDA_ROOT=$HOME/anaconda3 | |
| 29 | +source activate.sh | |
| 30 | 30 | ``` |
| 31 | +See `docs/环境配置说明.md` for first-time env creation (`conda env create -f environment.yml` or `pip install -r requirements.txt`). | |
| 31 | 32 | |
| 32 | 33 | **Database Configuration:** |
| 33 | 34 | ```yaml |
| ... | ... | @@ -48,11 +49,12 @@ password: P89cZHS5d7dFyc9R |
| 48 | 49 | |
| 49 | 50 | ### Environment Setup |
| 50 | 51 | ```bash |
| 51 | -# Complete environment setup | |
| 52 | -./setup.sh | |
| 52 | +# Activate environment (canonical: use activate.sh) | |
| 53 | +source activate.sh | |
| 53 | 54 | |
| 54 | -# Install Python dependencies | |
| 55 | -pip install -r requirements.txt | |
| 55 | +# First-time / new machine: create env and install deps | |
| 56 | +./setup.sh # or: conda env create -f environment.yml | |
| 57 | +# If pip-only: pip install -r requirements.txt | |
| 56 | 58 | ``` |
| 57 | 59 | |
| 58 | 60 | ### Data Management |
| ... | ... | @@ -109,7 +111,7 @@ python main.py search "query" --tenant-id 1 --size 10 |
| 109 | 111 | |
| 110 | 112 | ### Core Components |
| 111 | 113 | ``` |
| 112 | -/data/tw/SearchEngine/ | |
| 114 | +/data/tw/saas-search/ | |
| 113 | 115 | ├── api/ # FastAPI REST API service (port 6002) |
| 114 | 116 | ├── config/ # Configuration management system |
| 115 | 117 | ├── indexer/ # MySQL → Elasticsearch data pipeline | ... | ... |
CLIP_SERVICE_README.md
| ... | ... | @@ -14,8 +14,9 @@ |
| 14 | 14 | 推荐使用 Conda 新建一个专用环境(与本项目的 `searchengine` 环境隔离): |
| 15 | 15 | |
| 16 | 16 | ```bash |
| 17 | -# 1)加载 conda | |
| 18 | -source /home/tw/miniconda3/etc/profile.d/conda.sh | |
| 17 | +# 1)加载 conda(你的 conda 是 ~/anaconda3/bin/conda → CONDA_ROOT=~/anaconda3) | |
| 18 | +export CONDA_ROOT=${CONDA_ROOT:-$HOME/anaconda3} # 或你的 Conda 安装路径 | |
| 19 | +source "$CONDA_ROOT/etc/profile.d/conda.sh" | |
| 19 | 20 | |
| 20 | 21 | # 2)创建 clip 向量服务专用环境 |
| 21 | 22 | conda create -n clip_service python=3.9 -y |
| ... | ... | @@ -46,14 +47,14 @@ chmod +x scripts/stop_clip_service.sh |
| 46 | 47 | ### 2.1 启动服务 |
| 47 | 48 | |
| 48 | 49 | ```bash |
| 49 | -cd /home/tw/SearchEngine | |
| 50 | +cd /data/saas-search | |
| 50 | 51 | ./scripts/start_clip_service.sh |
| 51 | 52 | ``` |
| 52 | 53 | |
| 53 | 54 | 脚本行为: |
| 54 | 55 | |
| 55 | -- 自动 `cd` 到仓库根目录 `/home/tw/SearchEngine` | |
| 56 | -- 尝试加载 `/home/tw/miniconda3/etc/profile.d/conda.sh` 并激活 `clip_service` 环境 | |
| 56 | +- 自动 `cd` 到仓库根目录 | |
| 57 | +- 尝试加载 `$CONDA_ROOT/etc/profile.d/conda.sh` 并激活 `clip_service` 环境(可通过 `export CONDA_ROOT=...` 适配新机器) | |
| 57 | 58 | - 使用 `nohup python -m clip_server` 启动服务到后台 |
| 58 | 59 | - 将日志写入 `logs/clip_service.log` |
| 59 | 60 | - 将进程号写入 `logs/clip_service.pid` |
| ... | ... | @@ -65,7 +66,7 @@ cd /home/tw/SearchEngine |
| 65 | 66 | ### 2.2 停止服务 |
| 66 | 67 | |
| 67 | 68 | ```bash |
| 68 | -cd /home/tw/SearchEngine | |
| 69 | +cd /data/saas-search | |
| 69 | 70 | ./scripts/stop_clip_service.sh |
| 70 | 71 | ``` |
| 71 | 72 | |
| ... | ... | @@ -101,7 +102,8 @@ cd /home/tw/SearchEngine |
| 101 | 102 | 1. 确认 `clip_service` 环境创建并安装成功: |
| 102 | 103 | |
| 103 | 104 | ```bash |
| 104 | - source /home/tw/miniconda3/etc/profile.d/conda.sh | |
| 105 | + export CONDA_ROOT=${CONDA_ROOT:-$HOME/anaconda3} | |
| 106 | + source "$CONDA_ROOT/etc/profile.d/conda.sh" | |
| 105 | 107 | conda activate clip_service |
| 106 | 108 | python -c "import jina; print('jina version:', jina.__version__)" |
| 107 | 109 | ``` |
| ... | ... | @@ -109,7 +111,7 @@ cd /home/tw/SearchEngine |
| 109 | 111 | 2. 启动服务并查看日志: |
| 110 | 112 | |
| 111 | 113 | ```bash |
| 112 | - cd /home/tw/SearchEngine | |
| 114 | + cd /data/saas-search | |
| 113 | 115 | ./scripts/start_clip_service.sh |
| 114 | 116 | tail -f logs/clip_service.log |
| 115 | 117 | ``` | ... | ... |
README.md
| ... | ... | @@ -100,16 +100,23 @@ localhost替换为 |
| 100 | 100 | |
| 101 | 101 | |
| 102 | 102 | ## 项目环境 |
| 103 | -source /home/tw/miniconda3/etc/profile.d/conda.sh | |
| 104 | -conda activate searchengine | |
| 105 | -source .env | |
| 103 | + | |
| 104 | +以项目根目录的 **`activate.sh`** 为准(会激活 Conda 环境 `searchengine` 并加载 `.env`): | |
| 105 | + | |
| 106 | +```bash | |
| 107 | +# 若在新机器且 Conda 不在默认路径,先设置: | |
| 108 | +# - 你的 conda 是 ~/anaconda3/bin/conda,则:export CONDA_ROOT=$HOME/anaconda3 | |
| 109 | +source activate.sh | |
| 110 | +``` | |
| 111 | + | |
| 112 | +新机器首次需创建环境,见 `docs/环境配置说明.md`(`conda env create -f environment.yml` 或 `pip install -r requirements.txt`)。 | |
| 106 | 113 | |
| 107 | 114 | ## 测试pipeline |
| 108 | 115 | |
| 109 | 116 | 1. |
| 110 | 117 | 店铺1 tenant_id=162: |
| 111 | 118 | fake数据 生成商品导入数据 提交到店匠的店铺: |
| 112 | -cd /home/tw/SearchEngine && source /home/tw/miniconda3/etc/profile.d/conda.sh && conda activate searchengine && python scripts/csv_to_excel_multi_variant.py --output with_colors.xlsx | |
| 119 | +cd /data/saas-search && source activate.sh && python scripts/csv_to_excel_multi_variant.py --output with_colors.xlsx | |
| 113 | 120 | |
| 114 | 121 | 店铺2 tenant_id= |
| 115 | 122 | |
| ... | ... | @@ -143,7 +150,7 @@ python scripts/recreate_and_import.py \ |
| 143 | 150 | |
| 144 | 151 | | 步骤 | 去哪里看 | 摘要 | |
| 145 | 152 | |------|---------|------| |
| 146 | -| 1. 准备环境 | `环境配置说明.md` / `Usage-Guide.md` | Conda/依赖、Elasticsearch、MySQL、必需变量 | | |
| 153 | +| 1. 准备环境 | `docs/环境配置说明.md` / `Usage-Guide.md` | Conda、`activate.sh`、依赖、ES/MySQL、`.env` | | |
| 147 | 154 | | 2. 构造测试数据 | `测试数据指南.md` | Tenant1 Mock、Tenant2 CSV、`mock_data.sh` / `ingest.sh` | |
| 148 | 155 | | 3. 启动与验证 | `Usage-Guide.md` | `run.sh` 一键启动、分步脚本、日志与健康检查 | |
| 149 | 156 | | 4. 理解架构 | `系统设计文档.md` | 数据流、配置系统、查询/搜索/索引模块 | |
| ... | ... | @@ -155,8 +162,9 @@ python scripts/recreate_and_import.py \ |
| 155 | 162 | ### Runtimes & 命令示例 |
| 156 | 163 | |
| 157 | 164 | ```bash |
| 158 | -# 1. 安装依赖与准备服务 | |
| 159 | -pip install -r requirements.txt # 详见 USAGE_GUIDE.md | |
| 165 | +# 1. 安装依赖与准备服务(环境创建见 docs/环境配置说明.md) | |
| 166 | +source activate.sh # 或先 export CONDA_ROOT=你的conda路径 | |
| 167 | +pip install -r requirements.txt # 若用 environment.yml 创建环境可省略 | |
| 160 | 168 | docker run -d --name es -p 9200:9200 elasticsearch:8.11.0 |
| 161 | 169 | |
| 162 | 170 | # 2. 构造测试数据并导入 MySQL |
| ... | ... | @@ -187,7 +195,7 @@ curl -X POST http://localhost:6002/search/ \ |
| 187 | 195 | |
| 188 | 196 | | 文档 | 内容提要 | 适用场景 | |
| 189 | 197 | |------|----------|----------| |
| 190 | -| `环境配置说明.md` | 系统要求、Conda/依赖、外部服务账号、常用端口 | 首次部署、环境核对 | | |
| 198 | +| `docs/环境配置说明.md` | 系统要求、`activate.sh`、Conda/依赖、外部服务、CONDA_ROOT | 首次部署、新机器环境 | | |
| 191 | 199 | | `Usage-Guide.md` | 环境准备、服务启动、配置、日志、验证手册 | 日常运维、调试 | |
| 192 | 200 | | `基础配置指南.md` | 统一硬编码配置说明、索引结构、查询配置 | 了解系统配置、修改配置 | |
| 193 | 201 | | `测试数据指南.md` | 两个租户的模拟/CSV 数据构造 & MySQL→ES 流程 | 数据准备、联调 | | ... | ... |
activate.sh
| 1 | 1 | #!/bin/bash |
| 2 | -source /home/tw/miniconda3/etc/profile.d/conda.sh | |
| 2 | +# 新机器部署:可设置 CONDA_ROOT 指向本机 Conda 路径 | |
| 3 | +# 例如你的 conda 是 ~/anaconda3/bin/conda,则 export CONDA_ROOT=$HOME/anaconda3 | |
| 4 | +CONDA_ROOT="${CONDA_ROOT:-/home/tw/miniconda3}" | |
| 5 | +source "$CONDA_ROOT/etc/profile.d/conda.sh" | |
| 3 | 6 | conda activate searchengine |
| 4 | 7 | |
| 5 | 8 | # 如果需要加载 .env 中的环境变量 | ... | ... |
api/indexer_app.py
| ... | ... | @@ -140,7 +140,7 @@ def init_indexer_service(es_host: str = "http://localhost:9200"): |
| 140 | 140 | |
| 141 | 141 | app = FastAPI( |
| 142 | 142 | title="E-Commerce Indexer API", |
| 143 | - description="Dedicated indexing service for SearchEngine", | |
| 143 | + description="Dedicated indexing service for saas-search", | |
| 144 | 144 | version="1.0.0", |
| 145 | 145 | docs_url="/docs", |
| 146 | 146 | redoc_url="/redoc", | ... | ... |
config/env_config.py
| 1 | 1 | """ |
| 2 | -Centralized configuration management for SearchEngine. | |
| 2 | +Centralized configuration management for saas-search. | |
| 3 | 3 | |
| 4 | 4 | Loads configuration from environment variables and .env file. |
| 5 | 5 | This module provides a single point for loading .env and setting defaults. |
| ... | ... | @@ -80,7 +80,7 @@ DB_CONFIG = { |
| 80 | 80 | def print_config(): |
| 81 | 81 | """Print current configuration (with sensitive data masked).""" |
| 82 | 82 | print("=" * 60) |
| 83 | - print("SearchEngine Configuration") | |
| 83 | + print("saas-search Configuration") | |
| 84 | 84 | print("=" * 60) |
| 85 | 85 | |
| 86 | 86 | print("\nElasticsearch:") | ... | ... |
data/wanbang/README.md
| ... | ... | @@ -37,7 +37,7 @@ pip install requests |
| 37 | 37 | ### 2. 测试运行(推荐先测试) |
| 38 | 38 | |
| 39 | 39 | ```bash |
| 40 | -cd /home/tw/SearchEngine/data_crawling | |
| 40 | +cd /home/tw/saas-search/data_crawling | |
| 41 | 41 | python test_crawler.py |
| 42 | 42 | ``` |
| 43 | 43 | |
| ... | ... | @@ -177,7 +177,7 @@ cat shopee_results/summary.json |
| 177 | 177 | #### 方法1:使用配置文件(推荐) |
| 178 | 178 | |
| 179 | 179 | ```bash |
| 180 | -cd /home/tw/SearchEngine/data_crawling | |
| 180 | +cd /home/tw/saas-search/data_crawling | |
| 181 | 181 | cp config.example.py config.py |
| 182 | 182 | # 编辑 config.py,填入你的API密钥 |
| 183 | 183 | ``` | ... | ... |
data/wanbang/使用说明.md
| ... | ... | @@ -39,7 +39,7 @@ data_crawling/ |
| 39 | 39 | ### 1. 测试运行(推荐) |
| 40 | 40 | |
| 41 | 41 | ```bash |
| 42 | -cd /home/tw/SearchEngine/data_crawling | |
| 42 | +cd /home/tw/saas-search/data_crawling | |
| 43 | 43 | python test_crawler.py |
| 44 | 44 | ``` |
| 45 | 45 | |
| ... | ... | @@ -233,7 +233,7 @@ COUNTRY = '.sg' # 改为新加坡站 |
| 233 | 233 | # 联系万邦API开通Shopee接口 |
| 234 | 234 | |
| 235 | 235 | # 步骤2: 测试 |
| 236 | -cd /home/tw/SearchEngine/data_crawling | |
| 236 | +cd /home/tw/saas-search/data_crawling | |
| 237 | 237 | python test_crawler.py |
| 238 | 238 | |
| 239 | 239 | # 步骤3: 检查测试结果 | ... | ... |
docs/CNCLIP_SERVICE说明文档.md
docs/ES/ES_9
| ... | ... | @@ -236,9 +236,9 @@ http://<kibana-server-ip>:5601 |
| 236 | 236 | |
| 237 | 237 | --- |
| 238 | 238 | |
| 239 | -### 9. 与现有 SearchEngine 项目集成 | |
| 239 | +### 9. 与现有 saas-search 项目集成 | |
| 240 | 240 | |
| 241 | -在这台新机器上跑你的 SearchEngine 项目时: | |
| 241 | +在这台新机器上跑你的 saas-search 项目时: | |
| 242 | 242 | |
| 243 | 243 | - 环境变量或配置里的 ES 地址需要指向这台机器,例如: |
| 244 | 244 | - `ES_HOST=http://127.0.0.1:9200` | ... | ... |
docs/Usage-Guide.md
| 1 | -# 使用指南 - SearchEngine | |
| 1 | +# 使用指南 - saas-search | |
| 2 | 2 | |
| 3 | 3 | 本文档提供完整的使用指南,包括环境准备、服务启动、配置说明、日志查看等。 |
| 4 | 4 | |
| ... | ... | @@ -25,13 +25,19 @@ |
| 25 | 25 | |
| 26 | 26 | ### 安装依赖 |
| 27 | 27 | |
| 28 | -#### 1. 安装Python依赖 | |
| 28 | +#### 1. 安装 Python 依赖与激活环境 | |
| 29 | + | |
| 30 | +**推荐**:使用项目根目录的 `activate.sh` 激活环境(会加载 `.env`)。新机器部署时若 Conda 不在默认路径,请先设置 `CONDA_ROOT`(例如你的 conda 是 `~/anaconda3/bin/conda`,则 `export CONDA_ROOT=$HOME/anaconda3`)。详见 `docs/环境配置说明.md`。 | |
| 29 | 31 | |
| 30 | 32 | ```bash |
| 31 | -cd /home/tw/SearchEngine | |
| 32 | -pip install -r requirements.txt | |
| 33 | +cd /data/saas-search | |
| 34 | +source activate.sh | |
| 33 | 35 | ``` |
| 34 | 36 | |
| 37 | +首次在新机器创建环境时,可任选其一: | |
| 38 | +- `conda env create -f environment.yml`(推荐,与 environment.yml 一致) | |
| 39 | +- 或创建 env 后 `pip install -r requirements.txt` | |
| 40 | + | |
| 35 | 41 | #### 2. 启动Elasticsearch |
| 36 | 42 | |
| 37 | 43 | **方式1: 使用Docker(推荐)** |
| ... | ... | @@ -91,7 +97,7 @@ API_PORT=6002 |
| 91 | 97 | ### 方式1: 一键启动(推荐) |
| 92 | 98 | |
| 93 | 99 | ```bash |
| 94 | -cd /home/tw/SearchEngine | |
| 100 | +cd /data/saas-search | |
| 95 | 101 | ./run.sh |
| 96 | 102 | ``` |
| 97 | 103 | |
| ... | ... | @@ -451,7 +457,7 @@ curl "https://api.yourdomain.com/search/suggestions?q=iph&size=5&language=en&wit |
| 451 | 457 | #### UAT 环境(索引前缀 uat_) |
| 452 | 458 | |
| 453 | 459 | ```bash |
| 454 | -cd /home/tw/SearchEngine | |
| 460 | +cd /data/saas-search | |
| 455 | 461 | |
| 456 | 462 | # 1. 切换到 UAT 环境配置 |
| 457 | 463 | cp .env.uat .env |
| ... | ... | @@ -475,7 +481,7 @@ curl -X POST "http://localhost:6004/indexer/reindex" \ |
| 475 | 481 | #### PROD 环境(无前缀) |
| 476 | 482 | |
| 477 | 483 | ```bash |
| 478 | -cd /home/tw/SearchEngine | |
| 484 | +cd /data/saas-search | |
| 479 | 485 | |
| 480 | 486 | # 1. 切换到 PROD 环境配置 |
| 481 | 487 | cp .env.prod .env | ... | ... |
docs/向量化模块和API说明文档.md
| 1 | 1 | # 鍚戦噺鍖栨ā鍧楀拰API璇存槑鏂囨。 |
| 2 | 2 | |
| 3 | -鏈枃妗h缁嗚鏄嶴earchEngine椤圭洰涓殑鍚戦噺鍖栨ā鍧楁灦鏋勩丄PI鎺ュ彛銆侀厤缃柟娉曞拰浣跨敤鎸囧崡銆 | |
| 3 | +鏈枃妗h缁嗚鏄巗aas-search椤圭洰涓殑鍚戦噺鍖栨ā鍧楁灦鏋勩丄PI鎺ュ彛銆侀厤缃柟娉曞拰浣跨敤鎸囧崡銆 | |
| 4 | 4 | |
| 5 | 5 | ## 鐩綍 |
| 6 | 6 | |
| ... | ... | @@ -62,7 +62,7 @@ |
| 62 | 62 | |
| 63 | 63 | ### 1.1 鍚戦噺鍖栨ā鍧楃畝浠 |
| 64 | 64 | |
| 65 | -SearchEngine椤圭洰瀹炵幇浜嗗畬鏁寸殑鏂囨湰鍜屽浘鐗囧悜閲忓寲鑳藉姏锛屾敮鎸佷袱绉嶉儴缃叉柟寮忥細 | |
| 65 | +saas-search椤圭洰瀹炵幇浜嗗畬鏁寸殑鏂囨湰鍜屽浘鐗囧悜閲忓寲鑳藉姏锛屾敮鎸佷袱绉嶉儴缃叉柟寮忥細 | |
| 66 | 66 | |
| 67 | 67 | 1. **鏈湴鍚戦噺鍖栨湇鍔**锛氱嫭绔嬮儴缃茬殑寰湇鍔★紝鍩轰簬鏈湴GPU/CPU杩愯BGE-M3鍜孋N-CLIP妯″瀷 |
| 68 | 68 | 2. **浜戠鍚戦噺鍖栨湇鍔**锛氶泦鎴愰樋閲屼簯DashScope API锛屾寜浣跨敤閲忎粯璐 |
| ... | ... | @@ -117,7 +117,7 @@ SearchEngine椤圭洰瀹炵幇浜嗗畬鏁寸殑鏂囨湰鍜屽浘鐗囧悜閲忓寲鑳藉姏锛屾敮鎸佷袱绉 |
| 117 | 117 | |
| 118 | 118 | ``` |
| 119 | 119 | 鈹屸攢鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹 |
| 120 | -鈹 SearchEngine Main Service 鈹 | |
| 120 | +鈹 saas-search Main Service 鈹 | |
| 121 | 121 | 鈹 (uses CloudTextEncoder) 鈹 |
| 122 | 122 | 鈹斺攢鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹攢鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹鈹 |
| 123 | 123 | 鈹 |
| ... | ... | @@ -169,9 +169,10 @@ SearchEngine椤圭洰瀹炵幇浜嗗畬鏁寸殑鏂囨湰鍜屽浘鐗囧悜閲忓寲鑳藉姏锛屾敮鎸佷袱绉 |
| 169 | 169 | #### 鏂瑰紡2锛氭墜鍔ㄥ惎鍔 |
| 170 | 170 | |
| 171 | 171 | ```bash |
| 172 | -# 婵娲荤幆澧 | |
| 173 | -source /home/tw/miniconda3/etc/profile.d/conda.sh | |
| 174 | -conda activate searchengine | |
| 172 | +# 婵娲荤幆澧冿紙鎺ㄨ崘浣跨敤椤圭洰鏍圭洰褰 activate.sh锛涙柊鏈哄櫒鎸夐渶 export CONDA_ROOT锛 | |
| 173 | +# 渚嬪浣犵殑 conda 鏄 ~/anaconda3/bin/conda锛屽垯 export CONDA_ROOT=$HOME/anaconda3 | |
| 174 | +cd /data/saas-search | |
| 175 | +source activate.sh | |
| 175 | 176 | |
| 176 | 177 | # 鍚姩鏈嶅姟 |
| 177 | 178 | python -m uvicorn embeddings.server:app \ |
| ... | ... | @@ -1419,6 +1420,6 @@ python scripts/benchmark_embeddings.py |
| 1419 | 1420 | |
| 1420 | 1421 | 濡傛湁闂鎴栧缓璁紝璇疯仈绯婚」鐩淮鎶よ呫 |
| 1421 | 1422 | |
| 1422 | -**椤圭洰浠撳簱**: `/data/tw/SearchEngine` | |
| 1423 | +**椤圭洰浠撳簱**: `/data/saas-search` | |
| 1423 | 1424 | |
| 1424 | 1425 | **鐩稿叧鏂囨。鐩綍**: `docs/` | ... | ... |
docs/测试Pipeline说明.md
| ... | ... | @@ -152,7 +152,7 @@ pytest tests/integration/test_api_integration.py -v |
| 152 | 152 | #### 5.1 启动 Indexer 服务 |
| 153 | 153 | |
| 154 | 154 | ```bash |
| 155 | -cd /home/tw/SearchEngine | |
| 155 | +cd /home/tw/saas-search | |
| 156 | 156 | ./scripts/stop.sh # 停掉已有进程(可选) |
| 157 | 157 | ./scripts/start_indexer.sh # 启动专用 indexer 服务,默认端口 6004 |
| 158 | 158 | ``` | ... | ... |
docs/环境配置说明.md
| 1 | 1 | |
| 2 | +## 1. 系统要求 | |
| 2 | 3 | |
| 4 | +- **操作系统**:Linux(推荐 Ubuntu 18.04+) | |
| 5 | +- **Conda**:Miniconda3 或 Anaconda(用于 Python 环境隔离) | |
| 6 | +- **Python**:3.10(由 Conda 环境提供) | |
| 7 | +- **内存**:建议 8GB+(含模型与 ES) | |
| 8 | +- **磁盘**:10GB+(含模型与索引) | |
| 9 | + | |
| 10 | +--- | |
| 3 | 11 | |
| 4 | 12 | ## 2. Python 运行环境 |
| 5 | 13 | |
| 14 | +**推荐方式(与项目脚本一致)**:使用项目根目录下的 `activate.sh` 激活环境,会自动加载当前目录下的 `.env`(忽略注释与空行): | |
| 15 | + | |
| 6 | 16 | ```bash |
| 7 | -# 1. 激活 Conda | |
| 8 | -source /home/tw/miniconda3/etc/profile.d/conda.sh | |
| 9 | -conda activate searchengine | |
| 17 | +cd /data/saas-search | |
| 18 | +source activate.sh | |
| 19 | +``` | |
| 10 | 20 | |
| 11 | -# 如果部署到新机器,不存在 searchengine 环境时,需要初始化环境: | |
| 12 | -cd /home/tw/SearchEngine | |
| 13 | -pip install -r requirements.txt | |
| 21 | +`activate.sh` 会激活 Conda 环境 `searchengine`。若在新机器上部署,请先设置本机 Conda 路径再执行: | |
| 22 | + | |
| 23 | +```bash | |
| 24 | +# 你的 conda 在 ~/anaconda3/bin/conda,则 CONDA_ROOT=~/anaconda3 | |
| 25 | +export CONDA_ROOT=$HOME/anaconda3 # 或你的 Conda 安装路径(如 /home/ubuntu/anaconda3) | |
| 26 | +source activate.sh | |
| 14 | 27 | ``` |
| 15 | 28 | |
| 29 | +**新机器首次部署(创建环境)**:若本机尚未创建 `searchengine` 环境,任选其一: | |
| 30 | + | |
| 31 | +- **方式 A(推荐,与 environment.yml 一致)**: | |
| 32 | + ```bash | |
| 33 | + cd /data/saas-search | |
| 34 | + export CONDA_ROOT=$HOME/anaconda3 # 或你的 Conda 安装路径 | |
| 35 | + conda env create -f environment.yml | |
| 36 | + source activate.sh | |
| 37 | + ``` | |
| 38 | +- **方式 B(仅 pip)**: | |
| 39 | + ```bash | |
| 40 | + conda create -n searchengine python=3.10 -y | |
| 41 | + conda activate searchengine | |
| 42 | + cd /data/saas-search | |
| 43 | + pip install -r requirements.txt | |
| 44 | + ``` | |
| 45 | + | |
| 46 | +之后日常使用执行 `source activate.sh` 即可(如需可先 `export CONDA_ROOT=...`)。 | |
| 47 | + | |
| 16 | 48 | --- |
| 17 | 49 | |
| 18 | 50 | ## 3. 外部服务与端口 |
| ... | ... | @@ -83,7 +115,7 @@ API_PORT=6002 |
| 83 | 115 | |
| 84 | 116 | ## 6. 店匠数据源说明 |
| 85 | 117 | |
| 86 | -SearchEngine 以 MySQL 中的店匠标准表为权威数据源: | |
| 118 | +saas-search 以 MySQL 中的店匠标准表为权威数据源: | |
| 87 | 119 | |
| 88 | 120 | - `shoplazza_product_spu`:SPU 商品主表 |
| 89 | 121 | - `shoplazza_product_sku`:SKU 变体表 |
| ... | ... | @@ -114,10 +146,13 @@ SearchEngine 以 MySQL 中的店匠标准表为权威数据源: |
| 114 | 146 | |
| 115 | 147 | ## 7. 相关脚本 |
| 116 | 148 | |
| 149 | +- **`activate.sh`**(项目根目录):激活 Conda 环境 `searchengine` 并加载 `.env`,**日常开发/部署以本脚本为准**。 | |
| 117 | 150 | - `scripts/mock_data.sh`:一次性生成 Tenant1 Mock + Tenant2 CSV 数据并导入 MySQL |
| 118 | 151 | - `scripts/ingest.sh <tenant_id> [recreate]`:从 MySQL 写入 Elasticsearch |
| 119 | -- `run.sh` / `restart.sh`:服务启动/重启 | |
| 152 | +- `run.sh` / `restart.sh`:服务启动/重启(内部会调用 `start_backend.sh` 等,同样使用 `CONDA_ROOT`) | |
| 153 | + | |
| 154 | +**新机器部署**:若 Conda 未安装在默认路径(如 `/home/tw/miniconda3`),请在执行上述脚本前设置 `CONDA_ROOT`。例如你的 conda 是 `~/anaconda3/bin/conda`(即 `/home/ubuntu/anaconda3/bin/conda`),则设置:`export CONDA_ROOT=$HOME/anaconda3`。可将该行写入 `~/.bashrc` 或部署说明。 | |
| 120 | 155 | |
| 121 | -更多脚本参数、日志与验证命令参见 `USAGE_GUIDE.md` 与 `TEST_DATA_GUIDE.md`。 | |
| 156 | +更多脚本参数、日志与验证命令参见 `Usage-Guide.md` 与 `测试数据指南.md`。 | |
| 122 | 157 | |
| 123 | 158 | ... | ... |
docs/翻译模块说明.md
| ... | ... | @@ -51,14 +51,14 @@ TRANSLATION_MODEL=qwen # 或 deepl |
| 51 | 51 | 推荐(热更新): |
| 52 | 52 | |
| 53 | 53 | ```bash |
| 54 | -cd /home/tw/SearchEngine | |
| 54 | +cd /home/tw/saas-search | |
| 55 | 55 | uvicorn api.translator_app:app --host 0.0.0.0 --port 6006 --reload |
| 56 | 56 | ``` |
| 57 | 57 | |
| 58 | 58 | 指定默认模型(不传请求 `model` 时生效): |
| 59 | 59 | |
| 60 | 60 | ```bash |
| 61 | -cd /home/tw/SearchEngine | |
| 61 | +cd /home/tw/saas-search | |
| 62 | 62 | export TRANSLATION_MODEL=qwen # 或 deepl |
| 63 | 63 | uvicorn api.translator_app:app --host 0.0.0.0 --port 6006 --reload |
| 64 | 64 | ``` | ... | ... |
embeddings/CLOUD_EMBEDDING_README.md
| ... | ... | @@ -2,7 +2,7 @@ |
| 2 | 2 | |
| 3 | 3 | ## 📝 概述 |
| 4 | 4 | |
| 5 | -本次更新为 SearchEngine 项目添加了基于阿里云 DashScope API 的云端文本向量化功能,使用 `text-embedding-v4` 模型。 | |
| 5 | +本次更新为 saas-search 项目添加了基于阿里云 DashScope API 的云端文本向量化功能,使用 `text-embedding-v4` 模型。 | |
| 6 | 6 | |
| 7 | 7 | ## 🎯 主要功能 |
| 8 | 8 | |
| ... | ... | @@ -25,7 +25,7 @@ |
| 25 | 25 | ## 📁 文件结构 |
| 26 | 26 | |
| 27 | 27 | ``` |
| 28 | -SearchEngine/ | |
| 28 | +saas-search/ | |
| 29 | 29 | ├── embeddings/ |
| 30 | 30 | │ ├── cloud_text_encoder.py # 云端向量化编码器(新增) |
| 31 | 31 | │ ├── text_encoder.py # 本地编码器(现有) | ... | ... |
embeddings/server.py
| ... | ... | @@ -19,7 +19,7 @@ from embeddings.clip_model import ClipImageModel |
| 19 | 19 | |
| 20 | 20 | logger = logging.getLogger(__name__) |
| 21 | 21 | |
| 22 | -app = FastAPI(title="SearchEngine Embedding Service", version="1.0.0") | |
| 22 | +app = FastAPI(title="saas-search Embedding Service", version="1.0.0") | |
| 23 | 23 | |
| 24 | 24 | # Models are loaded at startup, not lazily |
| 25 | 25 | _text_model: Optional[BgeTextModel] = None | ... | ... |
frontend/README.md
frontend/index.html
| ... | ... | @@ -194,7 +194,7 @@ |
| 194 | 194 | </div> |
| 195 | 195 | |
| 196 | 196 | <footer> |
| 197 | - <p>SearchEngine © 2025 | API: <span id="apiUrl">Loading...</span></p> | |
| 197 | + <p>saas-search © 2025 | API: <span id="apiUrl">Loading...</span></p> | |
| 198 | 198 | </footer> |
| 199 | 199 | |
| 200 | 200 | <script src="/static/js/tenant_facets_config.js?v=1.3"></script> | ... | ... |
frontend/static/css/style.css
frontend/static/js/app.js
indexer/ANCHORS_AND_SEMANTIC_ATTRIBUTES.md
| ... | ... | @@ -18,7 +18,7 @@ |
| 18 | 18 | - **Mapping 位置**:`mappings/search_products.json` 中的 `qanchors` 对象。 |
| 19 | 19 | - **结构**(与 `title.{lang}` 一致): |
| 20 | 20 | |
| 21 | -```140:182:/home/tw/SearchEngine/mappings/search_products.json | |
| 21 | +```140:182:/home/tw/saas-search/mappings/search_products.json | |
| 22 | 22 | "qanchors": { |
| 23 | 23 | "type": "object", |
| 24 | 24 | "properties": { |
| ... | ... | @@ -48,7 +48,7 @@ |
| 48 | 48 | - **Mapping 位置**:`mappings/search_products.json`,追加的 nested 字段。 |
| 49 | 49 | - **结构**: |
| 50 | 50 | |
| 51 | -```1392:1410:/home/tw/SearchEngine/mappings/search_products.json | |
| 51 | +```1392:1410:/home/tw/saas-search/mappings/search_products.json | |
| 52 | 52 | "semantic_attributes": { |
| 53 | 53 | "type": "nested", |
| 54 | 54 | "properties": { |
| ... | ... | @@ -89,7 +89,7 @@ |
| 89 | 89 | - **文件**:`indexer/process_products.py` |
| 90 | 90 | - **函数签名**: |
| 91 | 91 | |
| 92 | -```365:392:/home/tw/SearchEngine/indexer/process_products.py | |
| 92 | +```365:392:/home/tw/saas-search/indexer/process_products.py | |
| 93 | 93 | def analyze_products( |
| 94 | 94 | products: List[Dict[str, str]], |
| 95 | 95 | target_lang: str = "zh", |
| ... | ... | @@ -108,7 +108,7 @@ def analyze_products( |
| 108 | 108 | |
| 109 | 109 | - **支持的输出语言**(在同文件中定义): |
| 110 | 110 | |
| 111 | -```54:62:/home/tw/SearchEngine/indexer/process_products.py | |
| 111 | +```54:62:/home/tw/saas-search/indexer/process_products.py | |
| 112 | 112 | LANG_LABELS: Dict[str, str] = { |
| 113 | 113 | "zh": "中文", |
| 114 | 114 | "en": "英文", |
| ... | ... | @@ -148,7 +148,7 @@ SUPPORTED_LANGS = set(LANG_LABELS.keys()) |
| 148 | 148 | |
| 149 | 149 | - Prompt 中会明确要求“**所有输出内容使用目标语言**”,并给出中英文示例: |
| 150 | 150 | |
| 151 | -```65:81:/home/tw/SearchEngine/indexer/process_products.py | |
| 151 | +```65:81:/home/tw/saas-search/indexer/process_products.py | |
| 152 | 152 | def create_prompt(products: List[Dict[str, str]], target_lang: str = "zh") -> str: |
| 153 | 153 | """创建LLM提示词(根据目标语言输出)""" |
| 154 | 154 | lang_label = LANG_LABELS.get(target_lang, "对应语言") |
| ... | ... | @@ -170,7 +170,7 @@ def create_prompt(products: List[Dict[str, str]], target_lang: str = "zh") -> st |
| 170 | 170 | |
| 171 | 171 | - 返回格式固定为 Markdown 表格,首行头为: |
| 172 | 172 | |
| 173 | -```89:91:/home/tw/SearchEngine/indexer/process_products.py | |
| 173 | +```89:91:/home/tw/saas-search/indexer/process_products.py | |
| 174 | 174 | | 序号 | 商品标题 | 品类路径 | 细分标签 | 适用人群 | 使用场景 | 适用季节 | 关键属性 | 材质说明 | 功能特点 | 商品卖点 | 锚文本 | |
| 175 | 175 | |----|----|----|----|----|----|----|----|----|----|----|----| |
| 176 | 176 | ``` |
| ... | ... | @@ -185,7 +185,7 @@ def create_prompt(products: List[Dict[str, str]], target_lang: str = "zh") -> st |
| 185 | 185 | |
| 186 | 186 | 在 `SPUDocumentTransformer.transform_spu_to_doc(...)` 的末尾,在所有基础字段(多语言文本、类目、SKU/规格、价格、库存等)填充完成后,会调用: |
| 187 | 187 | |
| 188 | -```96:101:/home/tw/SearchEngine/indexer/document_transformer.py | |
| 188 | +```96:101:/home/tw/saas-search/indexer/document_transformer.py | |
| 189 | 189 | # 文本字段处理(翻译等) |
| 190 | 190 | self._fill_text_fields(doc, spu_row, primary_lang) |
| 191 | 191 | |
| ... | ... | @@ -206,7 +206,7 @@ def create_prompt(products: List[Dict[str, str]], target_lang: str = "zh") -> st |
| 206 | 206 | |
| 207 | 207 | 在 `_fill_llm_attributes` 内部: |
| 208 | 208 | |
| 209 | -```148:164:/home/tw/SearchEngine/indexer/document_transformer.py | |
| 209 | +```148:164:/home/tw/saas-search/indexer/document_transformer.py | |
| 210 | 210 | try: |
| 211 | 211 | index_langs = self.tenant_config.get("index_languages") or ["en", "zh"] |
| 212 | 212 | except Exception: |
| ... | ... | @@ -232,7 +232,7 @@ def create_prompt(products: List[Dict[str, str]], target_lang: str = "zh") -> st |
| 232 | 232 | |
| 233 | 233 | 核心逻辑(简化描述): |
| 234 | 234 | |
| 235 | -```164:210:/home/tw/SearchEngine/indexer/document_transformer.py | |
| 235 | +```164:210:/home/tw/saas-search/indexer/document_transformer.py | |
| 236 | 236 | spu_id = str(spu_row.get("id") or "").strip() |
| 237 | 237 | title = str(spu_row.get("title") or "").strip() |
| 238 | 238 | if not spu_id or not title: |
| ... | ... | @@ -365,7 +365,7 @@ def create_prompt(products: List[Dict[str, str]], target_lang: str = "zh") -> st |
| 365 | 365 | |
| 366 | 366 | 现有 `suggestion/builder.py` 已经支持从 `qanchors.{lang}` 中提取候选: |
| 367 | 367 | |
| 368 | -```249:287:/home/tw/SearchEngine/suggestion/builder.py | |
| 368 | +```249:287:/home/tw/saas-search/suggestion/builder.py | |
| 369 | 369 | # Step 1: product title/qanchors |
| 370 | 370 | hits = self._scan_products(tenant_id, batch_size=batch_size) |
| 371 | 371 | ... | ... | ... |
indexer/README.md
| ... | ... | @@ -7,7 +7,7 @@ |
| 7 | 7 | - 负责**商品/店铺/类目等基础数据同步**(写 MySQL)。 |
| 8 | 8 | - 负责**多租户环境下的全量/增量索引调度**,但不再关心具体 doc 字段细节。 |
| 9 | 9 | |
| 10 | -- **Python 索引富化模块(本项目 SearchEngine / indexer)** | |
| 10 | +- **Python 索引富化模块(本项目 saas-search / indexer)** | |
| 11 | 11 | - 负责“**如何把 MySQL 基础数据变成符合 ES mapping 的 doc**”,包括: |
| 12 | 12 | - 多语言字段组织; |
| 13 | 13 | - 翻译调用与缓存; | ... | ... |
main.py
| 1 | 1 | #!/usr/bin/env python3 |
| 2 | 2 | """ |
| 3 | -Main entry point for SearchEngine operations. | |
| 3 | +Main entry point for saas-search operations. | |
| 4 | 4 | |
| 5 | 5 | Provides a unified CLI for common operations: |
| 6 | 6 | - serve: Start API service (search + admin routes) |
| ... | ... | @@ -146,7 +146,7 @@ def cmd_build_suggestions(args): |
| 146 | 146 | def main(): |
| 147 | 147 | """Main CLI entry point.""" |
| 148 | 148 | parser = argparse.ArgumentParser( |
| 149 | - description='SearchEngine - E-Commerce Search SaaS', | |
| 149 | + description='saas-search - E-Commerce Search SaaS', | |
| 150 | 150 | formatter_class=argparse.RawDescriptionHelpFormatter |
| 151 | 151 | ) |
| 152 | 152 | ... | ... |
requirements.txt
| 1 | -# Python dependencies for SearchEngine | |
| 1 | +# Python dependencies for saas-search | |
| 2 | 2 | |
| 3 | 3 | # Core |
| 4 | 4 | pyyaml>=6.0 |
| ... | ... | @@ -27,6 +27,8 @@ fastapi>=0.100.0 |
| 27 | 27 | uvicorn[standard]>=0.23.0 |
| 28 | 28 | pydantic>=2.0.0 |
| 29 | 29 | python-multipart>=0.0.6 |
| 30 | +slowapi>=0.1.9 | |
| 31 | +anyio>=3.7.0 | |
| 30 | 32 | |
| 31 | 33 | # Translation |
| 32 | 34 | requests>=2.31.0 | ... | ... |
reranker/server.py
| ... | ... | @@ -31,7 +31,7 @@ logging.basicConfig( |
| 31 | 31 | ) |
| 32 | 32 | logger = logging.getLogger("reranker.service") |
| 33 | 33 | |
| 34 | -app = FastAPI(title="SearchEngine Reranker Service", version="1.0.0") | |
| 34 | +app = FastAPI(title="saas-search Reranker Service", version="1.0.0") | |
| 35 | 35 | |
| 36 | 36 | _reranker: Optional[BGEReranker] = None |
| 37 | 37 | ... | ... |
restart.sh
| 1 | 1 | #!/bin/bash |
| 2 | 2 | |
| 3 | -# Restart script for SearchEngine services | |
| 3 | +# Restart script for saas-search services | |
| 4 | 4 | # This script stops all services first, then starts them again |
| 5 | 5 | |
| 6 | 6 | cd "$(dirname "$0")" |
| ... | ... | @@ -11,7 +11,7 @@ RED='\033[0;31m' |
| 11 | 11 | NC='\033[0m' |
| 12 | 12 | |
| 13 | 13 | echo -e "${GREEN}========================================${NC}" |
| 14 | -echo -e "${GREEN}SearchEngine服务重启脚本${NC}" | |
| 14 | +echo -e "${GREEN}saas-search服务重启脚本${NC}" | |
| 15 | 15 | echo -e "${GREEN}========================================${NC}" |
| 16 | 16 | |
| 17 | 17 | # Step 1: Stop all services | ... | ... |
| 1 | 1 | #!/bin/bash |
| 2 | 2 | |
| 3 | -# Production startup script for SearchEngine services | |
| 3 | +# Production startup script for saas-search services | |
| 4 | 4 | # This script starts frontend and backend services (no data ingestion) |
| 5 | 5 | |
| 6 | 6 | cd "$(dirname "$0")" |
| ... | ... | @@ -11,7 +11,7 @@ RED='\033[0;31m' |
| 11 | 11 | NC='\033[0m' |
| 12 | 12 | |
| 13 | 13 | echo -e "${GREEN}========================================${NC}" |
| 14 | -echo -e "${GREEN}SearchEngine服务启动脚本${NC}" | |
| 14 | +echo -e "${GREEN}saas-search服务启动脚本${NC}" | |
| 15 | 15 | echo -e "${GREEN}========================================${NC}" |
| 16 | 16 | |
| 17 | 17 | # Create logs directory if it doesn't exist | ... | ... |
scripts/frontend_server.py
scripts/indexer__old_2025_11/ingest.sh
scripts/mock_data.sh
| 1 | 1 | #!/bin/bash |
| 2 | 2 | |
| 3 | 3 | # ============================================================================ |
| 4 | -# Mock Data Script for SearchEngine | |
| 4 | +# Mock Data Script for saas-search | |
| 5 | 5 | # ============================================================================ |
| 6 | 6 | # |
| 7 | 7 | # 功能说明: |
| ... | ... | @@ -20,7 +20,8 @@ |
| 20 | 20 | # ============================================================================ |
| 21 | 21 | |
| 22 | 22 | cd "$(dirname "$0")/.." |
| 23 | -source /home/tw/miniconda3/etc/profile.d/conda.sh | |
| 23 | +CONDA_ROOT="${CONDA_ROOT:-/home/tw/miniconda3}" | |
| 24 | +source "$CONDA_ROOT/etc/profile.d/conda.sh" | |
| 24 | 25 | conda activate searchengine |
| 25 | 26 | |
| 26 | 27 | GREEN='\033[0;32m' | ... | ... |
scripts/start.sh
| 1 | 1 | #!/bin/bash |
| 2 | 2 | |
| 3 | -# Unified startup script for SearchEngine services | |
| 3 | +# Unified startup script for saas-search services | |
| 4 | 4 | # This script starts both frontend and backend services |
| 5 | 5 | |
| 6 | 6 | cd "$(dirname "$0")/.." |
| ... | ... | @@ -11,7 +11,7 @@ RED='\033[0;31m' |
| 11 | 11 | NC='\033[0m' |
| 12 | 12 | |
| 13 | 13 | echo -e "${GREEN}========================================${NC}" |
| 14 | -echo -e "${GREEN}SearchEngine服务启动脚本${NC}" | |
| 14 | +echo -e "${GREEN}saas-search服务启动脚本${NC}" | |
| 15 | 15 | echo -e "${GREEN}========================================${NC}" |
| 16 | 16 | |
| 17 | 17 | # Create logs directory if it doesn't exist | ... | ... |
scripts/start_backend.sh
scripts/start_clip_service.sh
| ... | ... | @@ -10,7 +10,7 @@ set -e |
| 10 | 10 | |
| 11 | 11 | cd "$(dirname "$0")/.." |
| 12 | 12 | |
| 13 | -LOG_DIR="/home/tw/SearchEngine/logs" | |
| 13 | +LOG_DIR="$(pwd)/logs" | |
| 14 | 14 | mkdir -p "${LOG_DIR}" |
| 15 | 15 | PID_FILE="${LOG_DIR}/clip_service.pid" |
| 16 | 16 | LOG_FILE="${LOG_DIR}/clip_service.log" |
| ... | ... | @@ -20,16 +20,17 @@ echo "Starting CLIP vector service (clip-server)" |
| 20 | 20 | echo "========================================" |
| 21 | 21 | |
| 22 | 22 | # Load conda and activate dedicated environment, if available |
| 23 | -if [ -f "/home/tw/miniconda3/etc/profile.d/conda.sh" ]; then | |
| 23 | +CONDA_ROOT="${CONDA_ROOT:-/home/tw/miniconda3}" | |
| 24 | +if [ -f "$CONDA_ROOT/etc/profile.d/conda.sh" ]; then | |
| 24 | 25 | # shellcheck disable=SC1091 |
| 25 | - source /home/tw/miniconda3/etc/profile.d/conda.sh | |
| 26 | + source "$CONDA_ROOT/etc/profile.d/conda.sh" | |
| 26 | 27 | conda activate clip_service || { |
| 27 | 28 | echo "Failed to activate conda env 'clip_service'. Please create it first." >&2 |
| 28 | 29 | echo "See CLIP_SERVICE_README.md for setup instructions." >&2 |
| 29 | 30 | exit 1 |
| 30 | 31 | } |
| 31 | 32 | else |
| 32 | - echo "Warning: /home/tw/miniconda3/etc/profile.d/conda.sh not found." >&2 | |
| 33 | + echo "Warning: $CONDA_ROOT/etc/profile.d/conda.sh not found." >&2 | |
| 33 | 34 | echo "Please activate the 'clip_service' environment manually before running this script." >&2 |
| 34 | 35 | fi |
| 35 | 36 | ... | ... |
scripts/start_cnclip_service.sh
| ... | ... | @@ -45,8 +45,8 @@ DEFAULT_MODEL_NAME="CN-CLIP/ViT-H-14" |
| 45 | 45 | # DEFAULT_MODEL_NAME="CN-CLIP/ViT-L-14-336" |
| 46 | 46 | DEFAULT_REPLICAS=1 # 副本数 |
| 47 | 47 | |
| 48 | -# 项目路径 | |
| 49 | -PROJECT_ROOT="/data/tw/SearchEngine" | |
| 48 | +# 项目路径(以仓库实际路径为准,避免写死 /data/tw/...) | |
| 49 | +PROJECT_ROOT="$(cd "$(dirname "$0")/.." && pwd)" | |
| 50 | 50 | CLIP_SERVER_DIR="${PROJECT_ROOT}/third-party/clip-as-service/server" |
| 51 | 51 | LOG_DIR="${PROJECT_ROOT}/logs" |
| 52 | 52 | PID_FILE="${LOG_DIR}/cnclip_service.pid" |
| ... | ... | @@ -180,12 +180,13 @@ if [ -z "${CONDA_DEFAULT_ENV}" ] || [ "${CONDA_DEFAULT_ENV}" != "clip_service" ] |
| 180 | 180 | echo -e "${YELLOW}警告: 当前未激活 clip_service 环境${NC}" |
| 181 | 181 | echo -e "${YELLOW}正在激活环境...${NC}" |
| 182 | 182 | |
| 183 | - if [ -f "/home/tw/miniconda3/etc/profile.d/conda.sh" ]; then | |
| 184 | - source "/home/tw/miniconda3/etc/profile.d/conda.sh" | |
| 183 | + CONDA_ROOT="${CONDA_ROOT:-/home/tw/miniconda3}" | |
| 184 | + if [ -f "$CONDA_ROOT/etc/profile.d/conda.sh" ]; then | |
| 185 | + source "$CONDA_ROOT/etc/profile.d/conda.sh" | |
| 185 | 186 | conda activate clip_service |
| 186 | 187 | echo -e "${GREEN}✓ 环境已激活${NC}" |
| 187 | 188 | else |
| 188 | - echo -e "${RED}错误: 无法找到 conda 初始化脚本${NC}" | |
| 189 | + echo -e "${RED}错误: 无法找到 conda 初始化脚本: $CONDA_ROOT/etc/profile.d/conda.sh${NC}" | |
| 189 | 190 | exit 1 |
| 190 | 191 | fi |
| 191 | 192 | else | ... | ... |
scripts/start_embedding_service.sh
| ... | ... | @@ -13,8 +13,9 @@ set -e |
| 13 | 13 | cd "$(dirname "$0")/.." |
| 14 | 14 | |
| 15 | 15 | # Load conda env if available (keep consistent with other scripts) |
| 16 | -if [ -f "/home/tw/miniconda3/etc/profile.d/conda.sh" ]; then | |
| 17 | - source /home/tw/miniconda3/etc/profile.d/conda.sh | |
| 16 | +CONDA_ROOT="${CONDA_ROOT:-/home/tw/miniconda3}" | |
| 17 | +if [ -f "$CONDA_ROOT/etc/profile.d/conda.sh" ]; then | |
| 18 | + source "$CONDA_ROOT/etc/profile.d/conda.sh" | |
| 18 | 19 | conda activate searchengine |
| 19 | 20 | fi |
| 20 | 21 | ... | ... |
scripts/start_frontend.sh
scripts/start_indexer.sh
scripts/start_servers.py
| ... | ... | @@ -178,12 +178,12 @@ def main(): |
| 178 | 178 | """Main function to start all servers.""" |
| 179 | 179 | global manager |
| 180 | 180 | |
| 181 | - parser = argparse.ArgumentParser(description='Start SearchEngine servers (multi-tenant)') | |
| 181 | + parser = argparse.ArgumentParser(description='Start saas-search servers (multi-tenant)') | |
| 182 | 182 | parser.add_argument('--es-host', default='http://localhost:9200', help='Elasticsearch host') |
| 183 | 183 | parser.add_argument('--check-dependencies', action='store_true', help='Check dependencies before starting') |
| 184 | 184 | args = parser.parse_args() |
| 185 | 185 | |
| 186 | - logger.info("Starting SearchEngine servers (multi-tenant)...") | |
| 186 | + logger.info("Starting saas-search servers (multi-tenant)...") | |
| 187 | 187 | logger.info(f"Elasticsearch: {args.es_host}") |
| 188 | 188 | |
| 189 | 189 | # Check dependencies if requested | ... | ... |
scripts/stop_clip_service.sh
scripts/stop_cnclip_service.sh
scripts/tenant3__csv_to_shoplazza_xlsx.sh
setup.sh
| 1 | 1 | #!/bin/bash |
| 2 | 2 | |
| 3 | -source /home/tw/miniconda3/etc/profile.d/conda.sh | |
| 3 | +CONDA_ROOT="${CONDA_ROOT:-/home/tw/miniconda3}" | |
| 4 | +source "$CONDA_ROOT/etc/profile.d/conda.sh" | |
| 4 | 5 | |
| 5 | -# SearchEngine Setup and Startup Script | |
| 6 | +# saas-search Setup and Startup Script | |
| 6 | 7 | # This script sets up the environment and starts all services |
| 7 | 8 | |
| 8 | 9 | set -e # Exit on error |
| ... | ... | @@ -14,7 +15,7 @@ YELLOW='\033[1;33m' |
| 14 | 15 | NC='\033[0m' # No Color |
| 15 | 16 | |
| 16 | 17 | echo -e "${GREEN}========================================${NC}" |
| 17 | -echo -e "${GREEN}SearchEngine Setup Script${NC}" | |
| 18 | +echo -e "${GREEN}saas-search Setup Script${NC}" | |
| 18 | 19 | echo -e "${GREEN}========================================${NC}" |
| 19 | 20 | |
| 20 | 21 | # Change to project directory |
| ... | ... | @@ -28,9 +29,6 @@ if ! command -v conda &> /dev/null; then |
| 28 | 29 | exit 1 |
| 29 | 30 | fi |
| 30 | 31 | |
| 31 | -# Source conda | |
| 32 | -source /home/tw/miniconda3/etc/profile.d/conda.sh | |
| 33 | - | |
| 34 | 32 | # Check if environment exists |
| 35 | 33 | if conda env list | grep -q "searchengine"; then |
| 36 | 34 | echo -e "${GREEN}Environment 'searchengine' already exists${NC}" | ... | ... |
tests/__init__.py
third-party/xinference/activate.sh
third-party/xinference/test.sh