Blame view

config/config.yaml 7.02 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
25
26
27
28
29
  
    # 商品标识字段
    - name: "product_id"
      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
90
91
92
93
94
  
    # 分类和标签字段(TEXT + KEYWORD双重索引)
    - name: "vendor"
      type: "TEXT"
      analyzer: "chinese_ecommerce"
      boost: 1.5
      index: true
      store: true
cd3799c6   tangwang   tenant2 1w测试数据 mo...
95
      return_in_source: true
4d824a77   tangwang   所有租户共用一套统一配置.tena...
96
97
98
99
100
  
    - name: "vendor_keyword"
      type: "KEYWORD"
      index: true
      store: false
cd3799c6   tangwang   tenant2 1w测试数据 mo...
101
      return_in_source: false  # keyword字段通常只用于过滤,不需要返回
4d824a77   tangwang   所有租户共用一套统一配置.tena...
102
103
104
105
106
107
108
  
    - name: "product_type"
      type: "TEXT"
      analyzer: "chinese_ecommerce"
      boost: 1.5
      index: true
      store: true
cd3799c6   tangwang   tenant2 1w测试数据 mo...
109
      return_in_source: true
4d824a77   tangwang   所有租户共用一套统一配置.tena...
110
111
112
113
114
  
    - name: "product_type_keyword"
      type: "KEYWORD"
      index: true
      store: false
cd3799c6   tangwang   tenant2 1w测试数据 mo...
115
      return_in_source: false
4d824a77   tangwang   所有租户共用一套统一配置.tena...
116
117
118
119
120
121
122
  
    - name: "tags"
      type: "TEXT"
      analyzer: "chinese_ecommerce"
      boost: 1.0
      index: true
      store: true
cd3799c6   tangwang   tenant2 1w测试数据 mo...
123
      return_in_source: true
4d824a77   tangwang   所有租户共用一套统一配置.tena...
124
125
126
127
128
  
    - name: "tags_keyword"
      type: "KEYWORD"
      index: true
      store: false
cd3799c6   tangwang   tenant2 1w测试数据 mo...
129
      return_in_source: false
4d824a77   tangwang   所有租户共用一套统一配置.tena...
130
131
132
133
134
135
136
  
    - name: "category"
      type: "TEXT"
      analyzer: "chinese_ecommerce"
      boost: 1.5
      index: true
      store: true
cd3799c6   tangwang   tenant2 1w测试数据 mo...
137
      return_in_source: true
4d824a77   tangwang   所有租户共用一套统一配置.tena...
138
139
140
141
142
  
    - name: "category_keyword"
      type: "KEYWORD"
      index: true
      store: false
cd3799c6   tangwang   tenant2 1w测试数据 mo...
143
      return_in_source: false
4d824a77   tangwang   所有租户共用一套统一配置.tena...
144
145
146
147
148
149
  
    # 价格字段(扁平化)
    - name: "min_price"
      type: "FLOAT"
      index: true
      store: true
cd3799c6   tangwang   tenant2 1w测试数据 mo...
150
      return_in_source: true
4d824a77   tangwang   所有租户共用一套统一配置.tena...
151
152
153
154
155
  
    - name: "max_price"
      type: "FLOAT"
      index: true
      store: true
cd3799c6   tangwang   tenant2 1w测试数据 mo...
156
      return_in_source: true
4d824a77   tangwang   所有租户共用一套统一配置.tena...
157
158
159
160
161
  
    - name: "compare_at_price"
      type: "FLOAT"
      index: true
      store: true
cd3799c6   tangwang   tenant2 1w测试数据 mo...
162
      return_in_source: true
4d824a77   tangwang   所有租户共用一套统一配置.tena...
163
164
165
166
167
168
  
    # 图片字段(用于显示,不参与搜索)
    - name: "image_url"
      type: "KEYWORD"
      index: false
      store: true
cd3799c6   tangwang   tenant2 1w测试数据 mo...
169
      return_in_source: true
4d824a77   tangwang   所有租户共用一套统一配置.tena...
170
  
325eec03   tangwang   1. 日志、配置基础设施,使用优化
171
    # 文本嵌入字段(用于语义搜索)
b73baf85   tangwang   撰写接口文档
172
    - name: "title_embedding"
325eec03   tangwang   1. 日志、配置基础设施,使用优化
173
174
175
176
177
      type: "TEXT_EMBEDDING"
      embedding_dims: 1024
      embedding_similarity: "dot_product"
      index: true
      store: false
cd3799c6   tangwang   tenant2 1w测试数据 mo...
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
      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. 日志、配置基础设施,使用优化
204
  
4d824a77   tangwang   所有租户共用一套统一配置.tena...
205
206
207
208
    # 嵌套variants字段
    - name: "variants"
      type: "JSON"
      nested: true
cd3799c6   tangwang   tenant2 1w测试数据 mo...
209
      return_in_source: true
4d824a77   tangwang   所有租户共用一套统一配置.tena...
210
211
212
213
214
215
216
217
218
219
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
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
      nested_properties:
        variant_id:
          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"
        - "product_type"
        - "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. 日志、配置基础设施,使用优化
298
    # Embedding field names (if not set, will auto-detect from fields)
b73baf85   tangwang   撰写接口文档
299
    text_embedding_field: "title_embedding"  # Field name for text embeddings
325eec03   tangwang   1. 日志、配置基础设施,使用优化
300
301
    image_embedding_field: null  # Field name for image embeddings (if not set, will auto-detect)
  
4d824a77   tangwang   所有租户共用一套统一配置.tena...
302
303
304
    # Translation API (DeepL)
    translation_service: "deepl"
    translation_api_key: null  # Set via environment variable
522a3964   tangwang   多语言搜索翻译的优化(deepL添...
305
306
    # 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...
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
  
  # 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)"
  
  # SPU配置(已启用,使用嵌套variants)
  spu_config:
    enabled: true
    spu_field: "product_id"
    inner_hits_size: 10