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