Blame view

config/config.yaml 6.34 KB
4d824a77   tangwang   所有租户共用一套统一配置.tena...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
  # Unified Configuration for Multi-Tenant Search Engine
  # 统一配置文件,所有租户共用一套索引配置
  # 注意:此配置不包含MySQL相关配置,只包含ES搜索相关配置
  
  # Elasticsearch Index
  es_index_name: "search_products"
  
  # ES Index Settings
  es_settings:
    number_of_shards: 1
    number_of_replicas: 0
    refresh_interval: "30s"
  
  # Field Definitions (SPU级别,只包含对搜索有帮助的字段)
  fields:
    # 租户隔离字段(必需)
    - name: "tenant_id"
      type: "KEYWORD"
      required: true
      index: true
      store: true
cd3799c6   tangwang   tenant2 1w测试数据 mo...
22
      return_in_source: true
4d824a77   tangwang   所有租户共用一套统一配置.tena...
23
24
  
    # 商品标识字段
cadc77b6   tangwang   索引字段名、变量名、API数据结构...
25
    - name: "spu_id"
4d824a77   tangwang   所有租户共用一套统一配置.tena...
26
27
28
29
      type: "KEYWORD"
      required: true
      index: true
      store: true
cd3799c6   tangwang   tenant2 1w测试数据 mo...
30
      return_in_source: true
4d824a77   tangwang   所有租户共用一套统一配置.tena...
31
32
33
34
35
  
    - name: "handle"
      type: "KEYWORD"
      index: true
      store: true
cd3799c6   tangwang   tenant2 1w测试数据 mo...
36
      return_in_source: true
4d824a77   tangwang   所有租户共用一套统一配置.tena...
37
38
39
40
41
42
43
44
  
    # 文本搜索字段
    - name: "title"
      type: "TEXT"
      analyzer: "chinese_ecommerce"
      boost: 3.0
      index: true
      store: true
cd3799c6   tangwang   tenant2 1w测试数据 mo...
45
      return_in_source: true
4d824a77   tangwang   所有租户共用一套统一配置.tena...
46
47
48
49
50
51
52
  
    - name: "brief"
      type: "TEXT"
      analyzer: "chinese_ecommerce"
      boost: 1.5
      index: true
      store: true
cd3799c6   tangwang   tenant2 1w测试数据 mo...
53
      return_in_source: true
4d824a77   tangwang   所有租户共用一套统一配置.tena...
54
55
56
57
58
59
60
  
    - name: "description"
      type: "TEXT"
      analyzer: "chinese_ecommerce"
      boost: 1.0
      index: true
      store: true
cd3799c6   tangwang   tenant2 1w测试数据 mo...
61
      return_in_source: true
4d824a77   tangwang   所有租户共用一套统一配置.tena...
62
63
64
65
66
67
68
69
  
    # SEO字段(提升相关性)
    - name: "seo_title"
      type: "TEXT"
      analyzer: "chinese_ecommerce"
      boost: 2.0
      index: true
      store: true
cd3799c6   tangwang   tenant2 1w测试数据 mo...
70
      return_in_source: false  # SEO字段通常不需要在结果中返回
4d824a77   tangwang   所有租户共用一套统一配置.tena...
71
72
73
74
75
76
77
  
    - name: "seo_description"
      type: "TEXT"
      analyzer: "chinese_ecommerce"
      boost: 1.5
      index: true
      store: true
cd3799c6   tangwang   tenant2 1w测试数据 mo...
78
      return_in_source: false
4d824a77   tangwang   所有租户共用一套统一配置.tena...
79
80
81
82
83
84
85
  
    - name: "seo_keywords"
      type: "TEXT"
      analyzer: "chinese_ecommerce"
      boost: 2.0
      index: true
      store: true
cd3799c6   tangwang   tenant2 1w测试数据 mo...
86
      return_in_source: false
4d824a77   tangwang   所有租户共用一套统一配置.tena...
87
88
89
  
    # 分类和标签字段(TEXT + KEYWORD双重索引)
    - name: "vendor"
cadc77b6   tangwang   索引字段名、变量名、API数据结构...
90
      type: "HKText"
4d824a77   tangwang   所有租户共用一套统一配置.tena...
91
92
93
94
      analyzer: "chinese_ecommerce"
      boost: 1.5
      index: true
      store: true
cd3799c6   tangwang   tenant2 1w测试数据 mo...
95
      return_in_source: true
4d824a77   tangwang   所有租户共用一套统一配置.tena...
96
  
4d824a77   tangwang   所有租户共用一套统一配置.tena...
97
    - name: "tags"
cadc77b6   tangwang   索引字段名、变量名、API数据结构...
98
      type: "HKText"
4d824a77   tangwang   所有租户共用一套统一配置.tena...
99
100
101
102
      analyzer: "chinese_ecommerce"
      boost: 1.0
      index: true
      store: true
cd3799c6   tangwang   tenant2 1w测试数据 mo...
103
      return_in_source: true
4d824a77   tangwang   所有租户共用一套统一配置.tena...
104
  
4d824a77   tangwang   所有租户共用一套统一配置.tena...
105
    - name: "category"
cadc77b6   tangwang   索引字段名、变量名、API数据结构...
106
      type: "HKText"
4d824a77   tangwang   所有租户共用一套统一配置.tena...
107
108
109
110
      analyzer: "chinese_ecommerce"
      boost: 1.5
      index: true
      store: true
cd3799c6   tangwang   tenant2 1w测试数据 mo...
111
      return_in_source: true
4d824a77   tangwang   所有租户共用一套统一配置.tena...
112
  
4d824a77   tangwang   所有租户共用一套统一配置.tena...
113
114
115
116
117
    # 价格字段(扁平化)
    - name: "min_price"
      type: "FLOAT"
      index: true
      store: true
cd3799c6   tangwang   tenant2 1w测试数据 mo...
118
      return_in_source: true
4d824a77   tangwang   所有租户共用一套统一配置.tena...
119
120
121
122
123
  
    - name: "max_price"
      type: "FLOAT"
      index: true
      store: true
cd3799c6   tangwang   tenant2 1w测试数据 mo...
124
      return_in_source: true
4d824a77   tangwang   所有租户共用一套统一配置.tena...
125
126
127
128
129
  
    - name: "compare_at_price"
      type: "FLOAT"
      index: true
      store: true
cd3799c6   tangwang   tenant2 1w测试数据 mo...
130
      return_in_source: true
4d824a77   tangwang   所有租户共用一套统一配置.tena...
131
132
133
134
135
136
  
    # 图片字段(用于显示,不参与搜索)
    - name: "image_url"
      type: "KEYWORD"
      index: false
      store: true
cd3799c6   tangwang   tenant2 1w测试数据 mo...
137
      return_in_source: true
4d824a77   tangwang   所有租户共用一套统一配置.tena...
138
  
325eec03   tangwang   1. 日志、配置基础设施,使用优化
139
    # 文本嵌入字段(用于语义搜索)
b73baf85   tangwang   撰写接口文档
140
    - name: "title_embedding"
325eec03   tangwang   1. 日志、配置基础设施,使用优化
141
142
143
144
145
      type: "TEXT_EMBEDDING"
      embedding_dims: 1024
      embedding_similarity: "dot_product"
      index: true
      store: false
cd3799c6   tangwang   tenant2 1w测试数据 mo...
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
      return_in_source: false  # 嵌入向量通常不需要在结果中返回
  
    # 时间字段
    - name: "create_time"
      type: "DATE"
      index: true
      store: true
      return_in_source: true
  
    - name: "update_time"
      type: "DATE"
      index: true
      store: true
      return_in_source: true
  
    - name: "shoplazza_created_at"
      type: "DATE"
      index: true
      store: true
      return_in_source: false  # 通常不需要返回
  
    - name: "shoplazza_updated_at"
      type: "DATE"
      index: true
      store: true
      return_in_source: false  # 通常不需要返回
325eec03   tangwang   1. 日志、配置基础设施,使用优化
172
  
cadc77b6   tangwang   索引字段名、变量名、API数据结构...
173
174
    # 嵌套skus字段
    - name: "skus"
4d824a77   tangwang   所有租户共用一套统一配置.tena...
175
176
      type: "JSON"
      nested: true
cd3799c6   tangwang   tenant2 1w测试数据 mo...
177
      return_in_source: true
4d824a77   tangwang   所有租户共用一套统一配置.tena...
178
      nested_properties:
cadc77b6   tangwang   索引字段名、变量名、API数据结构...
179
        sku_id:
4d824a77   tangwang   所有租户共用一套统一配置.tena...
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
          type: "keyword"
          index: true
          store: true
        title:
          type: "text"
          analyzer: "chinese_ecommerce"
          index: true
          store: true
        price:
          type: "float"
          index: true
          store: true
        compare_at_price:
          type: "float"
          index: true
          store: true
        sku:
          type: "keyword"
          index: true
          store: true
        stock:
          type: "long"
          index: true
          store: true
        options:
          type: "object"
          enabled: true
  
  # Index Structure (Query Domains)
  indexes:
    - name: "default"
      label: "默认索引"
      fields:
        - "title"
        - "brief"
        - "description"
        - "seo_title"
        - "seo_description"
        - "seo_keywords"
        - "vendor"
4d824a77   tangwang   所有租户共用一套统一配置.tena...
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
        - "tags"
        - "category"
      analyzer: "chinese_ecommerce"
      boost: 1.0
  
    - name: "title"
      label: "标题索引"
      fields:
        - "title"
        - "seo_title"
      analyzer: "chinese_ecommerce"
      boost: 2.0
  
    - name: "vendor"
      label: "品牌索引"
      fields:
        - "vendor"
      analyzer: "chinese_ecommerce"
      boost: 1.5
  
    - name: "category"
      label: "类目索引"
      fields:
        - "category"
      analyzer: "chinese_ecommerce"
      boost: 1.5
  
    - name: "tags"
      label: "标签索引"
      fields:
        - "tags"
        - "seo_keywords"
      analyzer: "chinese_ecommerce"
      boost: 1.0
  
  # Query Configuration
  query_config:
    supported_languages:
      - "zh"
      - "en"
    default_language: "zh"
    enable_translation: true
    enable_text_embedding: true
    enable_query_rewrite: true
  
325eec03   tangwang   1. 日志、配置基础设施,使用优化
265
    # Embedding field names (if not set, will auto-detect from fields)
b73baf85   tangwang   撰写接口文档
266
    text_embedding_field: "title_embedding"  # Field name for text embeddings
325eec03   tangwang   1. 日志、配置基础设施,使用优化
267
268
    image_embedding_field: null  # Field name for image embeddings (if not set, will auto-detect)
  
4d824a77   tangwang   所有租户共用一套统一配置.tena...
269
270
271
    # Translation API (DeepL)
    translation_service: "deepl"
    translation_api_key: null  # Set via environment variable
522a3964   tangwang   多语言搜索翻译的优化(deepL添...
272
273
    # translation_glossary_id: null  # Optional: DeepL glossary ID for custom terminology (e.g., "车" -> "car")
    # translation_context: "e-commerce product search"  # Context hint for better translation disambiguation
4d824a77   tangwang   所有租户共用一套统一配置.tena...
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
  
  # Ranking Configuration
  ranking:
    expression: "bm25() + 0.2*text_embedding_relevance()"
    description: "BM25 text relevance combined with semantic embedding similarity"
  
  # Function Score配置(ES层打分规则)
  function_score:
    score_mode: "sum"
    boost_mode: "multiply"
    
    functions: []
  
  # Rerank配置(本地重排,当前禁用)
  rerank:
    enabled: false
    expression: ""
    description: "Local reranking (disabled, use ES function_score instead)"
  
cadc77b6   tangwang   索引字段名、变量名、API数据结构...
293
  # SPU配置(已启用,使用嵌套skus)
4d824a77   tangwang   所有租户共用一套统一配置.tena...
294
295
  spu_config:
    enabled: true
cadc77b6   tangwang   索引字段名、变量名、API数据结构...
296
    spu_field: "spu_id"
4d824a77   tangwang   所有租户共用一套统一配置.tena...
297
    inner_hits_size: 10