Commit 331ea682414c005ad959b52030821fcf80098527

Authored by tangwang
1 parent 38f530ff

文档完善

Showing 2 changed files with 46 additions and 64 deletions   Show diff stats
@@ -83,70 +83,6 @@ ES_HOST=http://localhost:9200 @@ -83,70 +83,6 @@ ES_HOST=http://localhost:9200
83 | `scripts/mock_data.sh` | 数据导入 | 将 Mock 数据或 CSV 数据导入 MySQL | 83 | `scripts/mock_data.sh` | 数据导入 | 将 Mock 数据或 CSV 数据导入 MySQL |
84 | `scripts/ingest.sh` | 数据索引 | 从 MySQL 导入数据到 Elasticsearch | 84 | `scripts/ingest.sh` | 数据索引 | 从 MySQL 导入数据到 Elasticsearch |
85 85
86 -#### 使用示例  
87 -  
88 -**1. 导入 Mock 数据到 MySQL(tenant_id=1)**  
89 -  
90 -```bash  
91 -# 生成并导入 100 个 Mock SPU(默认)  
92 -./scripts/mock_data.sh  
93 -  
94 -# 生成并导入指定数量的 SPU  
95 -./scripts/mock_data.sh 1 200  
96 -  
97 -# 使用显式参数  
98 -./scripts/mock_data.sh --mode mock --tenant-id 1 --num-spus 200  
99 -```  
100 -  
101 -**2. 导入 CSV 数据到 MySQL(tenant_id=2)**  
102 -  
103 -```bash  
104 -# 导入 customer1 的 CSV 数据  
105 -./scripts/mock_data.sh --mode csv \  
106 - --csv-file data/customer1/goods_with_pic.5years_congku.csv.shuf.1w \  
107 - --tenant-id 2 \  
108 - --start-spu-id 1  
109 -```  
110 -  
111 -**3. 从 MySQL 导入数据到 Elasticsearch**  
112 -  
113 -```bash  
114 -# 导入 tenant_id=1 的数据  
115 -./scripts/ingest.sh 1  
116 -  
117 -# 重建索引并导入数据  
118 -./scripts/ingest.sh 1 true  
119 -```  
120 -  
121 -**4. 启动服务**  
122 -  
123 -```bash  
124 -# 启动前端和后端  
125 -./run.sh  
126 -  
127 -# 重启所有服务  
128 -./restart.sh  
129 -```  
130 -  
131 -#### 完整工作流程示例  
132 -  
133 -```bash  
134 -# 1. 导入 Mock 数据(tenant_id=1)  
135 -./scripts/mock_data.sh 1 100  
136 -  
137 -# 2. 导入 CSV 数据(tenant_id=2)  
138 -./scripts/mock_data.sh --mode csv \  
139 - --csv-file data/customer1/goods_with_pic.5years_congku.csv.shuf.1w \  
140 - --tenant-id 2  
141 -  
142 -# 3. 将两个租户的数据导入 ES  
143 -./scripts/ingest.sh 1  
144 -./scripts/ingest.sh 2  
145 -  
146 -# 4. 启动服务  
147 -./run.sh  
148 -```  
149 -  
150 ### 3. 手动启动 API 服务(可选) 86 ### 3. 手动启动 API 服务(可选)
151 87
152 如果不想使用脚本,可以手动启动: 88 如果不想使用脚本,可以手动启动:
TEST_DATA_GUIDE.md
@@ -2,6 +2,52 @@ @@ -2,6 +2,52 @@
2 2
3 本文档说明如何构造测试数据,包括两种数据源的准备和导入流程。 3 本文档说明如何构造测试数据,包括两种数据源的准备和导入流程。
4 4
  5 +---
  6 +
  7 +## 快速开始
  8 +
  9 +### 1. 构造 Mock 数据(tenant_id=1 和 tenant_id=2)
  10 +
  11 +```bash
  12 +./scripts/mock_data.sh
  13 +```
  14 +
  15 +功能:自动生成 tenant_id=1 的Mock数据,并从CSV导入 tenant_id=2 的数据到MySQL
  16 +
  17 +---
  18 +
  19 +### 2. 从 MySQL → Elasticsearch
  20 +
  21 +```bash
  22 +# 导入 tenant_id=1 的数据(重建索引)
  23 +./scripts/ingest.sh 1 true
  24 +
  25 +# 导入 tenant_id=2 的数据(重建索引)
  26 +./scripts/ingest.sh 2 true
  27 +```
  28 +
  29 +
  30 +**用法**:`./scripts/ingest.sh <tenant_id> [recreate_index]`
  31 +- `tenant_id`: 租户ID(1 或 2)
  32 +- `recreate_index`: 是否重建索引(`true`/`false`,默认:`false`)
  33 +
  34 +---
  35 +
  36 +## 完整工作流程
  37 +
  38 +```bash
  39 +# 1. 构造并导入测试数据到MySQL
  40 +./scripts/mock_data.sh
  41 +
  42 +# 2. 导入 tenant_id=1 的数据到ES
  43 +./scripts/ingest.sh 1 true
  44 +
  45 +# 3. 导入 tenant_id=2 的数据到ES
  46 +./scripts/ingest.sh 2 true
  47 +```
  48 +
  49 +---
  50 +
5 ## 目录 51 ## 目录
6 52
7 1. [数据说明](#数据说明) 53 1. [数据说明](#数据说明)