Commit 648cb4c26be522956d4d692fcd59c8a99be7da3f

Authored by tangwang
1 parent 501066e1

ES docs

config/env_config.py
... ... @@ -22,6 +22,16 @@ ES_CONFIG = {
22 22 'password': os.getenv('ES_PASSWORD'),
23 23 }
24 24  
  25 +# Runtime environment & index namespace
  26 +# RUNTIME_ENV: 当前运行环境,建议使用 prod / uat / test / dev 等枚举值
  27 +RUNTIME_ENV = os.getenv('RUNTIME_ENV', 'prod')
  28 +# ES_INDEX_NAMESPACE: 用于按环境隔离索引的命名空间前缀,例如 "uat_" / "test_"
  29 +# 为空字符串时表示不加前缀(通常是 prod 环境)
  30 +ES_INDEX_NAMESPACE = os.getenv('ES_INDEX_NAMESPACE')
  31 +if ES_INDEX_NAMESPACE is None:
  32 + # 未显式配置时,非 prod 环境默认加 "<env>_" 前缀,prod 环境默认不加前缀
  33 + ES_INDEX_NAMESPACE = '' if RUNTIME_ENV == 'prod' else f'{RUNTIME_ENV}_'
  34 +
25 35 # Redis Configuration
26 36 REDIS_CONFIG = {
27 37 'host': os.getenv('REDIS_HOST', 'localhost'),
... ...
docs/ES/1_ES安装.md 0 → 100644
... ... @@ -0,0 +1,103 @@
  1 +
  2 +
  3 +
  4 +## 一、安装
  5 +### 1. 安装
  6 +```shell
  7 +# 参考install_elasticsearch.sh。
  8 +
  9 +ELASTICSEARCH_VERSION="8.18.0"
  10 +
  11 +wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo rpm --import
  12 +yum install -y https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-$ELASTICSEARCH_VERSION-x86_64.rpm
  13 +
  14 +# 设置Elasticsearch的系统服务
  15 +systemctl daemon-reload
  16 +systemctl start elasticsearch
  17 +systemctl enable elasticsearch
  18 +```
  19 +安装、配置好后验证命令: curl -X GET "http://localhost:9200"
  20 +
  21 +
  22 +### 3. 工程&安全方面设置
  23 +
  24 +性能相关配置:
  25 +```shell
  26 +vi /etc/elasticsearch/jvm.options
  27 +堆内存大小:
  28 +-Xms32g
  29 +-Xmx32g
  30 +```
  31 +
  32 +/etc/elasticsearch/elasticsearch.yml :
  33 +
  34 +Fielddata Cache(用于聚合和排序操作):
  35 +indices.fielddata.cache.size: 40% # 将 fielddata 缓存大小设置为 40% 的物理内存
  36 +Query Cache(用于查询缓存):
  37 +indices.queries.cache.size: 30% # 将查询缓存设置为 30% 的物理内存
  38 +
  39 +修改的系统配置:
  40 +vi /etc/sysctl.conf
  41 +```shell
  42 +# tangwang
  43 +# 调整系统句柄限制
  44 +fs.file-max = 1000000
  45 +# 优化文件描述符 可以分配的vma数量
  46 +vm.max_map_count = 655360
  47 +# 优化脏内存页,es写入削峰
  48 +vm.dirty_ratio=10
  49 +vm.dirty_background_ratio=5
  50 +vm.dirty_writeback_centisecs=200
  51 +# 优化系统回收inode cache权重
  52 +vm.vfs_cache_pressure=200
  53 +vm.dirty_expire_centisecs=6000
  54 +# 尽可能低的使用swap,内存很充裕可以设置为0,较低设置为1
  55 +vm.swappiness=0
  56 +```
  57 +vi /etc/security/limits.conf
  58 +```shell
  59 +# tangwang 修改 下面都加了10倍
  60 +# End of file
  61 +* soft nofile 655350
  62 +* hard nofile 655350
  63 +root soft nofile 655350
  64 +root hard nofile 655350
  65 +* soft nofile 655350
  66 +* hard nofile 655350
  67 +
  68 +
  69 +# tangwang 补充下面的
  70 +* soft nproc 102400
  71 +* hard nproc 409600
  72 +# 允许进程锁定内存
  73 +* soft memlock unlimited
  74 +* hard memlock unlimited
  75 +```
  76 +
  77 +
  78 +### TOOD :
  79 +配置为单节点模式,discovery.type: single-node 但是还需要其他配套改动。
  80 +
  81 +用户名 密码 安全方面
  82 +kibana用户名密码
  83 +
  84 +## 其他说明
  85 +ES 8.x版本特性
  86 +在 8.0版本 中,提供新的kNN 搜索 API。以前,Elasticsearch 仅支持使用script_score带有向量函数的查询进行精确的 kNN 搜索。虽然此方法可以保证准确的结果,但它通常会导致搜索速度缓慢,并且无法很好地适应大型数据集。作为索引速度较慢和准确性不完美的代价,新的 kNN 搜索 API 允许您以更快的速度对更大的数据集运行近似 kNN 搜索。
  87 +
  88 +在 8.4版本中,把knn搜索加入到search API中,以支持 ANN 搜索。它由与旧 _knn_search端点相同的 Lucene ANN 功能提供支持。该knn选项可以与其他搜索功能(例如查询和聚合)结合使用。
  89 +
  90 +在 8.7版本中,允许多个 KNN 搜索子句。某些向量搜索场景需要使用几个 kNN 子句进行相关性排名,例如,当基于多个字段进行排名时,每个字段都有自己的向量,或者当文档包含图像向量和文本向量时。用户可能希望获得基于所有这些 kNN 子句的组合的相关性排名。
  91 +
  92 +在 8.8版本 中,将 Introducing Elastic Learned Sparse Encoder: Elastic’s AI model for semantic search — Elastic Search Labs 模型引入到我们的机器学习模型库中,您可以开箱即用。ELSER 通过启用语义搜索来提高搜索结果的相关性。这种搜索方法考虑单词的含义,而不是仅仅依赖字面术语。ELSER 是一种预训练的域外稀疏向量模型,无需对特定源数据进行微调。它从一开始就为您提供相关的搜索结果。并且在此版本中,还提升了KNN检索语法,加入了similarity参数,允许过滤给定相似性之外的最近邻结果。
  93 +
  94 +在8.9版本中。text_embedding query_vector_builderkNN 搜索的扩展普遍可用。
  95 +
  96 +在8.10版本中,启用跨段并行 knn 搜索,使得 knn 查询对由多个段组成的分片更快,来优化knn搜索的性能。
  97 +
  98 +
  99 +
  100 +
  101 +
  102 +8.15 更为丰富的工具用于微调相关性、更高的模型灵活性、矢量搜索的改进
  103 +
... ...
docs/ES/1_ES配置和使用.md 0 → 100644
... ... @@ -0,0 +1,680 @@
  1 +# Elasticsearch 文档
  2 +
  3 +## 相关链接
  4 +- 接口文档:http://rap.essa.top:88/workspace/myWorkspace.do?projectId=78#2187
  5 +- Kibana 控制台:http://120.76.41.98:5601/app/dev_tools#/console/shell
  6 +
  7 +## 分词方面
  8 +
  9 +Ansj 分词插件安装
  10 +ES可以用的中文分词,效果最好的是hanLP和ansj,其次是jieba。
  11 +
  12 +我们老的搜索 solr 已经在几年前替代掉了ik,使用的是mmseg。但是我没找到mmseg的ES插件。
  13 +
  14 +为了分词方面不至于比老版本差,这里先安装了ansj
  15 +
  16 +### 1. 下载插件
  17 +从 [elasticsearch-analysis-ansj releases](https://github.com/NLPchina/elasticsearch-analysis-ansj/releases) 选择对应版本下载:
  18 +
  19 +- ES 8.18 版本:
  20 +```bash
  21 +wget https://github.com/NLPchina/elasticsearch-analysis-ansj/archive/refs/tags/v8.18.0.zip
  22 +```
  23 +
  24 +- ES 8.17 版本:
  25 +```bash
  26 +wget https://github.com/NLPchina/elasticsearch-analysis-ansj/archive/refs/tags/v8.17.6.zip
  27 +```
  28 +
  29 +### 2. 编译
  30 +执行 `mvn package` 命令,编译成功后将在 `target/releases/` 目录生成插件压缩包:
  31 +`elasticsearch-analysis-ansj-<版本号>-release.zip`
  32 +
  33 +### 3. 安装步骤
  34 +1. 进入 ES 安装路径(默认:`/usr/share/elasticsearch/`)
  35 +2. 执行安装命令:
  36 +```bash
  37 +bin/elasticsearch-plugin install file:///xxx/绝对路径到/elasticsearch-analysis-ansj-8.18.0.0-release.zip
  38 +```
  39 +3. 重启服务:
  40 +```bash
  41 +systemctl restart elasticsearch
  42 +```
  43 +
  44 +其他分词插件安装方法:
  45 +《3.1_hanlp安装.md》
  46 +《3.2_jieba插件安装.md》
  47 +在ES8上面安装过,但是没试过具体的版本 8.17 8.18
  48 +
  49 +### 4. 配置说明
  50 +停用词、同义词配置位于 `<ES_HOME>/config/elasticsearch-analysis-ansj/ansj.cfg.yml`(暂未使用)
  51 +
  52 +## 字段说明
  53 +
  54 +```bash
  55 +需要的字段:
  56 +id 商品skuId
  57 +goods_id 商品spuId
  58 +buyer_id 所属专属采购商id
  59 +trader_buyer_ids 所属贸易商名下平台客户的专属采购商id
  60 +goods_certification_types 商品证书类型
  61 +supplier_code 供应商编码
  62 +supplier_name 供应商名称
  63 +supplier_certification_code 供应商企业证书编码(列表)
  64 +auth_buyer_level_list 商品可见采购商等级(集合)
  65 +show_price_level_list 价格可见采购商等级(集合)
  66 +goods_composition 成分列表(材质)
  67 +compositions_main_secondary 物料主副(主:1,副:2),格式:物料代码_主副类型
  68 +goods_key_word_zh 商品关键词中文
  69 +goods_key_word_en 商品关键词英文
  70 +goods_key_word_ru 商品关键词俄文
  71 +goods_copyright 版权(自有、第三方、无授权、A货)
  72 +goods_main_material 主材质(字典:材质)
  73 +is_in_new_protect 是否在新品保护期(0否,1是)
  74 +goods_new_protect_date_stamp 新品保护期日期时间戳
  75 +goods_attribute_name_zh spu属性中文(列表)
  76 +goods_attribute_name_en spu属性英文(列表)
  77 +goods_attribute_name_ru spu属性俄文(列表)
  78 +purchase_moq 采购MOQ
  79 +ts 触发索引的时间
  80 +deliver_day 货期
  81 +factory_no 工厂货号
  82 +factory_no_buyer 工厂货号(客户)
  83 +fir_on_sell_time 首次上架时间
  84 +fir_on_sell_time_stamp 首次上架时间timestamp
  85 +no 商品编码
  86 +hs_no 宏升编码
  87 +package_type 包装类型值(来自商品属性编码:PKG)
  88 +package_type_id 包装类型ID(来自商品属性编码:PKG)
  89 +labelId_by_skuId_essaone_* essaone商品标签,国家编码标识
  90 +sale_goods_certificate_* 商品证书ID,国家编码标识
  91 +labelId_by_skuId_essa_* essa商品标签,区域ID标识
  92 +```
  93 +
  94 +## Mapping 配置
  95 +参考文件 `create_index.sh`:
  96 +
  97 +## 快速入门
  98 +
  99 +### Shell
  100 +参考 [索引和查询测试](../docs/3.3_索引和查询测试.md) 包含了在ES服务器进行本地进行一些常用的查询操作。
  101 +
  102 +### Python
  103 +- [test_index_and_search.py](../tests/test_index_and_search.py) 是一个简单的例子,创建索引,导入数据,查询数据
  104 +- [batch_bulk_goods.py](../batch_bulk_goods.py) 功能是 通过sql 读取最近3年的所有数据,按batch(1000)通过bulk接口进行逐批入库,入库到goods索引。
  105 +
  106 +### Kibana
  107 +
  108 +#### 分词相关
  109 +```bash
  110 +# 索引分词
  111 +GET /_cat/ansj?text=14寸第4代真眼珠实身冰雪公仔带手动大推车,搪胶雪宝宝&type=index_ansj
  112 +
  113 +# 查询分词
  114 +GET /_cat/ansj?text=14寸第4代真眼珠实身冰雪公仔带手动大推车,搪胶雪宝宝&type=query_ansj
  115 +
  116 +# 查看配置
  117 +GET /_cat/ansj/config
  118 +```
  119 +#### 查询相关
  120 +GET /goods/_search
  121 +{
  122 + "query": {
  123 + "match_all": {}
  124 + },
  125 + "size": 5
  126 +}
  127 +
  128 +#### 1. 查看字段分词结果
  129 +```bash
  130 +# 查看中文名称分词结果
  131 +GET /_cat/ansj?text=14寸第4代真眼珠实身冰雪公仔带手动大推车&type=index_ansj
  132 +
  133 +# 查看英文名称分词结果
  134 +GET /_cat/ansj?text=14 inch 4th generation real eye snow doll with manual cart&type=standard
  135 +```
  136 +
  137 +#### 2. 查看索引随机10条内容
  138 +```bash
  139 +GET /goods/_search
  140 +{
  141 + "size": 10,
  142 + "query": {
  143 + "function_score": {
  144 + "query": { "match_all": {} },
  145 + "random_score": {}
  146 + }
  147 + }
  148 +}
  149 +```
  150 +
  151 +#### 3. 关键词查询
  152 +```bash
  153 +# 简单关键词匹配
  154 +GET /goods/_search
  155 +{
  156 + "query": {
  157 + "match": {
  158 + "name_zh": "冰雪公仔"
  159 + }
  160 + }
  161 +}
  162 +
  163 +# 多字段关键词匹配
  164 +GET /goods/_search
  165 +{
  166 + "query": {
  167 + "multi_match": {
  168 + "query": "冰雪公仔",
  169 + "fields": ["name_zh", "sub_name_zh", "category_name_zh"]
  170 + }
  171 + }
  172 +}
  173 +```
  174 +
  175 +#### 4. 向量查询
  176 +```bash
  177 +# 使用向量相似度查询
  178 +GET /goods/_search
  179 +{
  180 + "query": {
  181 + "script_score": {
  182 + "query": { "match_all": {} },
  183 + "script": {
  184 + "source": "cosineSimilarity(params.query_vector, 'name_prefix') + 1.0",
  185 + "params": {
  186 + "query_vector": [0.1, 0.2, ...] # 1024维向量
  187 + }
  188 + }
  189 + }
  190 + }
  191 +}
  192 +```
  193 +
  194 +#### 5. SKUID查询
  195 +```bash
  196 +# 精确匹配SKUID
  197 +GET /goods/_search
  198 +{
  199 + "query": {
  200 + "term": {
  201 + "goods_id": "2817667"
  202 + }
  203 + }
  204 +}
  205 +```
  206 +
  207 +#### 6. 名称查询测试
  208 +```bash
  209 +# 中文名称模糊匹配
  210 +GET /goods/_search
  211 +{
  212 + "query": {
  213 + "match": {
  214 + "name_zh": {
  215 + "query": "冰雪公仔",
  216 + "fuzziness": "AUTO"
  217 + }
  218 + }
  219 + }
  220 +}
  221 +
  222 +# 英文名称匹配
  223 +GET /goods/_search
  224 +{
  225 + "query": {
  226 + "match": {
  227 + "name_en": "snow doll"
  228 + }
  229 + }
  230 +}
  231 +
  232 +# 俄语名称匹配
  233 +GET /goods/_search
  234 +{
  235 + "query": {
  236 + "match": {
  237 + "name_ru": "снежная кукла"
  238 + }
  239 + }
  240 +}
  241 +
  242 +# 使用 match_phrase 进行短语匹配
  243 +GET /goods/_search
  244 +{
  245 + "query": {
  246 + "match_phrase": {
  247 + "name_zh": "冰雪公仔"
  248 + }
  249 + }
  250 +}
  251 +
  252 +# 使用 match_phrase 进行多语言短语匹配
  253 +GET /goods/_search
  254 +{
  255 + "query": {
  256 + "bool": {
  257 + "should": [
  258 + {
  259 + "match_phrase": {
  260 + "name_zh": "冰雪公仔"
  261 + }
  262 + },
  263 + {
  264 + "match_phrase": {
  265 + "name_en": "snow doll"
  266 + }
  267 + },
  268 + {
  269 + "match_phrase": {
  270 + "name_ru": "снежная кукла"
  271 + }
  272 + }
  273 + ],
  274 + "minimum_should_match": 1
  275 + }
  276 + }
  277 +}
  278 +
  279 +# 使用 match_phrase 配合 slop 参数进行模糊短语匹配
  280 +GET /goods/_search
  281 +{
  282 + "query": {
  283 + "match_phrase": {
  284 + "name_zh": {
  285 + "query": "冰雪公仔",
  286 + "slop": 2
  287 + }
  288 + }
  289 + }
  290 +}
  291 +
  292 +# 多语言 match_phrase 配合 slop 参数
  293 +GET /goods/_search
  294 +{
  295 + "query": {
  296 + "bool": {
  297 + "should": [
  298 + {
  299 + "match_phrase": {
  300 + "name_zh": {
  301 + "query": "冰雪公仔",
  302 + "slop": 2
  303 + }
  304 + }
  305 + },
  306 + {
  307 + "match_phrase": {
  308 + "name_en": {
  309 + "query": "snow doll",
  310 + "slop": 1
  311 + }
  312 + }
  313 + },
  314 + {
  315 + "match_phrase": {
  316 + "name_ru": {
  317 + "query": "снежная кукла",
  318 + "slop": 2
  319 + }
  320 + }
  321 + }
  322 + ],
  323 + "minimum_should_match": 1
  324 + }
  325 + }
  326 +}
  327 +```
  328 +
  329 +#### 7. 多语言查询测试
  330 +```bash
  331 +# 同时查询中英文名称
  332 +GET /goods/_search
  333 +{
  334 + "query": {
  335 + "bool": {
  336 + "should": [
  337 + {
  338 + "match": {
  339 + "name_zh": "冰雪公仔"
  340 + }
  341 + },
  342 + {
  343 + "match": {
  344 + "name_en": "snow doll"
  345 + }
  346 + }
  347 + ],
  348 + "minimum_should_match": 1
  349 + }
  350 + }
  351 +}
  352 +```
  353 +
  354 +#### 8. 向量索引查询测试
  355 +注意:向量查询中的向量维度必须与索引中定义的维度匹配(1024维)
  356 +```bash
  357 +# 使用向量相似度进行商品推荐
  358 +GET /goods/_search
  359 +{
  360 + "query": {
  361 + "script_score": {
  362 + "query": { "match_all": {} },
  363 + "script": {
  364 + "source": "cosineSimilarity(params.query_vector, 'ru_name') + 1.0",
  365 + "params": {
  366 + "query_vector": [0.1, 0.2, ...] # 1024维向量
  367 + }
  368 + }
  369 + }
  370 + },
  371 + "size": 10
  372 +}
  373 +```
  374 +
  375 +#### 9. 关键词+向量索引组合查询测试
  376 +```bash
  377 +# 关键词搜索+向量相似度提权
  378 +GET /goods/_search
  379 +{
  380 + "query": {
  381 + "function_score": {
  382 + "query": {
  383 + "match": {
  384 + "name_zh": "冰雪公仔",
  385 + "boost": 1.0
  386 + }
  387 + },
  388 + "functions": [
  389 + {
  390 + "script_score": {
  391 + "script": {
  392 + "source": "cosineSimilarity(params.query_vector, 'name_prefix') + 1.0",
  393 + "params": {
  394 + "query_vector": [0.1, 0.2, ...] # 1024维向量
  395 + }
  396 + }
  397 + }
  398 + }
  399 + ],
  400 + "boost_mode": "multiply"
  401 + }
  402 + }
  403 +}
  404 +
  405 +# source 可以支持embedding为空 : "source": "doc['embedding'].isEmpty() ? 1.0 : dotProduct(params.query_vector, 'embedding') + 1.0",
  406 +
  407 +两者乘起来:
  408 +{
  409 + "query": {
  410 + "function_score": {
  411 + "score_mode": "sum",
  412 + "boost_mode": "multiply",
  413 + "query": {
  414 + "match": {
  415 + "content": {
  416 + "query": keywords,
  417 + "boost": 1.0
  418 + }
  419 + }
  420 + },
  421 + "functions": [
  422 + {
  423 + "script_score": {
  424 + "script": {
  425 + "source": "doc['embedding'].isEmpty() ? 1.0 : dotProduct(params.query_vector, 'embedding') + 1.0",
  426 + "params": {"query_vector": context.embeddings[0][1]}
  427 + }
  428 + }
  429 + }
  430 + ]
  431 + }
  432 + }
  433 + }
  434 +
  435 +#### 9. 向量搜索+关键词搜索
  436 +GET /goods/_search
  437 +{
  438 + "query": {
  439 + "match": {
  440 + "content": {
  441 + "query": "玩具",
  442 + "boost": 1.0
  443 + }
  444 + }
  445 + },
  446 + "knn": {
  447 + "field": "name_prefix",
  448 + "query_vector": [-0.05291186273097992, ...],
  449 + "k": 5,
  450 + "num_candidates": 10,
  451 + "boost": 1.0
  452 + }
  453 + }
  454 +
  455 +
  456 +
  457 +
  458 +参考代码:
  459 +```python
  460 + def execute_search(self, context, search_type="match_phrase", search_type_attachment=0, size=10):
  461 + query = context.query
  462 + normalized_query = context.normalized_query
  463 + core_term = context.core_term
  464 + keywords = context.keywords
  465 + knn_boost_keywords = core_term if core_term else keywords
  466 + expand = context.expand
  467 +
  468 + seen_queries = set()
  469 + unique_queries = []
  470 + for q, weight in [(query, 1.0), (normalized_query, 1.0), (keywords, 0.5)]:
  471 + if q and q not in seen_queries:
  472 + unique_queries.append((q, weight))
  473 + seen_queries.add(q)
  474 +
  475 + # 关于混合检索:
  476 + # knn和文本查询同时作用:
  477 + # 8.12之前query里面不能包含knn,kNN搜索作为查询已在 8.12 版本中引入: https://www.elastic.co/search-labs/blog/knn-query-elasticsearch
  478 + # {
  479 + # "size": 3,
  480 + # "query": {
  481 + # "bool": {
  482 + # "should": [
  483 + # {
  484 + # "knn": {
  485 + # "field": "embedding",
  486 + # "query_vector": [2,2,2,0],
  487 + # "num_candidates": 10,
  488 + # "_name": "knn_query"
  489 + # }
  490 + # },
  491 + # {
  492 + # "match": {
  493 + # "description": {
  494 + # "query": "luxury",
  495 + # "_name": "bm25query"
  496 + # }
  497 + # }
  498 + # }
  499 + # ]
  500 + # }
  501 + #
  502 + # knn里面不能包含query。
  503 + # knn和query并列(hybrid search 混合检索),是求或的关系。
  504 + # knn里面可以加filter,比如: "filter": {"match": {"my_label": "red"}}
  505 +
  506 + if search_type == "match_phrase":
  507 + body = {
  508 + "query": {
  509 + "bool": {
  510 + "should": [
  511 + {
  512 + "match_phrase": {
  513 + "content": {
  514 + "query": unique_query,
  515 + "boost": weight,
  516 + "slop": search_type_attachment
  517 + }
  518 + }
  519 + } for unique_query, weight in unique_queries
  520 + ],
  521 + "minimum_should_match": 1
  522 + }
  523 + }
  524 + }
  525 + # 纯关键词检索 2
  526 + elif search_type == "match_keywords":
  527 + body = {
  528 + "query": {
  529 + "bool": {
  530 + "must": [
  531 + {
  532 + "match": {
  533 + "content": {"query": core_term, "boost": 1.0}
  534 + }
  535 + }
  536 + ],
  537 + "should": [
  538 + {
  539 + "match": {
  540 + "content": {"query": q, "boost": boost}
  541 + }
  542 + } for (q, boost) in [(keywords, 1.0), (expand, 0.6), (normalized_query, 1.0)] if q
  543 + ],
  544 + "minimum_should_match": 1
  545 + }
  546 + }
  547 + }
  548 + # 关键词搜索+向量排序
  549 + elif search_type == "match&boost":
  550 + body = {
  551 + "query": {
  552 + "function_score": {
  553 + "score_mode": "sum",
  554 + "boost_mode": "multiply",
  555 + "query": {
  556 + "match": {
  557 + "content": {
  558 + "query": keywords,
  559 + "boost": 1.0
  560 + }
  561 + }
  562 + },
  563 + "functions": [
  564 + {
  565 + "script_score": {
  566 + "script": {
  567 + "source": "doc['embedding'].isEmpty() ? 1.0 : dotProduct(params.query_vector, 'embedding') + 1.0",
  568 + "params": {"query_vector": context.embeddings[0][1]}
  569 + }
  570 + }
  571 + }
  572 + ]
  573 + }
  574 + }
  575 + }
  576 + # 这个太慢
  577 + elif search_type == "match&boost2":
  578 + body = {
  579 + "query": {
  580 + "script_score": {
  581 + "query": {
  582 + "match": {
  583 + "content": {
  584 + "query": keywords,
  585 + "boost": 1.0
  586 + }
  587 + }
  588 + },
  589 + "script": {
  590 + "source": "doc['embedding'].isEmpty() ? 1.0 : dotProduct(params.query_vector, 'embedding') + 1.0",
  591 + "params": {"query_vector": context.embeddings[0][1]}
  592 + }
  593 + }
  594 + }
  595 + }
  596 + # 向量搜索+关键词搜索
  597 + elif search_type == "match&knn":
  598 + body = {
  599 + "query": {
  600 + "match": {
  601 + "content": {
  602 + "query": knn_boost_keywords,
  603 + "boost": 1.0
  604 + }
  605 + }
  606 + },
  607 + "knn": {
  608 + "field": "embedding",
  609 + "query_vector": context.embeddings[search_type_attachment][1],
  610 + "k": 5,
  611 + "num_candidates": 10,
  612 + "boost": 1.0
  613 + }
  614 + }
  615 + # 纯向量搜索
  616 + elif search_type == "knn":
  617 + body = {
  618 + "knn": {
  619 + "field": "embedding",
  620 + "query_vector": context.embeddings[search_type_attachment][1],
  621 + "k": 5,
  622 + "num_candidates": 10
  623 + }
  624 + }
  625 +
  626 + need_embedding = (search_type == "match&boost")
  627 + need_highlights = (search_type != "knn")
  628 +
  629 + body["_source"] = {"excludes": ["keywords", "quotes"]}
  630 + if not need_embedding:
  631 + body["_source"]["excludes"].append("embedding")
  632 + # 在填充highlight之前写入search_from
  633 + search_from = f'searchtype[{search_type}],param[{search_type_attachment}],body:{body}'
  634 +
  635 + if need_highlights:
  636 + body["_source"]["excludes"] = []
  637 + body["highlight"] = {
  638 + "pre_tags": [settings.HIGHTLIGHT_PRE_TAG],
  639 + "post_tags": [settings.HIGHTLIGHT_POST_TAG],
  640 + "fields": {"chapter_name": {}, "content": {}}
  641 + }
  642 +
  643 + body["size"] = size
  644 +
  645 + se_debug_info = ''
  646 + start_time = time.time()
  647 + try:
  648 + es_response = context.es.search(index=context.index_name, body=body)
  649 + except Exception as e:
  650 + se_debug_info = f'Error in executing search: {e}. request: {body}'
  651 + return None, se_debug_info
  652 + end_time = time.time()
  653 + elapsed_time = end_time - start_time
  654 + total_hits = es_response.get("hits", {}).get("total", {}).get("value", 0)
  655 + returned_hits = len(es_response.get("hits", {}).get("hits", []))
  656 +
  657 + if not '"' in search_from:
  658 + search_from = search_from.replace('\'', '"')
  659 + search_from = search_from if len(search_from) < 400 else search_from[:400] + '...'
  660 +
  661 + str_body = str(body)
  662 + if not '"' in str_body:
  663 + str_body = str_body.replace('\'', '"')
  664 + se_debug_info = f'({elapsed_time:.2f} seconds. Total: {total_hits}. Returned: {returned_hits}) : {search_from[:400]}'
  665 +
  666 + if not 'hits' in es_response or not 'hits' in es_response['hits']:
  667 + se_debug_info += f' InvalidResponce in executing search: {e}. request: {body}'
  668 + return None, se_debug_info
  669 +
  670 + for hit in es_response['hits']['hits']:
  671 + hit['search_from'] = search_from
  672 +
  673 + return es_response, se_debug_info
  674 +
  675 +```
  676 +
  677 +
  678 +# 测试向量:
  679 +# [-0.05291186273097992, 0.0274342093616724, -0.016730275005102158, 0.010487289167940617, -0.022640341892838478, -0.048682719469070435, 0.04544096067547798, 0.023079438135027885, 0.007221410982310772, 0.023566091433167458, 0.026696473360061646, 0.08252757787704468, -0.042835772037506104, 0.0009668126585893333, -0.02860398218035698, -0.004426108207553625, -0.002644421299919486, -0.027699561789631844, 0.005749804899096489, -0.04468372091650963, -0.0296687763184309, -0.009487600065767765, 0.020041221752762794, 0.00778265530243516, 0.008522099815309048, 0.03497027978301048, -0.021573258563876152, -0.028293319046497345, -8.54598984005861e-05, -0.03164539486169815, -0.017121458426117897, -0.0006902766763232648, 0.04650883004069328, -0.030234992504119873, -0.010207684710621834, -0.035288386046886444, -0.0047269039787352085, -0.0006454040994867682, -0.056146346032619476, 0.008901881985366344, 0.010757357813417912, -0.013022932223975658, 0.04627145081758499, -0.020669423043727875, -0.02031278982758522, -0.052186835557222366, -0.0148158585652709, -0.018267231062054634, -0.059003304690122604, -0.011793344281613827, 0.027096575126051903, 0.019299808889627457, 0.04161312058568001, -0.019393721595406532, -0.02361445501446724, 0.07711422443389893, -0.02068573422729969, -0.004702702630311251, -0.011135494336485863, 0.0101374052464962, -0.020808257162570953, 0.011924360878765583, -0.020093027502298355, -0.007138500455766916, 0.014727798290550709, 0.05770261213183403, 0.017841406166553497, 0.044339124113321304, -0.01490224339067936, -0.008343652822077274, -0.04842463508248329, 0.0336640290915966, -0.004893577191978693, -0.021536342799663544, -0.032384153455495834, -0.009452177211642265, -0.027460120618343353, -0.009426826611161232, 0.006357531528919935, 0.019494572654366493, 0.009722599759697914, -0.00497430982068181, 0.023032115772366524, 0.05221958085894585, -0.01671120524406433, 0.061740316450595856, -0.06789620220661163, -0.023851843550801277, -0.02249223366379738, -0.01231105625629425, -0.0499565526843071, 0.004251780919730663, 0.05466651916503906, -0.024449756368994713, -0.034151963889598846, 0.037387508898973465, -0.0016276679234579206, -0.02609393745660782, 0.01800747588276863, -0.0028136332985013723, -0.06036405637860298, 0.028903907164931297, 0.006318055558949709, 0.012870929203927517, -0.0021476889960467815, -0.012034566141664982, -0.008372323587536812, 0.024942906573414803, 0.08258169889450073, 0.006757829803973436, 0.032017264515161514, -0.012414710596203804, 0.014826267957687378, -0.040858786553144455, -0.0060302577912807465, 0.00843990221619606, -0.031066348776221275, -0.06313654035329819, 0.0056659989058971405, -0.007768781390041113, 0.011673268862068653, 0.007261875085532665, 0.006112886127084494, -0.07374890148639679, 0.06602894514799118, -0.05385972931981087, -0.0010994652984663844, 0.05939924344420433, 0.015503636561334133, 0.034621711820364, 0.008040975779294968, -0.023962488397955894, -0.06270411610603333, 0.00027893096557818353, -0.0436306893825531, -0.006309020332992077, 0.02416943572461605, -0.015391307882964611, -0.012442439794540405, -0.003181715961545706, -0.0021985983476042747, 0.008671553805470467, 0.004063367377966642, -0.02560708485543728, 0.03469422832131386, -0.04249674826860428, -0.013552767224609852, -0.052823010832071304, 0.014670411124825478, -0.011493593454360962, 0.024076055735349655, 0.056352417916059494, -0.008510314859449863, 0.015936613082885742, 0.003935575485229492, 0.0037949192337691784, 0.015074086375534534, 0.016583971679210663, -0.0057802870869636536, 0.005751866847276688, -0.009386995807290077, -0.03710195794701576, -0.03144300729036331, -0.07106415182352066, -0.003882911056280136, -0.010697683319449425, -0.014338435605168343, 0.007036983501166105, -0.035716522485017776, 0.06593189388513565, 0.007752529811114073, -0.030261363834142685, -0.02513342909514904, -0.039278656244277954, 0.015320679172873497, -0.012659071013331413, 0.014207725413143635, 0.010264124721288681, 0.01617652177810669, -0.022644126787781715, -0.031033707782626152, 0.04160666465759277, -0.05329348146915436, 0.02423500455915928, -0.019389694556593895, 0.008645910769701004, -0.005958682857453823, -0.03648180514574051, 0.011972597800195217, 0.037404924631118774, -0.007001751102507114, -0.05138246342539787, 0.0013400549069046974, -0.03268183395266533, 0.07687076926231384, -0.02033335529267788, -0.020667986944317818, 0.0038236891850829124, 0.029960744082927704, 0.015430699102580547, 0.05047214776277542, 0.0052254535257816315, 0.013995353132486343, -0.031164521351456642, -0.014291719533503056, 0.015829795971512794, -0.0013409113744273782, -0.044300951063632965, 0.045415859669446945, -0.005037966184318066, -0.03883415088057518, 0.027200160548090935, 0.008182630874216557, -0.046456750482320786, -0.029778052121400833, 0.02067168429493904, -0.006381513085216284, -0.04693000763654709, 0.009974686428904533, 0.03109011799097061, -0.012696364894509315, 0.030124813318252563, 0.02372679114341736, 0.06566771119832993, 0.03553507477045059, -0.032816141843795776, 0.028003521263599396, 0.06498659402132034, -0.013530750758945942, 0.0312667116522789, -0.015660811215639114, -0.00776742585003376, -0.004829467739909887, -0.015968922525644302, 0.04765664413571358, -0.0026502758264541626, 0.01891564577817917, 0.04119837284088135, 0.012158435769379139, 0.008338023908436298, -0.006039333995431662, 0.0630166307091713, -0.02758428454399109, 0.029347822070121765, -0.030129415914416313, 0.023165738210082054, 0.04064684361219406, 0.04446929693222046, -0.006133638322353363, -0.013095719739794731, -0.041152223944664, -0.01038535125553608, 0.01738007925450802, 0.0010595708154141903, -0.055003564804792404, 0.036829687654972076, -0.030270753428339958, -0.009607627056539059, 0.014103117398917675, 0.005140293389558792, 0.032931022346019745, 0.026972685009241104, -0.00039128100615926087, 0.00550195062533021, 0.062454141676425934, 0.02344602160155773, -0.01688288524746895, 0.011600837111473083, 0.009648085571825504, 0.012827200815081596, 0.02368510514497757, -0.044808436185121536, 0.006574536208063364, 0.03677171841263771, 0.021754244342446327, -0.0031720376573503017, -0.03498553857207298, -0.027119319885969162, 0.05196662247180939, 0.0063033513724803925, -0.002766692778095603, -0.03879206255078316, -0.005737128667533398, -0.02351462095975876, 0.04338989034295082, -0.03623301535844803, 0.003727369010448456, 0.044172726571559906, 0.06180792301893234, -0.025736358016729355, 0.01280374638736248, -0.01768171414732933, 0.0413120836019516, 0.036350950598716736, 0.020034022629261017, -0.00938474852591753, -0.04920303076505661, -0.1626604050397873, 0.0016566020203754306, -0.010797491297125816, 0.0037245014682412148, 0.039030417799949646, -0.009399985894560814, 0.016659803688526154, -0.047097429633140564, -0.00987484585493803, 0.020634479820728302, 0.005361238028854132, -0.05283225327730179, 0.002501025330275297, -0.004766151309013367, 0.00850654486566782, -0.0050267502665519714, -0.046555373817682266, 0.012670878320932388, 0.0018581973854452372, -0.010647253133356571, 0.01990092545747757, 0.02013244479894638, 0.04490885138511658, 0.029433563351631165, -0.01408607978373766, 0.029722925275564194, 0.04512600228190422, -0.04305345192551613, 0.0053901285864412785, -0.010685979388654232, 0.01516974437981844, 0.02340293675661087, -0.014181641861796379, -0.0013334851246327162, 0.020624764263629913, 0.06469231843948364, 0.016654038801789284, -0.043994754552841187, 0.025707466527819633, -0.004160136915743351, 0.021129926666617393, 0.041262850165367126, 0.006293899845331907, 0.056005991995334625, -0.006883381400257349, -0.07502268254756927, -0.02920101210474968, -0.019043054431676865, 0.00737513042986393, 0.013621360063552856, -0.02504715882241726, -0.01138006430119276, -0.010744514875113964, -0.02502342313528061, -0.03335903584957123, 0.012180354446172714, -0.03276645019650459, 0.05202409625053406, 0.03246080502867699, 0.03068908303976059, -0.029587913304567337, -0.04850265011191368, -0.006388102192431688, -0.03203853219747543, -0.050761956721544266, -0.021925227716565132, 0.036384399980306625, -0.011895880103111267, -0.007408954203128815, -0.012625153176486492, 0.0024322718381881714, -0.012196220457553864, -0.007011729292571545, -0.0337890200316906, -0.030034994706511497, 0.04638829082250595, -0.028362803161144257, -0.01176459901034832, 0.00956833828240633, -0.12054562568664551, -0.020540419965982437, 0.014624865725636482, -0.025515791028738022, -0.005027926992624998, -0.03586679324507713, -0.05585843697190285, -0.01700599677860737, -0.00044939795043319464, 0.029278729110956192, 0.25503888726234436, -0.024952411651611328, 0.005794796161353588, -0.007252118084579706, 0.03397773951292038, -0.0030146583449095488, -0.016645856201648712, -0.0008194005931727588, 0.02789629064500332, -0.039116114377975464, -0.035631854087114334, 0.04917449131608009, -0.006455820053815842, -0.011818122118711472, -0.00958359707146883, 0.013176187872886658, 0.037286531180143356, 0.022334400564432144, 0.05832865461707115, 0.010104321874678135, -0.04915979504585266, -0.022671189159154892, -0.016606582328677177, -0.007431587669998407, 0.0025214774068444967, -0.038979604840278625, 0.014895224012434483, 0.03583076596260071, 0.0006473385728895664, 0.04958082735538483, -0.017827684059739113, 0.015710417181253433, 0.062094446271657944, -0.014381879940629005, 0.0002880772517528385, 0.004948006477206945, -8.711735063116066e-06, -0.0029445397667586803, -0.044325683265924454, 0.047702621668577194, -0.03197811171412468, -0.02109563909471035, 0.03041824884712696, 0.021582895889878273, -0.004118872340768576, -0.025784745812416077, 0.06275995075702667, 0.006879465654492378, 0.04185185581445694, 0.02031264826655388, -0.02274201810359955, -0.009617358446121216, -0.04315454140305519, -0.033287111669778824, -0.025126483291387558, -0.003923895303159952, -0.041508499532938004, -0.0009355457150377333, -0.033565372228622437, 0.02229289337992668, -0.0026574484072625637, -0.0028596664778888226, -0.02223617024719715, -0.016868866980075836, 0.04172029718756676, 0.0014162511797621846, -0.037737537175416946, -0.010155809111893177, -0.010357595980167389, 0.04541466012597084, 0.03563382104039192, -0.019189776852726936, -0.012577632442116737, -0.013781189918518066, 0.026566311717033386, 0.020911909639835358, 0.02781282551586628, 0.053938526660203934, 0.0194545891135931, 0.0015139722963795066, -0.0357731431722641, -0.005088387057185173, 0.004257760010659695, 0.04332628846168518, -0.012149352580308914, -0.04734082147479057, 0.018029984086751938, -0.01322091929614544, -0.059820450842380524, -0.03677783161401749, -0.006745075341314077, -0.02209635078907013, -0.012663901783525944, -0.0059855030849576, 0.016270749270915985, -0.00725028058513999, 0.03019685670733452, 0.010252268984913826, -0.06314245611429214, -0.005512078758329153, -0.016377074643969536, -0.0014438428916037083, 0.029021194204688072, -0.015355946496129036, 0.02559172362089157, -0.04241044819355011, 0.010147088207304478, -0.016036594286561012, 0.023162752389907837, 0.047236304730176926, 0.0166736152023077, 0.01226564310491085, -0.015224735252559185, -0.01298521552234888, -0.008012642152607441, 0.028470756486058235, -0.013741613365709782, 0.019896863028407097, 0.01720179058611393, 0.01571199856698513, 0.030143165960907936, -0.02969514951109886, 0.014739652164280415, -0.01854291744530201, -0.045576371252536774, -0.04516203701496124, 0.02147211693227291, 0.007073952350765467, 0.008106761611998081, -0.01828523352742195, 0.002731812885031104, -0.04545339569449425, 0.019007619470357895, 0.03504781052470207, 0.037705861032009125, -0.0045634908601641655, 0.0070000626146793365, 0.0037205498665571213, 0.005224148277193308, -0.017060590907931328, -0.04246727377176285, -0.006265614647418261, -0.015374364331364632, -0.03380871191620827, -0.005029333755373955, 0.007065227720886469, 0.003886009333655238, 0.008613690733909607, -0.012133199721574783, 0.005556005053222179, -0.021959641948342323, 0.04834386706352234, 0.03787781298160553, -0.057815466076135635, 0.015909207984805107, -0.03855409845709801, 0.0018244135426357388, 0.04186264052987099, -0.054983459413051605, 0.006219237111508846, 0.03494301065802574, 0.023722950369119644, 0.0312604121863842, 0.05597991123795509, -0.030345493927598, 0.016615940257906914, -0.0207205917686224, 0.055960651487112045, -0.012713379226624966, -0.0261109359562397, 0.014332456514239311, -0.017245708033442497, -0.06636268645524979, 0.00592504907399416, 0.04649018123745918, -0.018362276256084442, 0.009620632976293564, -0.0044480785727500916, -0.0014729035319760442, 0.015621249563992023, 0.0367378331720829, -0.011857259087264538, -0.045088741928339005, 0.0006832792423665524, 0.02601524256169796, -0.02120809443295002, 0.018104318529367447, 0.008069046773016453, 0.013658273033797741, 0.004183551296591759, -0.04133244603872299, 0.05436890944838524, 0.009334285743534565, -0.014695074409246445, -0.011054124683141708, 0.009796642698347569, -0.008759389631450176, -0.06399217247962952, -0.0028859861195087433, -0.008736967109143734, -0.003506746841594577, 0.008123806677758694, 0.008794951252639294, -0.02940259501338005, 0.009597218595445156, -0.02197900228202343, -0.02082076109945774, 0.023915970697999, -0.059058744460344315, -0.010253551416099072, 0.024443935602903366, -0.029604850336909294, 0.008135135285556316, 0.03568771481513977, -0.017330091446638107, -0.003135789418593049, 0.035103678703308105, 0.0370408296585083, -0.01022601593285799, -0.045891791582107544, 0.01726667769253254, -0.008570673875510693, 0.015297998674213886, -0.015412220731377602, -0.01425748411566019, 0.031544867902994156, 0.013110813684761524, -0.057211123406887054, -0.0008968000765889883, 0.001981658162549138, -0.002101168967783451, -0.09516698867082596, -0.034693196415901184, 0.011157260276377201, 0.010063023306429386, -0.02550840750336647, 0.009959851391613483, 0.022281678393483162, -0.03908146917819977, 0.02196437120437622, 0.03520793840289116, -0.06856158375740051, -0.004901218693703413, 0.1122148334980011, -0.01498009730130434, 0.03165500983595848, -0.07618033140897751, -0.014297851361334324, 0.02150021120905876, 0.005999598652124405, -0.013493427075445652, 0.013868110254406929, 0.00079053093213588, 0.006475066766142845, 0.000955471652559936, -0.03403160721063614, -0.02295752801001072, 0.0041635241359472275, -0.03955964744091034, -0.04943346977233887, 0.00032474088948220015, 0.039174411445856094, -0.011974001303315163, 0.008057610131800175, 0.03809700161218643, -0.041719768196344376, 0.037615906447172165, -0.035932306200265884, 0.008293192833662033, -0.03261689469218254, -0.023902395740151405, -7.811257091816515e-05, -0.011328466236591339, -0.026476409286260605, 0.055370282381772995, 0.03128054738044739, -0.014991461299359798, 0.017835773527622223, 0.01642710715532303, 0.029273470863699913, -0.012139911763370037, 0.01371818222105503, -0.013113478198647499, -0.04071088507771492, 0.0233455840498209, -0.019497444853186607, -0.01747158169746399, 0.02493683062493801, 0.024074571207165718, -0.03614620864391327, -0.025289475917816162, -0.04030011221766472, -0.046772539615631104, 0.009969661012291908, 0.003724620910361409, 0.007474626414477825, -0.04855594411492348, 0.04697829484939575, 0.010695616714656353, 0.027944304049015045, -0.003937696572393179, -0.011591222137212753, -0.011533009819686413, 0.03215765953063965, -0.04699324443936348, -9.356102236779407e-05, -0.01535400003194809, -0.010238519869744778, 0.002703386126086116, 0.04759520664811134, 0.0074842446483671665, -0.04050430282950401, -0.028402622789144516, -0.03205197677016258, 0.011288953013718128, 0.006053865421563387, 0.04641448333859444, 0.005652922671288252, -0.018560705706477165, 0.02581481821835041, 0.00962467584758997, -0.017888177186250687, -0.026476262137293816, -0.005547264125198126, 0.012222226709127426, -0.004069746006280184, -0.020438821986317635, 0.01929863728582859, -0.0053736320696771145, 0.02221786603331566, -0.007175051141530275, 0.003961225971579552, -0.012380941770970821, -0.0040277824737131596, 0.009086307138204575, 0.012202796526253223, 0.018483169376850128, 0.017530532553792, 0.0422886498272419, 0.04987001419067383, 0.003722204128280282, 0.06421508640050888, -0.016258088871836662, -0.027659112587571144, 0.004458434879779816, -0.02898143045604229, -0.014475414529442787, 0.032039571553468704, -0.025734663009643555, -0.01585981249809265, 0.04900333285331726, -0.06422552466392517, -0.0007134959450922906, -0.04035528376698494, 0.03290264680981636, -0.0018848407780751586, 0.0068516512401402, 0.00032433189335279167, -0.002669606124982238, -0.017596688121557236, -0.026878179982304573, 0.014075388200581074, 0.020072080194950104, -0.00295435544103384, -0.01918656937777996, -0.007689833641052246, 0.039347097277641296, 0.0026605715975165367, 0.011779646389186382, 0.04189120978116989, -0.03846775367856026, -0.01993645168840885, 0.04546443000435829, 0.05682912468910217, -0.012384516187012196, -0.004507445730268955, 0.007476931903511286, -0.01160018052905798, 0.006559243891388178, 0.04354899004101753, 0.006185194011777639, 0.028355205431580544, -0.006518798414617777, -0.029528537765145302, 0.06740271300077438, -0.052158474922180176, 0.0025031850673258305, -0.005957300774753094, 0.00500349560752511, 0.022637680172920227, -0.0027129461523145437, -0.011677206493914127, -0.042732879519462585, -0.0021236639004200697, -0.1499215066432953, 0.02914350852370262, -0.031246500089764595, -0.027244996279478073, -0.006904688663780689, 0.01088196225464344, 0.01271661464124918, -0.0430884025990963, -0.020760131999850273, -0.006593034137040377, -0.0007962957606650889, -0.031729113310575485, 0.052976224571466446, -0.03149586543440819, 0.0392388291656971, 0.023318620398640633, -0.01383691094815731, 0.02858218550682068, 0.023135144263505936, 0.026421336457133293, 0.00027594034327194095, -0.03901490569114685, 0.008533132262527943, -0.03802476078271866, -0.011105065234005451, -0.028275510296225548, 0.04846742004156113, 0.021237077191472054, -0.027375172823667526, -0.02717825025320053, -0.031243441626429558, -0.021638689562678337, 0.024066096171736717, 0.05689090117812157, -0.04352620989084244, 0.03599394112825394, 0.05153508856892586, 0.002263782313093543, 0.047110624611377716, 0.006084555760025978, 0.003244618885219097, -0.0015037712873890996, 0.027960799634456635, -0.013650861568748951, 0.03281615301966667, 0.012363187968730927, 0.02162906341254711, -0.010951842181384563, -0.02786285988986492, 0.03754381462931633, 0.01957041770219803, -0.017010418698191643, -0.008339766412973404, 0.0755641758441925, 0.023412147536873817, -0.005748848430812359, -0.05465301498770714, -0.02190011739730835, 0.0054182386957108974, 0.032733004540205, -0.05342638120055199, 0.009907999075949192, -0.02370712347328663, -0.015652501955628395, -0.011254304088652134, -0.019827252253890038, -0.021032121032476425, -0.02607329562306404, -0.0008710312540642917, -0.06800976395606995, -0.017296750098466873, 0.015312970615923405, -0.015649013221263885, -0.016449443995952606, -0.012058117426931858, 0.002104945247992873, 0.020476385951042175, 0.014795565977692604, -0.02145536057651043, -0.028734024614095688, -0.041212357580661774, -0.008211270906031132, 0.033569078892469406, -0.0033273063600063324, -0.02339683100581169, 0.0421740785241127, -0.009677124209702015, -0.006869456730782986, -0.016001028940081596, 0.029614608734846115, -0.06062136963009834, -0.011824233457446098, 0.012096629478037357, -0.028248939663171768, -0.03703905642032623, 0.012119539082050323, -0.041021380573511124, 0.01975782960653305, -0.028443211689591408, 0.020459437742829323, 0.0073023103177547455, -0.06498327851295471, -0.004016770515590906, 0.06460512429475784, -0.053343966603279114, 0.03865537419915199, -5.4113028454594314e-05, -0.008642046712338924, -0.009384138509631157, -0.037736788392066956, -0.035090748220682144, 0.018596891313791275, -0.008763385005295277, 0.040228284895420074, 0.03811536356806755, -0.034618355333805084, -0.004665717948228121, 0.04813361540436745, -0.004303373862057924, 0.00795511994510889, -0.017838604748249054, 0.00563138909637928, -0.03171280398964882, -0.0259436946362257, 0.004301885142922401, -0.02739236131310463, 0.03270035237073898, 0.009064823389053345, -0.0363747663795948, 0.02325567975640297, 0.03453107923269272, -0.012906554155051708, 0.028347544372081757, 0.01234712265431881, 0.030589573085308075, 0.0024874424561858177, -0.0173872709274292, 0.0247347354888916, 0.004171399865299463, 0.02350561134517193, -0.05499064922332764, -0.023146219551563263, -0.012485259212553501, -0.0228674728423357, 0.013267520815134048, 0.021304689347743988, -0.018937893211841583, -0.0260267723351717, -0.022532619535923004, 0.0030378480441868305, -0.008528024889528751, -0.030528495088219643, -0.009305189363658428, -0.0074027362279593945, -0.020641637966036797, 0.006984233390539885, 0.04300186410546303, -0.033014994114637375, -0.006089311558753252, 0.04753036051988602, -0.036625705659389496, -0.04691743850708008, -0.007467558141797781, 0.0652017593383789, -0.03861508145928383, -0.00741452956572175, 0.003471594536677003, 0.016132064163684845, 0.01570185460150242, 0.018733495846390724, -0.019025148823857307, 0.003490244736894965, -0.017714614048600197, -0.003447450464591384, 0.015267218463122845, 0.015076974406838417, -0.002631498035043478, 0.005311752203851938, 0.014075293205678463, 0.0026123111601918936, 0.011874910444021225, 0.0714355856180191, 0.06941138952970505, 0.022251378744840622, 0.01972009800374508, 0.04719123989343643, 0.023544959723949432, 0.017852554097771645, 0.01843070052564144, -0.05294886603951454, -0.008682304993271828, 0.010625398717820644, 0.0428495928645134, 0.002173527143895626, 0.06291069090366364, 0.024296458810567856, 0.008714474737644196, 0.06520587205886841, 0.015627536922693253, 0.04247526824474335, 0.0009774811333045363, 0.00738496845588088, -0.024803027510643005, 0.013228596188127995, -0.037615202367305756, -0.028807995840907097, 0.012890785001218319, -0.01587829552590847, -0.01928863860666752, 0.0011809614952653646, -0.026926854625344276, -0.020252779126167297, -0.010968486778438091, -0.015348547138273716, 0.008559435606002808, -0.009286923334002495, 0.0014621232403442264, 0.03831499442458153, 0.016517579555511475, 0.037184324115514755, -0.041231196373701096, 0.03757374733686447, -0.039465345442295074, -0.04308579862117767, 0.0011091071646660566, -0.029794104397296906, 0.008459310978651047, -0.01713281124830246, -0.016625113785266876, -0.05582521855831146, -0.0415986105799675, 0.028725938871502876, 0.04966316372156143, 0.012718678452074528, -0.025533588603138924, 0.013822318986058235, -5.168768620933406e-05, 0.02616700902581215, -0.06113629788160324, -0.03175340220332146, 0.03593592345714569, -0.04014921560883522, -0.020605407655239105, 0.02186705358326435]
  680 +```
0 681 \ No newline at end of file
... ...
docs/ES/2_kibana安装.md 0 → 100644
... ... @@ -0,0 +1,51 @@
  1 +
  2 +
  3 +
  4 +
  5 +
  6 +## 1. yum安装
  7 +添加yum仓库。
  8 +Kibana通常不是yum默认仓库的一部分,因此需要添加 Elastic 仓库::
  9 +```shell
  10 +
  11 +导入 Elastic 签名密钥:
  12 +sudo rpm --import https://artifacts.elastic.co/GPG-KEY-elasticsearch
  13 +
  14 +添加 Elastic 仓库:
  15 +sudo tee /etc/yum.repos.d/elastic.repo <<EOF
  16 +[elastic-8.x]
  17 +name=Elastic repository for 8.x packages
  18 +baseurl=https://artifacts.elastic.co/packages/8.x/yum
  19 +gpgcheck=1
  20 +gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch
  21 +enabled=1
  22 +autorefresh=1
  23 +type=rpm-md
  24 +EOF
  25 +```
  26 +然后可以安装 (版本要匹配,否则后面会有错误)
  27 +```shell
  28 +sudo yum install -y kibana-8.18.0
  29 +```
  30 +
  31 +## 2. 修改配置文件
  32 +```shell
  33 +# 使用yum安装的kibana,默认安装的主目录在/usr/share/kibana中。kibana配置文件的位置为/etc/kibana/kibana.yml。
  34 +vim /etc/kibana/kibana.yml
  35 +# 补充内容:
  36 +server.host: "0.0.0.0"
  37 +elasticsearch.hosts: ["http://ip:9200"]
  38 +i18n.locale: "zh-CN"
  39 +```
  40 +## 3. 启动
  41 +```shell
  42 +# 启动kibana
  43 +systemctl start kibana
  44 +systemctl status kibana
  45 +# 设置开机自启动
  46 +systemctl enable kibana
  47 +```
  48 +
  49 +在阿里云上面配置允许访问5601端口后,可以浏览器打开:
  50 +http://120.76.41.98:5601/
  51 +
... ...
docs/ES/3.1_hanlp安装.md 0 → 100644
... ... @@ -0,0 +1,116 @@
  1 +
  2 +
  3 +
  4 +TODO:
  5 +错误也是access denied ("java.io.FilePermission" "/usr/share/elasticsearch/data/model/perceptron/large/cws.bin" "read")
  6 +
  7 +一、环境:
  8 +[root@192 elasticsearch]# bin/elasticsearch --version
  9 +Version: 7.10.2, Build: default/rpm/747e1cc71def077253878a59143c1f785afa92b9/2021-01-13T00:42:12.435326Z, JVM: 15.0.1
  10 +[root@192 ~]# javac -version
  11 +javac 1.8.0_362
  12 +
  13 +二、jdk java.policy补充配置:
  14 +[root@192 elasticsearch]# tail /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.362.b08-3.el8.x86_64/jre/lib/security/java.policy
  15 + permission java.util.PropertyPermission "java.vm.specification.name", "read";
  16 + permission java.util.PropertyPermission "java.vm.version", "read";
  17 + permission java.util.PropertyPermission "java.vm.vendor", "read";
  18 + permission java.util.PropertyPermission "java.vm.name", "read";
  19 +
  20 + permission java.util.PropertyPermission "sun.security.pkcs11.disableKeyExtraction", "read";
  21 + permission java.net.SocketPermission "*", "connect,resolve";
  22 + permission java.io.FilePermission "-","read,write,delete";
  23 +};
  24 +
  25 +三、安装插件:
  26 +cd /usr/share/elasticsearch/
  27 +bin/elasticsearch-plugin install file:///ssd/samba_root1/projects/hanLP/elasticsearch-analysis-hanlp-7.10.2.zip
  28 +
  29 +chown -R elasticsearch:elasticsearch plugins/
  30 +
  31 +四、插件plugin-security.policy配置
  32 +因为本身已经配置了plugins/analysis-hanlp下的配置,而错误提示是用的elasticsearch/data/model 而不是 elasticsearch/plugins/analysis-hanlp/data/model,因此加上了上级目录的读写权限。
  33 +vi plugins/analysis-hanlp/plugin-security.policy
  34 +补充:
  35 + permission java.io.FilePermission "-", "read,write,delete";
  36 +
  37 +五、这时候提示model下的文件不存在,引文Model下是空的:
  38 +1)发现data/model用的不是插件下的data/model,这个data跟plugins同级,因此会把data拷贝一份到与plugins同级,使得两种路径都能访问到
  39 +2)models下只有一个readme,因此我会把hanLP官网下载下来的fulldata,把model下的内容拷贝过来
  40 +
  41 +ll plugins/analysis-hanlp/data/model/perceptron/large/cws.bin
  42 +
  43 +把data拷贝到上级
  44 +cd /usr/share/elasticsearch
  45 +cp -r /ssd/samba_root1/projects/hanLP/data/model/* plugins/analysis-hanlp/data/model/
  46 +chown -R elasticsearch:elasticsearch plugins/
  47 +cp -r /ssd/samba_root1/projects/hanLP/data .
  48 +chown -R elasticsearch:elasticsearch data/
  49 +
  50 +确保两个路径都能访问到:
  51 +ll /usr/share/elasticsearch/data/model/perceptron/large/cws.bin
  52 +ll /usr/share/elasticsearch/plugins/analysis-hanlp/data/model/perceptron/large/cws.bin
  53 +
  54 +六、还是提示同样的错误:
  55 +java.security.AccessControlException: access denied ("java.io.FilePermission" "/usr/share/elasticsearch/data/model/perceptron/large/cws.bin" "read")
  56 +但是这个路径是存在的:
  57 +[root@192 elasticsearch]# l /usr/share/elasticsearch/data/model/perceptron/large/cws.bin
  58 +-rw-r--r-- 1 elasticsearch elasticsearch 278038786 3月 9 19:44 /usr/share/elasticsearch/data/model/perceptron/large/cws.bin
  59 +
  60 +
  61 +
  62 +
  63 +
  64 +使用参考:
  65 +https://www.bilibili.com/read/cv22886449/
  66 +
  67 +一、python库安装
  68 +pip install hanlp -i https://pypi.tuna.tsinghua.edu.cn/simple
  69 +pip install --upgrade "hanlp[full]" -i https://pypi.tuna.tsinghua.edu.cn/simple
  70 +
  71 +# 环境准备:
  72 +# pip install hanlp -i https://pypi.tuna.tsinghua.edu.cn/simple
  73 +# # 安装完整版,注意zsh对于方括号[]要用引号包裹起来
  74 +# pip install --upgrade "hanlp[full]" -i https://pypi.tuna.tsinghua.edu.cn/simple
  75 +# 参考
  76 +# https://github.com/hankcs/HanLP/blob/doc-zh/plugins/hanlp_demo/hanlp_demo/zh/tok_stl.ipynb
  77 +# https://github.com/hankcs/HanLP/blob/doc-zh/plugins/hanlp_demo/hanlp_demo/zh/tok_mtl.ipynb
  78 +
  79 +(另外有一个 pyhanlp,看到官网上用的是hanlp,不是pyhanlp,先忽略)
  80 +
  81 +
  82 +
  83 +二、ES插件安装:
  84 +1. ES版本适配
  85 +hanlp插件只支持到7.10.2,因此将ES降到7.10.2
  86 +注意降级之前要把之前的数据都删掉(尝试把data数据下的路径删掉还不行),删掉后要yum remove elastics*,然后再安装。否则降级后ES不能适配新的数据格式,启动失败。
  87 +(删除之前把 /etc/elasticsearch/elasticsearch.yml 备份下来,否则又要重新改一次)
  88 +
  89 +es起来后,相应的pip的es版本也要更新:
  90 +pip install elasticsearch==7.10.1
  91 +
  92 +2. 安装插件
  93 +1)下载
  94 +hanlp:
  95 +https://github.com/KennFalcon/elasticsearch-analysis-hanlp
  96 +这里找一个最新的:
  97 +https://github.com/KennFalcon/elasticsearch-analysis-hanlp/releases
  98 +
  99 +2)安装插件:注意文件路径前面要加file://
  100 +cd /usr/share/elasticsearch
  101 +bin/elasticsearch-plugin install file:///ssd/samba_root1/projects/hanLP/elasticsearch-analysis-hanlp-7.10.2.zip
  102 +
  103 +如果要移出插件:
  104 +bin/elasticsearch-plugin remove analysis-hanlp
  105 +
  106 +3)安装数据包
  107 +https://github.com/hankcs/HanLP/releases?page=1
  108 +看到2020年5月以来、直至最新,都是这个数据包:数据包兼容data-for-1.7.5.zip md5=1d9e1be4378b2dbc635858d9c3517aaa
  109 +
  110 +unzip 后,把老的data备份,把新的拷贝过来:
  111 +
  112 +cd /usr/share/elasticsearch/plugins/analysis-hanlp
  113 +mv data data__bak_replace_by_full_data
  114 +cp /ssd/samba_root1/projects/hanLP/data . -rf
  115 +
  116 +
... ...
docs/ES/3.2_jieba插件安装.md 0 → 100644
... ... @@ -0,0 +1,107 @@
  1 +
  2 +
  3 +
  4 +插件地址:
  5 +https://gitcode.com/sing1ee/elasticsearch-jieba-plugin/tree/8.4.1?init=initRepo
  6 +安装参考文档:
  7 +https://blog.csdn.net/weixin_42326851/article/details/124615116
  8 +
  9 +
  10 +简明步骤
  11 +git clone git@gitcode.com:sing1ee/elasticsearch-jieba-plugin.git
  12 +cd elasticsearch-jieba-plugin
  13 +git checkout 8.4.1
  14 +# 注意如果Elasticsearch不是8.4.1,需要按照readme修改配置文件,包括ES版本、target JAVA版本
  15 +# 查看ES版本
  16 +# bin/elasticsearch --version
  17 +git submodule update --init --recursive
  18 +gradle wrapper
  19 +./gradlew pz
  20 +
  21 +TODO 拷贝到插件目录
  22 +
  23 +
  24 +检查
  25 +bin/elasticsearch-plugin list
  26 +
  27 +
  28 +测试
  29 +新建POST请求: http://localhost:9200/_analyze
  30 +
  31 +请求body:
  32 +
  33 +{
  34 + "analyzer": "jieba_index",
  35 + "text": "美国伊拉克"
  36 +}
  37 +
  38 +
  39 +
  40 +
  41 +
  42 +
  43 +详细步骤
  44 +1. 安装gradle:
  45 +到这里找到下载地址:https://services.gradle.org/distributions/
  46 +注意要用7.6.4 版本(之前用8.6版本出错,改为7.6.4好了)
  47 +wget下来二进制包(zip),解压到某个目录(~/.env下),配置好PATH:
  48 +~/.bashrc添加:
  49 +export GRADLE_HOME="$HOME/.env/gradle-7.6.4"
  50 +export PATH=${GRADLE_HOME}/bin::${PATH}
  51 +
  52 +2. 拉插件(elasticsearch-jieba-plugin)拉下来、打包
  53 +注意要用ssh、不要用https clone(用https,clone下来没问题,init就出问题,没找到原因。重新输密码、上传公钥、清除knownhosts,都不行):
  54 +git clone git@gitcode.com:sing1ee/elasticsearch-jieba-plugin.git
  55 +cd elasticsearch-jieba-plugin
  56 +git checkout 8.4.1
  57 +git submodule update --init --recursive
  58 +
  59 +/usr/share/elasticsearch/bin/elasticsearch --version
  60 +得到版本号:8.12.2
  61 +修改两个文件的ES版本:
  62 +src/main/resources/plugin-descriptor.properties
  63 +build.gradle (里面有两处修改)
  64 +
  65 +然后打包:
  66 +gradle wrapper
  67 +./gradlew pz
  68 +打包好的插件在目录: ./build/distributions
  69 +
  70 +gradlew pz又出错,提示找不到tools.jar:Could not find tools.jar. Please check that /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.292.b10-1.el8_4.x86_64/jre contains a valid JDK installation.
  71 +有的人是因为没配置JAVA_HOME,我这里,根据错误提示,路径找对了,但是这个路径下确实没有tools.jar。
  72 +因此只能重装jdk。
  73 +yum install java-1.8.0-openjdk
  74 +重装了,原来的jdk目录不存在了,有了新的:
  75 +/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.362.b08-3.el8.x86_64/
  76 +但是这个目录同样没有tools.jar 。后面找到资料,openjdk后面加个新,安装所有java1.8相关的东西,这个问题得到了修复:
  77 +yum -y install java-1.8.0-openjdk*
  78 +
  79 +又出了另外一个问题:
  80 +Execution failed for task ':compileJava'.
  81 +> 无效的源发行版: 18
  82 +原因是我们指定的源发行版不匹配Java编译器的版本。
  83 +1. 确保这里配置对了
  84 +sourceCompatibility = JavaVersion.VERSION_18 // 不同版本的es,需要不同版本的java环境,注意修改这里
  85 +targetCompatibility = JavaVersion.VERSION_18 // 不同版本的es,需要不同版本的java环境,注意修改这里
  86 +2. elasticsearch --version 提示ES的java版本是21,因此将以上配置改为21。 为了简化问题,决定回退ES版本,改回8.4.1,这样插件的配置文件都不用改了,直接用8.4.1分支就行。
  87 +3. java版本是1.8,不是18(之前以为1.8就是18,卡在这里大半天)。重新安装jdk18就好了。
  88 +javac -version
  89 +javac 1.8.0_362
  90 +# 注意yum里面只到17,没有18,下载jdk18,以rpm方式安装:https://www.oracle.com/java/technologies/javase/jdk18-archive-downloads.html
  91 +# 注意如果之前自己手动配置了JAVA_HOME,要把他删掉。
  92 +yum remove java-1.8.0-* (之前yum remove java*,有可能有问题)
  93 +rpm -ivh jdk-18.0.2.1_linux-x64_bin.rpm
  94 +现在三个的版本就都对了:
  95 +javac -version
  96 +javac 18.0.2.1
  97 +
  98 +[root@192 ~]# elasticsearch --version
  99 +warning: ignoring JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk; using bundled JDK
  100 +Version: 8.4.1, Build: rpm/2bd229c8e56650b42e40992322a76e7914258f0c/2022-08-26T12:11:43.232597118Z, JVM: 18.0.2
  101 +
  102 +gradle --version (gradle用的jdk是1.8 不用管,插件的readme上注明gradle版本7.6匹配ES版本8.4.1)
  103 +Gradle 7.6.4
  104 +JVM: 1.8.0_362
  105 +
  106 +
  107 +
... ...
docs/ES/3.3_ik分词器.md 0 → 100644
... ... @@ -0,0 +1,9 @@
  1 +
  2 +
  3 +
  4 +
  5 +cd /usr/share/elasticsearch/plugins/
  6 +wget https://release.infinilabs.com/analysis-ik/stable/elasticsearch-analysis-ik-8.18.0.zip
  7 +unzip elasticsearch-analysis-ik-8.18.0.zip -d elasticsearch-analysis-ik-8.18.0
  8 +systemctl restart elasticsearch
  9 +
... ...
docs/ES/3_ansj分词插件安装.md 0 → 100644
... ... @@ -0,0 +1,97 @@
  1 +
  2 +https://github.com/NLPchina/elasticsearch-analysis-ansj
  3 +
  4 +
  5 +git clone https://github.com/NLPchina/elasticsearch-analysis-ansj.git
  6 +cd elasticsearch-analysis-ansj
  7 +git checkout v8.3.3
  8 +mvn package
  9 +
  10 +会提示编译失败(v8.x版本都会失败,7.x就没问题),错误信息如下:
  11 +[ERROR] /ssd/samba_root1/projects/ansj/elasticsearch-analysis-ansj/src/main/java/org/ansj/elasticsearch/plugin/AnalysisAnsjPlugin.java:[14,34] 无法访问org.apache.lucene.analysis.Analyzer
  12 +[ERROR] 错误的类文件: /home/hello/.m2/repository/org/apache/lucene/lucene-core/9.2.0/lucene-core-9.2.0.jar(org/apache/lucene/analysis/Analyzer.class)
  13 +[ERROR] 类文件具有错误的版本 55.0, 应为 52.0
  14 +[ERROR] 请删除该文件或确保该文件位于正确的类路径子目录中。
  15 +
  16 +7.x版本都没问题,8.x就会出这个错误。尝试把jdk版本从1.8改成 11, 17, 18、升级maven版本到3.9.6都不行(又提示类文件具有错误的版本 61.0, 应为 55.0)。
  17 +有人说可能是依赖冲突,不知道是否可以修改下环境,使得不冲突。
  18 +
  19 +因此自己编译只能编译v7.17.16。8.x,release里面有现成的版本:
  20 +./bin/elasticsearch-plugin install https://github.com/NLPchina/elasticsearch-analysis-ansj/releases/download/v8.7.0/elasticsearch-analysis-ansj-8.7.0.0-release.zip
  21 +
  22 +测试:
  23 +kibana中 : GET /_cat/ansj?text=中国&type=index_ansj
  24 +或者:
  25 +curl -X GET "http://localhost:9200/_cat/ansj?text=中国&type=index_ansj"
  26 +
  27 +
  28 +curl -X GET "http://localhost:9200/_cat/ansj?pretty" -H 'Content-Type: application/json' -d'
  29 +{
  30 + "type": "index_ansj",
  31 + "text": "中国"
  32 +}'
  33 +
  34 +# 注意事项
  35 +ansj分词如果没有设置停用词的话,空格也会被分出来,搜出来的结果空格也会被飘红(如果query带空格的话)。所以一定要设置停用词表。
  36 +
  37 +词性说明:
  38 + 附-词性表格
  39 + 符号 词性 解释
  40 + n 名词 取英语名词noun的第1个字母。
  41 + np 人名
  42 + nr 人名 名词代码n和“人(ren)”的声母并在一起。
  43 + nh 人名
  44 + ns 地名 名词代码n和处所词代码s并在一起
  45 + ni 机构名
  46 + nz 其它专名
  47 + nt 机构团体名 “团”的声母为t,名词代码n和t并在一起。
  48 + nl 名词性惯用语
  49 + nd 方位名词
  50 + ng 名词性语素
  51 + b 区别词
  52 + m 数词 取英语numeral的第3个字母,n,u已有他用。
  53 + q 量词 取英语quantity的第1个字母。
  54 + mq 数量词
  55 + t 时间词 取英语time的第1个字母。
  56 + f 方位词 取汉字“方” 的声母。
  57 + s 处所词 取英语space的第1个字母
  58 + v 动词 取英语动词verb的第一个字母。
  59 + vd 副动词
  60 + vn 名动词
  61 + vshi 动词“是”
  62 + vyou 动词“有”
  63 + vf 趋向动词
  64 + vx 形式动词
  65 + vi 不及物动词(内动词)
  66 + vl 动词性惯用语
  67 + vg 动词性语素
  68 + a 形容词 取英语形容词adjective的第1个字母。
  69 + an 名形词
  70 + ad 副形词
  71 + an 名形词
  72 + ag 形容词性语素
  73 + al 形容词性惯用语
  74 + d 副词 取adverb的第2个字母,因其第1个字母已用于形容词。
  75 + h 前接成分 取英语head的第1个字母。
  76 + k 后接成分
  77 + i 成语 取英语成语idiom的第1个字母。
  78 + j 简称 取汉字“简”的声母。
  79 + l 习用语 习用语尚未成为成语,有点“临时性”,取“临”的声母
  80 + r 代词 取英语代词pronoun的第2个字母,因p已用于介词。
  81 + c 连词 取英语连词conjunction的第1个字母。
  82 + p 介词 取英语介词prepositional的第1个字母。
  83 + u 助词 取英语助词auxiliary 的第2个字母,因a已用于形容词。
  84 + ud 结构助词 有
  85 + ug 时态助词 你
  86 + uj 结构助词的 迈向
  87 + ul 时态助词了 完成
  88 + uv 结构助词地 满怀信心
  89 + uz 时态助词着 眼看
  90 + y 语气助词 取汉字“语”的声母。
  91 + e 叹词 取英语叹词exclamation的第1个字母。
  92 + o 拟声词 取英语拟声词onomatopoeia的第1个字母。
  93 + g 语素 绝大多数语素都能作为合成词的“词根”,取汉字“根”的声母。
  94 + w 标点
  95 + x 其它 非语素字只是一个符号,字母x通常用于代表未知数、符号。
  96 + z 状态词 取汉字“状”的声母的前一个字母。
  97 + tg 时语素 时间词性语素。时间词代码为t,在语素的代码g前面置以T。
0 98 \ No newline at end of file
... ...
docs/ES/4_索引和查询测试.md 0 → 100644
... ... @@ -0,0 +1,74 @@
  1 +# 查询官方文档:
  2 +https://link.zhihu.com/?target=https%3A//www.elastic.co/guide/cn/elasticsearch/guide/current/query-dsl-intro.html
  3 +
  4 +
  5 +# 查看配置
  6 +curl "localhost:9200/_nodes/settings?pretty=true"
  7 +
  8 +
  9 +# 测试多字段搜索(支持中文分词):
  10 +curl -X GET "localhost:9200/goods/_search" -H 'Content-Type: application/json' -d'
  11 +{
  12 + "query": {
  13 + "multi_match": {
  14 + "query": "玩具",
  15 + "fields": ["name^2", "name_zh^2", "sub_name_zh^2", "brand_name_zh^2", "category_name_zh^2"],
  16 + "fuzziness": "AUTO"
  17 + }
  18 + },
  19 + "highlight": {
  20 + "fields": {
  21 + "name": {},
  22 + "name_zh": {},
  23 + "sub_name_zh": {},
  24 + "brand_name_zh": {},
  25 + "category_name_zh": {}
  26 + }
  27 + },
  28 + "from": 0,
  29 + "size": 10
  30 +}'
  31 +
  32 +# 测试精确匹配:
  33 +curl -X GET "localhost:9200/goods/_search" -H "Content-Type: application/json" -d'
  34 +{
  35 + "query": {
  36 + "term": {
  37 + "goods_id": "2683337"
  38 + }
  39 + }
  40 +}'
  41 +
  42 +
  43 +# 查看索引分词情况:
  44 +curl -X GET "http://localhost:9200/goods/_doc/1?pretty"
  45 +curl -X GET "http://localhost:9200/goods/_termvectors/1?fields=*&pretty"
  46 +
  47 +# 如果文档不存在,找出任意一个文档,得到ID:
  48 +curl -X GET "http://localhost:9200/goods/_search?size=1&pretty"
  49 +# 得到ID后查询termvectors:
  50 +curl -X GET "http://localhost:9200/goods/_termvectors/[DOC_ID]?fields=*&pretty"
  51 +
  52 +
  53 +# 测试analyzer:
  54 +curl -X GET "http://localhost:9200/goods/_analyze?pretty" -H 'Content-Type: application/json' -d'
  55 +{
  56 + "text": "玩具",
  57 + "analyzer": "index_ansj"
  58 +}'
  59 +
  60 +
  61 +
  62 +# 测试向量搜索:
  63 +curl -X GET "localhost:9200/goods/_search" -H "Content-Type: application/json" -d'
  64 +{
  65 + "query": {
  66 + "script_score": {
  67 + "query": {"match_all": {}},
  68 + "script": {
  69 + "source": "cosineSimilarity(params.query_vector, 'name_prefix') + 1.0",
  70 + "params": {"query_vector": [-0.05291186273097992, 0.0274342093616724, -0.016730275005102158, 0.010487289167940617, -0.022640341892838478, -0.048682719469070435, 0.04544096067547798, 0.023079438135027885, 0.007221410982310772, 0.023566091433167458, 0.026696473360061646, 0.08252757787704468, -0.042835772037506104, 0.0009668126585893333, -0.02860398218035698, -0.004426108207553625, -0.002644421299919486, -0.027699561789631844, 0.005749804899096489, -0.04468372091650963, -0.0296687763184309, -0.009487600065767765, 0.020041221752762794, 0.00778265530243516, 0.008522099815309048, 0.03497027978301048, -0.021573258563876152, -0.028293319046497345, -8.54598984005861e-05, -0.03164539486169815, -0.017121458426117897, -0.0006902766763232648, 0.04650883004069328, -0.030234992504119873, -0.010207684710621834, -0.035288386046886444, -0.0047269039787352085, -0.0006454040994867682, -0.056146346032619476, 0.008901881985366344, 0.010757357813417912, -0.013022932223975658, 0.04627145081758499, -0.020669423043727875, -0.02031278982758522, -0.052186835557222366, -0.0148158585652709, -0.018267231062054634, -0.059003304690122604, -0.011793344281613827, 0.027096575126051903, 0.019299808889627457, 0.04161312058568001, -0.019393721595406532, -0.02361445501446724, 0.07711422443389893, -0.02068573422729969, -0.004702702630311251, -0.011135494336485863, 0.0101374052464962, -0.020808257162570953, 0.011924360878765583, -0.020093027502298355, -0.007138500455766916, 0.014727798290550709, 0.05770261213183403, 0.017841406166553497, 0.044339124113321304, -0.01490224339067936, -0.008343652822077274, -0.04842463508248329, 0.0336640290915966, -0.004893577191978693, -0.021536342799663544, -0.032384153455495834, -0.009452177211642265, -0.027460120618343353, -0.009426826611161232, 0.006357531528919935, 0.019494572654366493, 0.009722599759697914, -0.00497430982068181, 0.023032115772366524, 0.05221958085894585, -0.01671120524406433, 0.061740316450595856, -0.06789620220661163, -0.023851843550801277, -0.02249223366379738, -0.01231105625629425, -0.0499565526843071, 0.004251780919730663, 0.05466651916503906, -0.024449756368994713, -0.034151963889598846, 0.037387508898973465, -0.0016276679234579206, -0.02609393745660782, 0.01800747588276863, -0.0028136332985013723, -0.06036405637860298, 0.028903907164931297, 0.006318055558949709, 0.012870929203927517, -0.0021476889960467815, -0.012034566141664982, -0.008372323587536812, 0.024942906573414803, 0.08258169889450073, 0.006757829803973436, 0.032017264515161514, -0.012414710596203804, 0.014826267957687378, -0.040858786553144455, -0.0060302577912807465, 0.00843990221619606, -0.031066348776221275, -0.06313654035329819, 0.0056659989058971405, -0.007768781390041113, 0.011673268862068653, 0.007261875085532665, 0.006112886127084494, -0.07374890148639679, 0.06602894514799118, -0.05385972931981087, -0.0010994652984663844, 0.05939924344420433, 0.015503636561334133, 0.034621711820364, 0.008040975779294968, -0.023962488397955894, -0.06270411610603333, 0.00027893096557818353, -0.0436306893825531, -0.006309020332992077, 0.02416943572461605, -0.015391307882964611, -0.012442439794540405, -0.003181715961545706, -0.0021985983476042747, 0.008671553805470467, 0.004063367377966642, -0.02560708485543728, 0.03469422832131386, -0.04249674826860428, -0.013552767224609852, -0.052823010832071304, 0.014670411124825478, -0.011493593454360962, 0.024076055735349655, 0.056352417916059494, -0.008510314859449863, 0.015936613082885742, 0.003935575485229492, 0.0037949192337691784, 0.015074086375534534, 0.016583971679210663, -0.0057802870869636536, 0.005751866847276688, -0.009386995807290077, -0.03710195794701576, -0.03144300729036331, -0.07106415182352066, -0.003882911056280136, -0.010697683319449425, -0.014338435605168343, 0.007036983501166105, -0.035716522485017776, 0.06593189388513565, 0.007752529811114073, -0.030261363834142685, -0.02513342909514904, -0.039278656244277954, 0.015320679172873497, -0.012659071013331413, 0.014207725413143635, 0.010264124721288681, 0.01617652177810669, -0.022644126787781715, -0.031033707782626152, 0.04160666465759277, -0.05329348146915436, 0.02423500455915928, -0.019389694556593895, 0.008645910769701004, -0.005958682857453823, -0.03648180514574051, 0.011972597800195217, 0.037404924631118774, -0.007001751102507114, -0.05138246342539787, 0.0013400549069046974, -0.03268183395266533, 0.07687076926231384, -0.02033335529267788, -0.020667986944317818, 0.0038236891850829124, 0.029960744082927704, 0.015430699102580547, 0.05047214776277542, 0.0052254535257816315, 0.013995353132486343, -0.031164521351456642, -0.014291719533503056, 0.015829795971512794, -0.0013409113744273782, -0.044300951063632965, 0.045415859669446945, -0.005037966184318066, -0.03883415088057518, 0.027200160548090935, 0.008182630874216557, -0.046456750482320786, -0.029778052121400833, 0.02067168429493904, -0.006381513085216284, -0.04693000763654709, 0.009974686428904533, 0.03109011799097061, -0.012696364894509315, 0.030124813318252563, 0.02372679114341736, 0.06566771119832993, 0.03553507477045059, -0.032816141843795776, 0.028003521263599396, 0.06498659402132034, -0.013530750758945942, 0.0312667116522789, -0.015660811215639114, -0.00776742585003376, -0.004829467739909887, -0.015968922525644302, 0.04765664413571358, -0.0026502758264541626, 0.01891564577817917, 0.04119837284088135, 0.012158435769379139, 0.008338023908436298, -0.006039333995431662, 0.0630166307091713, -0.02758428454399109, 0.029347822070121765, -0.030129415914416313, 0.023165738210082054, 0.04064684361219406, 0.04446929693222046, -0.006133638322353363, -0.013095719739794731, -0.041152223944664, -0.01038535125553608, 0.01738007925450802, 0.0010595708154141903, -0.055003564804792404, 0.036829687654972076, -0.030270753428339958, -0.009607627056539059, 0.014103117398917675, 0.005140293389558792, 0.032931022346019745, 0.026972685009241104, -0.00039128100615926087, 0.00550195062533021, 0.062454141676425934, 0.02344602160155773, -0.01688288524746895, 0.011600837111473083, 0.009648085571825504, 0.012827200815081596, 0.02368510514497757, -0.044808436185121536, 0.006574536208063364, 0.03677171841263771, 0.021754244342446327, -0.0031720376573503017, -0.03498553857207298, -0.027119319885969162, 0.05196662247180939, 0.0063033513724803925, -0.002766692778095603, -0.03879206255078316, -0.005737128667533398, -0.02351462095975876, 0.04338989034295082, -0.03623301535844803, 0.003727369010448456, 0.044172726571559906, 0.06180792301893234, -0.025736358016729355, 0.01280374638736248, -0.01768171414732933, 0.0413120836019516, 0.036350950598716736, 0.020034022629261017, -0.00938474852591753, -0.04920303076505661, -0.1626604050397873, 0.0016566020203754306, -0.010797491297125816, 0.0037245014682412148, 0.039030417799949646, -0.009399985894560814, 0.016659803688526154, -0.047097429633140564, -0.00987484585493803, 0.020634479820728302, 0.005361238028854132, -0.05283225327730179, 0.002501025330275297, -0.004766151309013367, 0.00850654486566782, -0.0050267502665519714, -0.046555373817682266, 0.012670878320932388, 0.0018581973854452372, -0.010647253133356571, 0.01990092545747757, 0.02013244479894638, 0.04490885138511658, 0.029433563351631165, -0.01408607978373766, 0.029722925275564194, 0.04512600228190422, -0.04305345192551613, 0.0053901285864412785, -0.010685979388654232, 0.01516974437981844, 0.02340293675661087, -0.014181641861796379, -0.0013334851246327162, 0.020624764263629913, 0.06469231843948364, 0.016654038801789284, -0.043994754552841187, 0.025707466527819633, -0.004160136915743351, 0.021129926666617393, 0.041262850165367126, 0.006293899845331907, 0.056005991995334625, -0.006883381400257349, -0.07502268254756927, -0.02920101210474968, -0.019043054431676865, 0.00737513042986393, 0.013621360063552856, -0.02504715882241726, -0.01138006430119276, -0.010744514875113964, -0.02502342313528061, -0.03335903584957123, 0.012180354446172714, -0.03276645019650459, 0.05202409625053406, 0.03246080502867699, 0.03068908303976059, -0.029587913304567337, -0.04850265011191368, -0.006388102192431688, -0.03203853219747543, -0.050761956721544266, -0.021925227716565132, 0.036384399980306625, -0.011895880103111267, -0.007408954203128815, -0.012625153176486492, 0.0024322718381881714, -0.012196220457553864, -0.007011729292571545, -0.0337890200316906, -0.030034994706511497, 0.04638829082250595, -0.028362803161144257, -0.01176459901034832, 0.00956833828240633, -0.12054562568664551, -0.020540419965982437, 0.014624865725636482, -0.025515791028738022, -0.005027926992624998, -0.03586679324507713, -0.05585843697190285, -0.01700599677860737, -0.00044939795043319464, 0.029278729110956192, 0.25503888726234436, -0.024952411651611328, 0.005794796161353588, -0.007252118084579706, 0.03397773951292038, -0.0030146583449095488, -0.016645856201648712, -0.0008194005931727588, 0.02789629064500332, -0.039116114377975464, -0.035631854087114334, 0.04917449131608009, -0.006455820053815842, -0.011818122118711472, -0.00958359707146883, 0.013176187872886658, 0.037286531180143356, 0.022334400564432144, 0.05832865461707115, 0.010104321874678135, -0.04915979504585266, -0.022671189159154892, -0.016606582328677177, -0.007431587669998407, 0.0025214774068444967, -0.038979604840278625, 0.014895224012434483, 0.03583076596260071, 0.0006473385728895664, 0.04958082735538483, -0.017827684059739113, 0.015710417181253433, 0.062094446271657944, -0.014381879940629005, 0.0002880772517528385, 0.004948006477206945, -8.711735063116066e-06, -0.0029445397667586803, -0.044325683265924454, 0.047702621668577194, -0.03197811171412468, -0.02109563909471035, 0.03041824884712696, 0.021582895889878273, -0.004118872340768576, -0.025784745812416077, 0.06275995075702667, 0.006879465654492378, 0.04185185581445694, 0.02031264826655388, -0.02274201810359955, -0.009617358446121216, -0.04315454140305519, -0.033287111669778824, -0.025126483291387558, -0.003923895303159952, -0.041508499532938004, -0.0009355457150377333, -0.033565372228622437, 0.02229289337992668, -0.0026574484072625637, -0.0028596664778888226, -0.02223617024719715, -0.016868866980075836, 0.04172029718756676, 0.0014162511797621846, -0.037737537175416946, -0.010155809111893177, -0.010357595980167389, 0.04541466012597084, 0.03563382104039192, -0.019189776852726936, -0.012577632442116737, -0.013781189918518066, 0.026566311717033386, 0.020911909639835358, 0.02781282551586628, 0.053938526660203934, 0.0194545891135931, 0.0015139722963795066, -0.0357731431722641, -0.005088387057185173, 0.004257760010659695, 0.04332628846168518, -0.012149352580308914, -0.04734082147479057, 0.018029984086751938, -0.01322091929614544, -0.059820450842380524, -0.03677783161401749, -0.006745075341314077, -0.02209635078907013, -0.012663901783525944, -0.0059855030849576, 0.016270749270915985, -0.00725028058513999, 0.03019685670733452, 0.010252268984913826, -0.06314245611429214, -0.005512078758329153, -0.016377074643969536, -0.0014438428916037083, 0.029021194204688072, -0.015355946496129036, 0.02559172362089157, -0.04241044819355011, 0.010147088207304478, -0.016036594286561012, 0.023162752389907837, 0.047236304730176926, 0.0166736152023077, 0.01226564310491085, -0.015224735252559185, -0.01298521552234888, -0.008012642152607441, 0.028470756486058235, -0.013741613365709782, 0.019896863028407097, 0.01720179058611393, 0.01571199856698513, 0.030143165960907936, -0.02969514951109886, 0.014739652164280415, -0.01854291744530201, -0.045576371252536774, -0.04516203701496124, 0.02147211693227291, 0.007073952350765467, 0.008106761611998081, -0.01828523352742195, 0.002731812885031104, -0.04545339569449425, 0.019007619470357895, 0.03504781052470207, 0.037705861032009125, -0.0045634908601641655, 0.0070000626146793365, 0.0037205498665571213, 0.005224148277193308, -0.017060590907931328, -0.04246727377176285, -0.006265614647418261, -0.015374364331364632, -0.03380871191620827, -0.005029333755373955, 0.007065227720886469, 0.003886009333655238, 0.008613690733909607, -0.012133199721574783, 0.005556005053222179, -0.021959641948342323, 0.04834386706352234, 0.03787781298160553, -0.057815466076135635, 0.015909207984805107, -0.03855409845709801, 0.0018244135426357388, 0.04186264052987099, -0.054983459413051605, 0.006219237111508846, 0.03494301065802574, 0.023722950369119644, 0.0312604121863842, 0.05597991123795509, -0.030345493927598, 0.016615940257906914, -0.0207205917686224, 0.055960651487112045, -0.012713379226624966, -0.0261109359562397, 0.014332456514239311, -0.017245708033442497, -0.06636268645524979, 0.00592504907399416, 0.04649018123745918, -0.018362276256084442, 0.009620632976293564, -0.0044480785727500916, -0.0014729035319760442, 0.015621249563992023, 0.0367378331720829, -0.011857259087264538, -0.045088741928339005, 0.0006832792423665524, 0.02601524256169796, -0.02120809443295002, 0.018104318529367447, 0.008069046773016453, 0.013658273033797741, 0.004183551296591759, -0.04133244603872299, 0.05436890944838524, 0.009334285743534565, -0.014695074409246445, -0.011054124683141708, 0.009796642698347569, -0.008759389631450176, -0.06399217247962952, -0.0028859861195087433, -0.008736967109143734, -0.003506746841594577, 0.008123806677758694, 0.008794951252639294, -0.02940259501338005, 0.009597218595445156, -0.02197900228202343, -0.02082076109945774, 0.023915970697999, -0.059058744460344315, -0.010253551416099072, 0.024443935602903366, -0.029604850336909294, 0.008135135285556316, 0.03568771481513977, -0.017330091446638107, -0.003135789418593049, 0.035103678703308105, 0.0370408296585083, -0.01022601593285799, -0.045891791582107544, 0.01726667769253254, -0.008570673875510693, 0.015297998674213886, -0.015412220731377602, -0.01425748411566019, 0.031544867902994156, 0.013110813684761524, -0.057211123406887054, -0.0008968000765889883, 0.001981658162549138, -0.002101168967783451, -0.09516698867082596, -0.034693196415901184, 0.011157260276377201, 0.010063023306429386, -0.02550840750336647, 0.009959851391613483, 0.022281678393483162, -0.03908146917819977, 0.02196437120437622, 0.03520793840289116, -0.06856158375740051, -0.004901218693703413, 0.1122148334980011, -0.01498009730130434, 0.03165500983595848, -0.07618033140897751, -0.014297851361334324, 0.02150021120905876, 0.005999598652124405, -0.013493427075445652, 0.013868110254406929, 0.00079053093213588, 0.006475066766142845, 0.000955471652559936, -0.03403160721063614, -0.02295752801001072, 0.0041635241359472275, -0.03955964744091034, -0.04943346977233887, 0.00032474088948220015, 0.039174411445856094, -0.011974001303315163, 0.008057610131800175, 0.03809700161218643, -0.041719768196344376, 0.037615906447172165, -0.035932306200265884, 0.008293192833662033, -0.03261689469218254, -0.023902395740151405, -7.811257091816515e-05, -0.011328466236591339, -0.026476409286260605, 0.055370282381772995, 0.03128054738044739, -0.014991461299359798, 0.017835773527622223, 0.01642710715532303, 0.029273470863699913, -0.012139911763370037, 0.01371818222105503, -0.013113478198647499, -0.04071088507771492, 0.0233455840498209, -0.019497444853186607, -0.01747158169746399, 0.02493683062493801, 0.024074571207165718, -0.03614620864391327, -0.025289475917816162, -0.04030011221766472, -0.046772539615631104, 0.009969661012291908, 0.003724620910361409, 0.007474626414477825, -0.04855594411492348, 0.04697829484939575, 0.010695616714656353, 0.027944304049015045, -0.003937696572393179, -0.011591222137212753, -0.011533009819686413, 0.03215765953063965, -0.04699324443936348, -9.356102236779407e-05, -0.01535400003194809, -0.010238519869744778, 0.002703386126086116, 0.04759520664811134, 0.0074842446483671665, -0.04050430282950401, -0.028402622789144516, -0.03205197677016258, 0.011288953013718128, 0.006053865421563387, 0.04641448333859444, 0.005652922671288252, -0.018560705706477165, 0.02581481821835041, 0.00962467584758997, -0.017888177186250687, -0.026476262137293816, -0.005547264125198126, 0.012222226709127426, -0.004069746006280184, -0.020438821986317635, 0.01929863728582859, -0.0053736320696771145, 0.02221786603331566, -0.007175051141530275, 0.003961225971579552, -0.012380941770970821, -0.0040277824737131596, 0.009086307138204575, 0.012202796526253223, 0.018483169376850128, 0.017530532553792, 0.0422886498272419, 0.04987001419067383, 0.003722204128280282, 0.06421508640050888, -0.016258088871836662, -0.027659112587571144, 0.004458434879779816, -0.02898143045604229, -0.014475414529442787, 0.032039571553468704, -0.025734663009643555, -0.01585981249809265, 0.04900333285331726, -0.06422552466392517, -0.0007134959450922906, -0.04035528376698494, 0.03290264680981636, -0.0018848407780751586, 0.0068516512401402, 0.00032433189335279167, -0.002669606124982238, -0.017596688121557236, -0.026878179982304573, 0.014075388200581074, 0.020072080194950104, -0.00295435544103384, -0.01918656937777996, -0.007689833641052246, 0.039347097277641296, 0.0026605715975165367, 0.011779646389186382, 0.04189120978116989, -0.03846775367856026, -0.01993645168840885, 0.04546443000435829, 0.05682912468910217, -0.012384516187012196, -0.004507445730268955, 0.007476931903511286, -0.01160018052905798, 0.006559243891388178, 0.04354899004101753, 0.006185194011777639, 0.028355205431580544, -0.006518798414617777, -0.029528537765145302, 0.06740271300077438, -0.052158474922180176, 0.0025031850673258305, -0.005957300774753094, 0.00500349560752511, 0.022637680172920227, -0.0027129461523145437, -0.011677206493914127, -0.042732879519462585, -0.0021236639004200697, -0.1499215066432953, 0.02914350852370262, -0.031246500089764595, -0.027244996279478073, -0.006904688663780689, 0.01088196225464344, 0.01271661464124918, -0.0430884025990963, -0.020760131999850273, -0.006593034137040377, -0.0007962957606650889, -0.031729113310575485, 0.052976224571466446, -0.03149586543440819, 0.0392388291656971, 0.023318620398640633, -0.01383691094815731, 0.02858218550682068, 0.023135144263505936, 0.026421336457133293, 0.00027594034327194095, -0.03901490569114685, 0.008533132262527943, -0.03802476078271866, -0.011105065234005451, -0.028275510296225548, 0.04846742004156113, 0.021237077191472054, -0.027375172823667526, -0.02717825025320053, -0.031243441626429558, -0.021638689562678337, 0.024066096171736717, 0.05689090117812157, -0.04352620989084244, 0.03599394112825394, 0.05153508856892586, 0.002263782313093543, 0.047110624611377716, 0.006084555760025978, 0.003244618885219097, -0.0015037712873890996, 0.027960799634456635, -0.013650861568748951, 0.03281615301966667, 0.012363187968730927, 0.02162906341254711, -0.010951842181384563, -0.02786285988986492, 0.03754381462931633, 0.01957041770219803, -0.017010418698191643, -0.008339766412973404, 0.0755641758441925, 0.023412147536873817, -0.005748848430812359, -0.05465301498770714, -0.02190011739730835, 0.0054182386957108974, 0.032733004540205, -0.05342638120055199, 0.009907999075949192, -0.02370712347328663, -0.015652501955628395, -0.011254304088652134, -0.019827252253890038, -0.021032121032476425, -0.02607329562306404, -0.0008710312540642917, -0.06800976395606995, -0.017296750098466873, 0.015312970615923405, -0.015649013221263885, -0.016449443995952606, -0.012058117426931858, 0.002104945247992873, 0.020476385951042175, 0.014795565977692604, -0.02145536057651043, -0.028734024614095688, -0.041212357580661774, -0.008211270906031132, 0.033569078892469406, -0.0033273063600063324, -0.02339683100581169, 0.0421740785241127, -0.009677124209702015, -0.006869456730782986, -0.016001028940081596, 0.029614608734846115, -0.06062136963009834, -0.011824233457446098, 0.012096629478037357, -0.028248939663171768, -0.03703905642032623, 0.012119539082050323, -0.041021380573511124, 0.01975782960653305, -0.028443211689591408, 0.020459437742829323, 0.0073023103177547455, -0.06498327851295471, -0.004016770515590906, 0.06460512429475784, -0.053343966603279114, 0.03865537419915199, -5.4113028454594314e-05, -0.008642046712338924, -0.009384138509631157, -0.037736788392066956, -0.035090748220682144, 0.018596891313791275, -0.008763385005295277, 0.040228284895420074, 0.03811536356806755, -0.034618355333805084, -0.004665717948228121, 0.04813361540436745, -0.004303373862057924, 0.00795511994510889, -0.017838604748249054, 0.00563138909637928, -0.03171280398964882, -0.0259436946362257, 0.004301885142922401, -0.02739236131310463, 0.03270035237073898, 0.009064823389053345, -0.0363747663795948, 0.02325567975640297, 0.03453107923269272, -0.012906554155051708, 0.028347544372081757, 0.01234712265431881, 0.030589573085308075, 0.0024874424561858177, -0.0173872709274292, 0.0247347354888916, 0.004171399865299463, 0.02350561134517193, -0.05499064922332764, -0.023146219551563263, -0.012485259212553501, -0.0228674728423357, 0.013267520815134048, 0.021304689347743988, -0.018937893211841583, -0.0260267723351717, -0.022532619535923004, 0.0030378480441868305, -0.008528024889528751, -0.030528495088219643, -0.009305189363658428, -0.0074027362279593945, -0.020641637966036797, 0.006984233390539885, 0.04300186410546303, -0.033014994114637375, -0.006089311558753252, 0.04753036051988602, -0.036625705659389496, -0.04691743850708008, -0.007467558141797781, 0.0652017593383789, -0.03861508145928383, -0.00741452956572175, 0.003471594536677003, 0.016132064163684845, 0.01570185460150242, 0.018733495846390724, -0.019025148823857307, 0.003490244736894965, -0.017714614048600197, -0.003447450464591384, 0.015267218463122845, 0.015076974406838417, -0.002631498035043478, 0.005311752203851938, 0.014075293205678463, 0.0026123111601918936, 0.011874910444021225, 0.0714355856180191, 0.06941138952970505, 0.022251378744840622, 0.01972009800374508, 0.04719123989343643, 0.023544959723949432, 0.017852554097771645, 0.01843070052564144, -0.05294886603951454, -0.008682304993271828, 0.010625398717820644, 0.0428495928645134, 0.002173527143895626, 0.06291069090366364, 0.024296458810567856, 0.008714474737644196, 0.06520587205886841, 0.015627536922693253, 0.04247526824474335, 0.0009774811333045363, 0.00738496845588088, -0.024803027510643005, 0.013228596188127995, -0.037615202367305756, -0.028807995840907097, 0.012890785001218319, -0.01587829552590847, -0.01928863860666752, 0.0011809614952653646, -0.026926854625344276, -0.020252779126167297, -0.010968486778438091, -0.015348547138273716, 0.008559435606002808, -0.009286923334002495, 0.0014621232403442264, 0.03831499442458153, 0.016517579555511475, 0.037184324115514755, -0.041231196373701096, 0.03757374733686447, -0.039465345442295074, -0.04308579862117767, 0.0011091071646660566, -0.029794104397296906, 0.008459310978651047, -0.01713281124830246, -0.016625113785266876, -0.05582521855831146, -0.0415986105799675, 0.028725938871502876, 0.04966316372156143, 0.012718678452074528, -0.025533588603138924, 0.013822318986058235, -5.168768620933406e-05, 0.02616700902581215, -0.06113629788160324, -0.03175340220332146, 0.03593592345714569, -0.04014921560883522, -0.020605407655239105, 0.02186705358326435]}
  71 + }
  72 + }
  73 + }
  74 +}'
... ...
docs/ES/README__ES查询相关.md 0 → 100644
... ... @@ -0,0 +1,701 @@
  1 +# Elasticsearch 查询相关
  2 +
  3 +## 根据商品ID查询
  4 +
  5 +```json
  6 +GET /uat_spu/_search
  7 +{
  8 + "query": {
  9 + "term": {
  10 + "_id": "3588136"
  11 + }
  12 + }
  13 +}
  14 +```
  15 +
  16 +## 查label_id
  17 +
  18 +```json
  19 +GET /uat_spu/_search
  20 +{"query":{"bool":{"must":[{"term":{ "platform_sku_essaone": true }},{"term":{"label_id_list":166}}]}}}
  21 +```
  22 +
  23 +## collapse折叠
  24 +
  25 +```json
  26 +GET /spu/_search
  27 +{
  28 + "_source": ["_id", "name_zh", "goods_id", "*"],
  29 + "size": 1000,
  30 + "query": {
  31 + "match": {
  32 + "name_zh": {
  33 + "query": "园艺"
  34 + }
  35 + }
  36 + },
  37 + "collapse": {
  38 + "field": "goods_id", // 按 goods_id 字段折叠分组
  39 + "inner_hits": {
  40 + "_source": ["_id"],
  41 + "name": "top_docs", // 自定义内部结果名称
  42 + "size": 3, // 每组取1个文档
  43 + "sort": [{"_score": "desc"}] // 按评分降序排序
  44 + }
  45 + },
  46 + "sort": ["_score"] // 确保外层排序兼容折叠功能
  47 +}
  48 +```
  49 +
  50 +## 在架、某平台商品数
  51 +
  52 +```json
  53 +GET /uat_spu/_search
  54 +{
  55 + "track_total_hits": 100000,
  56 + "query": {
  57 + "bool": {
  58 + "filter": [
  59 + {
  60 + "term": {
  61 + "platform_sku_essaone": true
  62 + }
  63 + },
  64 + {
  65 + "term": {
  66 + "platform_rule_essaone": true
  67 + }
  68 + },
  69 + {
  70 + "terms": {
  71 + "goods_copyright": [
  72 + "1",
  73 + "2",
  74 + "3"
  75 + ]
  76 + }
  77 + }
  78 + ]
  79 + }
  80 + }
  81 +}
  82 +```
  83 +
  84 +## ID查询
  85 +
  86 +```json
  87 +GET /uat_spu/_search
  88 +{
  89 + "query": {
  90 + "term": {
  91 + "_id": "3302275"
  92 + }
  93 + }
  94 +}
  95 +```
  96 +
  97 +## 商品名搜索
  98 +
  99 +```json
  100 +GET /spu/_search
  101 +{
  102 + "_source": {
  103 + },
  104 + "size": 1000,
  105 + "query": {
  106 + "match": {
  107 + "name_zh": {
  108 + "query": "园艺工具四件套",
  109 + "boost": 111.0
  110 + }
  111 + }
  112 + },
  113 + "aggs" :{
  114 + "goods_agg": {
  115 + "terms": {
  116 + "field": "goods_id",
  117 + "size": 100
  118 + },
  119 + "aggs": {
  120 + "top_hits": {
  121 + "top_hits": {
  122 + "size": 1,
  123 + "sort": [{"_score": "desc"}]
  124 + }
  125 + }
  126 + }
  127 + }
  128 + }
  129 +}
  130 +```
  131 +
  132 +## phrase搜索
  133 +
  134 +```json
  135 +GET /uat_spu/_search
  136 +{
  137 + "_source":["id","goods_id","name_zh"],
  138 + "query":{
  139 + "multi_match": {
  140 + "_name": "base_query",
  141 + "fields": [
  142 + "name_zh^2.0",
  143 + "goods_keyword_zh^1.0",
  144 + "category_name_zh^1.0",
  145 + "sale_category_keyword_zh^1.0",
  146 + "sub_name_zh^1.0"
  147 + ],
  148 + "query": "戏水玩具"
  149 + }
  150 + }
  151 +}
  152 +```
  153 +
  154 +## aggs聚合查询
  155 +
  156 +```json
  157 +GET /spu/_search
  158 +{
  159 + "_source": {
  160 + "excludes": [
  161 + "embedding_name_zh",
  162 + "embedding_name_ru", "*"
  163 + ],
  164 + "includes": ["_id", "name_zh"]
  165 + },
  166 + "size": 1000,
  167 + "query": {
  168 + "match": {
  169 + "name_zh": {
  170 + "query": "园艺"
  171 + }
  172 + }
  173 + },
  174 + "aggs" :{
  175 + "goods_agg": {
  176 + "terms": {
  177 + "field": "goods_id",
  178 + "size": 100
  179 + },
  180 + "aggs": {
  181 + "top_hits": {
  182 + "top_hits": {
  183 + "size": 1,
  184 + "sort": [{"_score": "desc"}]
  185 + }
  186 + }
  187 + }
  188 + }
  189 + }
  190 +}
  191 +```
  192 +
  193 +## 检查某个字段是否有值
  194 +```json
  195 +GET /uat_spu/_search
  196 +{
  197 + "track_total_hits": true,
  198 + "size": 0, // 不返回 hits,只返回总数
  199 + "query": {
  200 + "exists": {
  201 + "field": "goods_keyword_zh"
  202 + }
  203 + }
  204 +}
  205 +```
  206 +如果是nested字段,要这么查:
  207 +```json
  208 +GET /uat_spu/_search
  209 +{
  210 + "track_total_hits": true,
  211 + "size": 0, // 只看总数
  212 + "query": {
  213 + "nested": {
  214 + "path": "embedding_pic_h14",
  215 + "query": {
  216 + "exists": {
  217 + "field": "embedding_pic_h14.vector" // 或 url,只要子文档里任意字段有值
  218 + }
  219 + }
  220 + }
  221 + }
  222 +}
  223 +```
  224 +
  225 +```json
  226 +```
  227 +
  228 +## 分词测试
  229 +
  230 +### ik_smart分词器
  231 +
  232 +```json
  233 +POST spu/_analyze
  234 +{
  235 + "analyzer": "ik_smart",
  236 + "text": "14寸第4代-眼珠实身冰雪公仔带手动大推车,搪胶雪宝宝"
  237 +}
  238 +```
  239 +
  240 +### ik_max_word分词器
  241 +
  242 +```json
  243 +POST spu/_analyze
  244 +{
  245 + "analyzer": "ik_max_word",
  246 + "text": "14寸第4代-眼珠实身冰雪公仔带手动大推车,搪胶雪宝宝"
  247 +}
  248 +```
  249 +
  250 +### query_ansj分词器
  251 +
  252 +```json
  253 +POST spu/_analyze
  254 +{
  255 + "analyzer": "query_ansj",
  256 + "text": "14寸第4代-眼珠实身冰雪公仔带手动大推车,搪胶雪宝宝"
  257 +}
  258 +```
  259 +
  260 +### index_ansj分词器
  261 +
  262 +```json
  263 +POST spu_test/_analyze
  264 +{
  265 + "analyzer": "index_ansj",
  266 + "text": "14寸第4代-眼珠实身冰雪公仔带手动大推车,搪胶雪宝宝"
  267 +}
  268 +```
  269 +
  270 +## 查商品名
  271 +
  272 +```json
  273 +GET /spu/_search
  274 +{
  275 + "_source": {
  276 + "includes": [
  277 + "name_zh",
  278 + "category_name_zh",
  279 + "sub_name_zh",
  280 + "label_id_list",
  281 + "brand_id",
  282 + "category_id",
  283 + "price_range",
  284 + "on_sell_days_boost"
  285 + ]
  286 + },
  287 + "collapse": {
  288 + "field": "goods_id",
  289 + "inner_hits": {
  290 + "name": "top_hits",
  291 + "size": 1,
  292 + "_source": false // 避免返回完整_source
  293 + }
  294 + },
  295 + "from": 0,
  296 + "query": {
  297 + "function_score": {
  298 + "query": {
  299 + "bool": {
  300 + "minimum_should_match": 1,
  301 + "should": [
  302 + {
  303 + "multi_match": {
  304 + "_name": "base_query",
  305 + "fields": [
  306 + "name_zh^2.0",
  307 + "goods_keyword_zh^1.0",
  308 + "category_name_zh^1.0",
  309 + "sale_category_keyword_zh^1.0",
  310 + "sub_name_zh^1.0"
  311 + ],
  312 + "minimum_should_match": "66%",
  313 + "query": "网球",
  314 + "tie_breaker": 0.301
  315 + }
  316 + }
  317 + ]
  318 + }
  319 + }
  320 + }
  321 + },
  322 + "size": 1000,
  323 + "track_scores": true
  324 +}
  325 +```
  326 +
  327 +# 配置相关
  328 +
  329 +## 查看索引信息
  330 +
  331 +```bash
  332 +GET /_cat/indices/spu?v
  333 +```
  334 +
  335 +```bash
  336 +GET /spu/_mapping
  337 +```
  338 +
  339 +```bash
  340 +GET /spu/_settings
  341 +```
  342 +
  343 +## 设置刷新时间
  344 +
  345 +```json
  346 +PUT /spu/_settings
  347 +{
  348 + "refresh_interval": -1
  349 +}
  350 +```
  351 +
  352 +```json
  353 +PUT /uat_spu/_settings
  354 +{
  355 + "refresh_interval": "600s"
  356 +}
  357 +```
  358 +
  359 +## 设置preload
  360 +
  361 +```json
  362 +POST uat_spu/_close
  363 +PUT uat_spu/_settings
  364 +{
  365 + "index.store.preload": []
  366 +}
  367 +
  368 +PUT uat_spu/_settings
  369 +{
  370 + "index.store.preload": ["vex", "veq"]
  371 +}
  372 +# ["nvd", "dvd", "tim", "doc", "dim"]
  373 +
  374 +POST uat_spu/_open
  375 +
  376 +```
  377 +
  378 +## 修改分片数目
  379 +主分片的数目(number_of_shards)只能创建索引的时候修改
  380 +
  381 +
  382 +## 查看索引的分片数量、大小分布
  383 +```json
  384 +GET _cat/indices/uat_spu?v&s=store.size:desc
  385 +GET _cat/shards/uat_spu
  386 +```
  387 +
  388 +## 类别查询:索引中该类别总数
  389 +
  390 +```json
  391 +GET /spu/_search
  392 +{
  393 + "track_total_hits": 10000000,
  394 + "query": {"terms": {
  395 + "sale_category_all": [37619]
  396 + }}
  397 +}
  398 +```
  399 +
  400 +## 类别查询:模拟平台规则
  401 +
  402 +除了类别限定,包括:
  403 +1. essaone平台展示过滤
  404 +2. 非专属商品
  405 +3. status 2 4 5
  406 +4. goods_copyright 1,2,3
  407 +
  408 +```json
  409 +GET /spu/_search
  410 +{
  411 + "track_total_hits": 10000000,
  412 + "aggs": {
  413 + "unique_count": {
  414 + "cardinality": {
  415 + "field": "goods_id"
  416 + }
  417 + }
  418 + },
  419 + "collapse": {
  420 + "field": "goods_id"
  421 + },
  422 + "query": {
  423 + "bool": {
  424 + "filter": [
  425 + {
  426 + "bool": {
  427 + "minimum_should_match": 1,
  428 + "should": [
  429 + {
  430 + "term": {
  431 + "platform_sku_essaone": true
  432 + }
  433 + },
  434 + {
  435 + "bool": {
  436 + "must": [
  437 + {
  438 + "term": {
  439 + "platform_rule_essaone": true
  440 + }
  441 + },
  442 + {
  443 + "bool": {
  444 + "must_not": {
  445 + "exists": {
  446 + "field": "platform_sku_essaone"
  447 + }
  448 + }
  449 + }
  450 + }
  451 + ]
  452 + }
  453 + }
  454 + ]
  455 + }
  456 + },
  457 + {
  458 + "bool": {
  459 + "must_not": {
  460 + "exists": {
  461 + "field": "buyer_id"
  462 + }
  463 + }
  464 + }
  465 + },
  466 + {
  467 + "terms": {
  468 + "sale_category_all": [37619]
  469 + }
  470 + },
  471 + {
  472 + "terms": {
  473 + "status": [2,4,5]
  474 + }
  475 + },
  476 + {
  477 + "terms": {
  478 + "goods_copyright": [
  479 + "1",
  480 + "2",
  481 + "3"
  482 + ]
  483 + }
  484 + }
  485 + ]
  486 + }
  487 + }
  488 +}
  489 +```
  490 +
  491 +## 关键词查询
  492 +
  493 +```json
  494 +GET /spu/_search
  495 +{
  496 + "size": 1000,
  497 + "from": 0,
  498 + "_source": {
  499 + "includes": ["name_zh","goods_keyword_zh","sub_name_zh","category_name_zh","goods_keyword_zh","sale_category_keyword_zh"]
  500 + },
  501 + "query": {
  502 + "multi_match": {
  503 + "query": "遥控车",
  504 + "fields": ["name_zh^3.0", "goods_keyword_zh^1.0", "category_name_zh^1.0", "sale_category_keyword_zh^1.0", "sub_name_zh^1.0"],
  505 + "minimum_should_match": "64%",
  506 + "tie_breaker": 0.3,
  507 + "_name": "base_query"
  508 + }
  509 + },
  510 + "track_scores": true,
  511 + "collapse": {
  512 + "field": "goods_id"
  513 + }
  514 +}
  515 +```
  516 +
  517 +## 慢查询日志
  518 +
  519 +```json
  520 +PUT /spu,spu_test/_settings
  521 +{
  522 + "index.search.slowlog.threshold.query.warn": "1s",
  523 + "index.search.slowlog.threshold.query.info": "800ms",
  524 + "index.search.slowlog.threshold.query.debug": "600ms",
  525 + "index.search.slowlog.threshold.query.trace": "400ms",
  526 + "index.search.slowlog.threshold.fetch.warn": "500ms",
  527 + "index.search.slowlog.threshold.fetch.info": "400ms",
  528 + "index.search.slowlog.threshold.fetch.debug": "200ms",
  529 + "index.search.slowlog.threshold.fetch.trace": "100ms"
  530 +}
  531 +```
  532 +
  533 +```bash
  534 +GET /spu,spu_test/_settings?include_defaults=true&filter_path=**.slowlog
  535 +```
  536 +
  537 +---
  538 +
  539 +# 一些问题
  540 +
  541 +有一个商品,只命中了"玩具"、没有命中"遥控",两个词命中一个词(注意是所有的字段 总共只命中一个词,玩具命中多次,但是没有任何一个字段有"遥控"),minimum_should_match应该没有达到76%吧,76%是按照什么算的?为什么命中了这个查询条件?
  542 +
  543 +```json
  544 +"multi_match": {
  545 + "_name": "base_query",
  546 + "fields": [
  547 + "name_zh^2.0",
  548 + "goods_keyword_zh^1.0",
  549 + "category_name_zh^1.0",
  550 + "sale_category_keyword_zh^1.0",
  551 + "sub_name_zh^1.0"
  552 + ],
  553 + "minimum_should_match": "76%",
  554 + "query": "遥控玩具",
  555 + "tie_breaker": 0.3
  556 +}
  557 +```
  558 +
  559 +tie_breaker 导致
  560 +
  561 +```json
  562 +GET /spu/_search
  563 +{
  564 + "_source": {
  565 + "excludes": [
  566 + "embedding_name_zh",
  567 + "embedding_name_ru", "*"
  568 + ],
  569 + "includes": ["_id", "name_zh"]
  570 + },
  571 + "size": 1000,
  572 + "query": {
  573 + "match": {
  574 + "name_zh": {
  575 + "query": "园艺"
  576 + }
  577 + }
  578 + },
  579 + "aggs" :{
  580 + "goods_agg": {
  581 + "terms": {
  582 + "field": "goods_id",
  583 + "size": 100
  584 + },
  585 + "aggs": {
  586 + "top_hits": {
  587 + "top_hits": {
  588 + "size": 1,
  589 + "sort": [{"_score": "desc"}]
  590 + }
  591 + }
  592 + }
  593 + }
  594 + }
  595 +}
  596 +
  597 +
  598 +商品搜索查询模板
  599 +```json
  600 +GET /spu/_search
  601 +{
  602 + "_source": {
  603 + "includes": [
  604 + "name_zh"
  605 + ]
  606 + },
  607 + "aggs": {
  608 + "category_stats": {
  609 + "terms": {
  610 + "field": "sale_category_one_all",
  611 + "size": 100
  612 + }
  613 + },
  614 + "spu_attr_stats": {
  615 + "terms": {
  616 + "field": "attribute_option_list",
  617 + "size": 50
  618 + }
  619 + },
  620 + "unique_count": {
  621 + "cardinality": {
  622 + "field": "goods_id"
  623 + }
  624 + }
  625 + },
  626 + "collapse": {
  627 + "field": "goods_id"
  628 + },
  629 + "from": 0,
  630 + "query": {
  631 + "function_score": {
  632 + "boost_mode": "multiply",
  633 + "functions": [
  634 + {
  635 + "filter": {
  636 + "term": {
  637 + "is_video": true
  638 + }
  639 + },
  640 + "weight": 1.05
  641 + }
  642 + ],
  643 + "query": {
  644 + "bool": {
  645 + "filter": [
  646 + {
  647 + "terms": {
  648 + "status": [2,4,5]
  649 + }
  650 + }
  651 + ],
  652 + "must": [
  653 + {
  654 + "bool": {
  655 + "minimum_should_match": 1,
  656 + "should": [
  657 + {
  658 + "multi_match": {
  659 + "_name": "base_query",
  660 + "fields": [
  661 + "name_en^3.0",
  662 + "goods_keyword_en^1.0",
  663 + "category_name_en^1.3",
  664 + "sale_category_keyword_en^1.0",
  665 + "sub_name_en^1.0"
  666 + ],
  667 + "minimum_should_match": "75%",
  668 + "operator": "AND",
  669 + "query": "changshen flashing toys",
  670 + "tie_breaker": 0.9
  671 + }
  672 + },
  673 + {
  674 + "knn": {
  675 + "_name": "knn_query",
  676 + "field": "embedding_name_zh",
  677 + "k": 40,
  678 + "num_candidates": 120,
  679 + "query_vector": [...]
  680 + }
  681 + }
  682 + ]
  683 + }
  684 + }
  685 + ]
  686 + }
  687 + },
  688 + "score_mode": "sum"
  689 + }
  690 + },
  691 + "size": 1000,
  692 + "sort": [
  693 + {
  694 + "_score": {
  695 + "order": "desc"
  696 + }
  697 + }
  698 + ],
  699 + "track_scores": true
  700 +}
  701 +```
0 702 \ No newline at end of file
... ...
docs/ES/README__分词相关.md 0 → 100644
... ... @@ -0,0 +1,120 @@
  1 +
  2 +
  3 +工厂搜索 依赖于关键词召回、没有做语义召回和精排,加上语义召回和精排则成本过高,所以对分词效果仍然很依赖。badcase: q=锦鸿 无法召回 锦鸿达
  4 +1. 虽然商品搜索已经不强依赖于分词效果,但是工厂搜索仍然对分词效果有很大依赖,所以进行了优化。
  5 +2. 优化内容:
  6 + 1) index_ansj + 自定义词典(需要配置自定义词典。 不配置自定义词典的时候,index_ansj分词结果和query_ansj完全一致,配置自定义词典时,index_ansj 将 )
  7 + 2) ansj自定义词典 补充属性词
  8 +
  9 +
  10 +
  11 +
  12 +
  13 +| Query | IK_Smart 分词结果 | IK_Max_Word 分词结果 |
  14 +|---------|---------------------------------------------|--------------------------------------------------|
  15 +| 锦鸿达 | 锦, 鸿达 | 锦, 鸿达 |
  16 +| 锦鸿 | 锦, 鸿 | 锦, 鸿 |
  17 +| 14寸 4代 | 14寸, 4代 | 14, 寸, 4, 代 |
  18 +| q=14寸第4代-眼珠实身冰雪公仔带手动大推车,搪胶雪宝宝 | 14寸, 第, 4代, 眼珠, 实, 身, 冰雪, 公, 仔, 带, 手动, 大, 推车, 搪, 胶, 雪, 宝宝 | 14, 寸, 第, 4, 代, 眼珠, 实, 身, 冰雪, 公仔, 带, 手动, 大, 推车, 搪, 胶, 雪, 宝宝 |
  19 +| 金毛犬-狗狗系列积木套 | 金毛犬, 狗狗, 系列, 积木, 套 | 金毛犬, 狗狗, 系列, 积木, 套 |
  20 +
  21 +
  22 +
  23 +| Query | query_ansj 分词结果 | index_ansj 分词结果 |
  24 +|---------|------------------------------------------|--------------------------------------------------|
  25 +| 锦鸿达 | 锦, 鸿达 | 锦, 鸿达, 鸿, 达 |
  26 +| 锦鸿 | 锦鸿 | 锦鸿, 锦, 鸿 |
  27 +| q=14寸第4代-眼珠实身冰雪公仔带手动大推车,搪胶雪宝宝 | 14寸, 第, 4代, 眼珠, 实, 身, 冰雪, 公仔, 带, 手动, 大, 推车, 搪, 胶, 雪, 宝宝 | 14寸, 寸, 第, 4代, 代, 眼珠, 眼, 珠, 实, 身, 冰雪, 冰, 雪, 公仔, 公, 仔, 带, 手动, 手, 动, 大, 推车, 推, 车, 搪, 胶, 雪, 宝宝, 宝 |
  28 +| 金毛犬-狗狗系列积木套 | 金毛犬, 狗狗, 系列, 积木, 套 | 金毛犬, 金毛, 金, 毛, 犬, 狗狗, 狗, 系列, 系, 列, 积木, 积, 木, 套 |
  29 +
  30 +
  31 +ansj 插件自定义词典补充属性词后:
  32 +| Query | query_ansj 分词结果 | index_ansj 分词结果 |
  33 +|---------|------------------------------------------|--------------------------------------------------|
  34 +| 锦鸿达 | 锦, 鸿达 | 锦, 鸿达, 鸿, 达 |
  35 +| 锦鸿 | 锦鸿 | 锦鸿, 锦, 鸿 |
  36 +| q=14寸第4代-眼珠实身冰雪公仔带手动大推车,搪胶雪宝宝 | 14寸, 第, 4代, 眼珠, 实身, 冰雪, 公仔, 带, 手动, 大, 推车, 搪胶, 雪, 宝宝 | 14寸, 寸, 第, 4代, 代, 眼珠, 眼, 珠, 实身, 实, 身, 冰雪, 冰, 雪, 公仔, 公, 仔, 带, 手动, 手, 动, 大, 推车, 推, 车, 搪胶, 搪, 胶, 雪, 宝宝, 宝 |
  37 +| 金毛犬-狗狗系列积木套 | 金毛犬, 狗狗, 系列, 积木, 套 | 金毛犬, 金毛, 金, 毛, 犬, 狗狗, 狗, 系列, 系, 列, 积木, 积, 木, 套 |
  38 +
  39 +
  40 +
  41 +
  42 +## ik分词器的问题:
  43 +
  44 +```bash
  45 +POST spu/_analyze
  46 +{
  47 + "analyzer": "ik_smart",
  48 + "text": "14寸第4代-眼珠实身冰雪公仔带手动大推车,搪胶雪宝宝"
  49 +}
  50 +
  51 +POST spu/_analyze
  52 +{
  53 + "analyzer": "ik_max_word",
  54 + "text": "14寸第4代-眼珠实身冰雪公仔带手动大推车,搪胶雪宝宝"
  55 +}
  56 +
  57 +# ik分词器的问题:
  58 +# ik_max_word 结果是: 14 寸 第 4 代
  59 +# 期望是能分出多种形式: 14 寸 14寸 第 4 代 4代
  60 +# ik_smart
  61 +# 结果是: 14寸 第 4代
  62 +# 因此 14寸 4代 都无法召回原始文档。
  63 +```
  64 +
  65 +
  66 +## ansj分词器的问题:
  67 +
  68 +### 1. index_ansj不符合预期
  69 +index模式(type=index_ansj)不符合预期 :type=index_ansj type=query_ansj 结果永远都是一样的。
  70 +https://github.com/NLPchina/elasticsearch-analysis-ansj/issues/235
  71 +
  72 +已解决:需要配置自定义词典
  73 +
  74 +### 2. 特殊符号分词粘连问题
  75 +特殊符号(减号)会跟后面的词粘连到一起,导致搜索减号后面的词,无法匹配:
  76 +
  77 +```bash
  78 +GET /_cat/ansj?text=狗狗系列-柴犬积木&type=index_ansj
  79 +{
  80 +"name": "-柴",
  81 +"nature": "nrf",
  82 +"offe": 4,
  83 +"realName": "-柴",
  84 +"synonyms": null
  85 +},
  86 +
  87 +GET /_cat/ansj?text=狗狗系列-哈士奇犬&type=index_ansj
  88 +{
  89 +"name": "-哈士奇",
  90 +"nature": "nrf",
  91 +"offe": 4,
  92 +"realName": "-哈士奇",
  93 +"synonyms": null
  94 +},
  95 +```
  96 +
  97 +这样的话,如果搜索“柴犬”、“哈士奇”,就不能命中上面的句子。
  98 +
  99 +暂时解决办法是:
  100 +```json
  101 + "analyzer": {
  102 + "index_ansj": {
  103 + "type": "custom",
  104 + "char_filter": ["hyphen_to_space"],
  105 + "tokenizer": "index_ansj"
  106 + },
  107 + "query_ansj": {
  108 + "type": "custom",
  109 + "char_filter": ["hyphen_to_space"],
  110 + "tokenizer": "query_ansj"
  111 + }
  112 + }
  113 +```
  114 +
  115 +
  116 +
  117 +
  118 +
  119 +
  120 +
... ...
docs/ES/README__性能优化.md 0 → 100644
... ... @@ -0,0 +1,701 @@
  1 +
  2 +
  3 +
  4 +# 性能优化TODO
  5 +
  6 +
  7 +1. 主分片个数设置为12 / 16(暂定 16),replaca保持为0
  8 +2. 缩减索引&预加载内存(3年前的不做向量索引,在uat上 水哥已经做了,索引大小已经从120G减少到61G)。 之后设置预加载(UAT上面已经做了):
  9 +```json
  10 +POST uat_spu/_close
  11 +PUT uat_spu/_settings
  12 +{
  13 + "index.store.preload": []
  14 +}
  15 +
  16 +PUT uat_spu/_settings
  17 +{
  18 + "index.store.preload": ["vex", "veq"]
  19 +}
  20 +PUT uat_spu/_settings
  21 +{
  22 + "index.store.preload": ["nvd", "dvd", "tim", "doc", "dim"]
  23 +}
  24 +# ["nvd", "dvd", "tim", "doc", "dim"]
  25 +
  26 +POST uat_spu/_open
  27 +```
  28 +3. 段优化 (在索引稳定后):
  29 +POST /spu/_forcemerge?max_num_segments=1 。这将每个分片内的 Lucene 段合并到最少(理想是1个)
  30 +4. UAT索引迁出。
  31 +
  32 +
  33 +# old
  34 +
  35 +## 当前主要问题
  36 +
  37 +### 1. 按goods_id聚合/去重问题(collapse相关)
  38 +
  39 +当前采用collapse实现,但存在以下问题:
  40 +
  41 +#### 1.1 加inner_hits的性能问题
  42 +
  43 +我暂时放弃了 inner_hits,但是其实对inner_hits功能有较强的需求,是否有替代办法:能满足 按 goods_id 聚合、也能得到聚合下的原始文档ID、同时能满足分页需求。
  44 +
  45 +**对应案例:**
  46 +
  47 +将下面的"商品搜索实际案例"中的:
  48 +
  49 +```json
  50 +"collapse": {
  51 + "field": "goods_id"
  52 +}
  53 +```
  54 +
  55 +替换为:
  56 +
  57 +```json
  58 +"collapse": {
  59 + "field": "goods_id",
  60 + "inner_hits": {
  61 + "_source": false,
  62 + "name": "top_docs",
  63 + "size": 4
  64 + }
  65 +}
  66 +```
  67 +
  68 +可以看到耗时明显增加,耗时 330ms 增加到 3565ms。
  69 +
  70 +#### 1.2 分页不准的问题
  71 +
  72 +**背景:** ES的分页是基于索引文档的顺序,而不是折collapse叠后的顺序,这可能导致深度分页时的性能问题或结果不一致。
  73 +
  74 +这样会带来两个问题:
  75 +
  76 +##### a) total不准(total是collapse之前的个数)
  77 +我现在的方案是,aggs 再补充一项,计算一个按照 goods_id 的去重数,以此作为 total,从而得到准确的分页。
  78 +( 也可以使用 cardinality 。 cardinality 提供的事近似计数。 希望快速估算唯一值数量,应该使用 cardinality )
  79 +
  80 +见下面案例中的 aggs 中的 unique_count
  81 +
  82 +##### b) from不准
  83 +相关资料提示只是“深度分页时”不准,比如结果跟前面的页内内容重复。但是我试了一些请求,还没找到过重复的情况。
  84 +
  85 +并且,商品搜索因为有精排,只要请求的内容位于top1000,则会从ES获得top1000的所有结果,所以top1000内的内容不会有分页不准的问题。
  86 +
  87 +而对于工厂搜索,我测试了一些请求,也还没有发现分页内内容跟前面的页的内容重复的情况。
  88 +
  89 +所以ES内部实现的from已经是collapse之后的
  90 +
  91 +### 2. ES配置优化
  92 +
  93 +还有哪些要注意的。
  94 +
  95 +## 实际案例
  96 +
  97 +### 商品搜索实际案例(简化后)
  98 +
  99 +```json
  100 +GET /spu/_search
  101 +{
  102 + "_source": {
  103 + "includes": [
  104 + "name_zh"
  105 + ]
  106 + },
  107 + "aggs": {
  108 + "unique_count": {
  109 + "cardinality": {
  110 + "field": "goods_id"
  111 + }
  112 + },
  113 + "category_stats": {
  114 + "terms": {
  115 + "field": "sale_category_one_all",
  116 + "size": 10
  117 + }
  118 + },
  119 + "certification_stats": {
  120 + "terms": {
  121 + "field": "goods_certification_type_list",
  122 + "size": 10
  123 + }
  124 + },
  125 + "deliver_day_stats": {
  126 + "terms": {
  127 + "field": "deliver_day",
  128 + "size": 10
  129 + }
  130 + },
  131 + "label_stats": {
  132 + "terms": {
  133 + "field": "label_id_list",
  134 + "size": 10
  135 + }
  136 + },
  137 + "material_stats": {
  138 + "terms": {
  139 + "field": "goods_main_material",
  140 + "size": 10
  141 + }
  142 + },
  143 + "moq_stats": {
  144 + "terms": {
  145 + "field": "purchase_moq",
  146 + "size": 10
  147 + }
  148 + },
  149 + "package_lang_stats": {
  150 + "terms": {
  151 + "field": "goods_package_lang",
  152 + "size": 10
  153 + }
  154 + },
  155 + "package_type_stats": {
  156 + "terms": {
  157 + "field": "package_type",
  158 + "size": 10
  159 + }
  160 + },
  161 + "spu_attr_stats": {
  162 + "terms": {
  163 + "field": "attribute_option_list",
  164 + "size": 10
  165 + }
  166 + }
  167 + },
  168 + "collapse": {
  169 + "field": "goods_id"
  170 + },
  171 + "from": 0,
  172 + "query": {
  173 + "function_score": {
  174 + "boost_mode": "multiply",
  175 + "functions": [
  176 + {
  177 + "filter": {
  178 + "term": {
  179 + "label_id_list": 156
  180 + }
  181 + },
  182 + "weight": 1.1
  183 + },
  184 + {
  185 + "filter": {
  186 + "term": {
  187 + "is_video": true
  188 + }
  189 + },
  190 + "weight": 1.2
  191 + }
  192 + ],
  193 + "query": {
  194 + "bool": {
  195 + "filter": [
  196 + {
  197 + "term": {
  198 + "platform_sku_essaone": true
  199 + }
  200 + },
  201 + {
  202 + "term": {
  203 + "platform_rule_essaone": true
  204 + }
  205 + },
  206 + {
  207 + "bool": {
  208 + "should": [
  209 + {
  210 + "bool": {
  211 + "must_not": {
  212 + "exists": {
  213 + "field": "auth_level_list"
  214 + }
  215 + }
  216 + }
  217 + },
  218 + {
  219 + "term": {
  220 + "auth_level_list": "1"
  221 + }
  222 + }
  223 + ]
  224 + }
  225 + },
  226 + {
  227 + "terms": {
  228 + "status": [2,4,5]
  229 + }
  230 + },
  231 + {
  232 + "terms": {
  233 + "goods_copyright": ["1","2","3"]
  234 + }
  235 + }
  236 + ],
  237 + "must": [
  238 + {
  239 + "bool": {
  240 + "minimum_should_match": 1,
  241 + "should": [
  242 + {
  243 + "multi_match": {
  244 + "_name": "base_query",
  245 + "fields": [
  246 + "name_zh^2.0",
  247 + "goods_keyword_zh^1.0",
  248 + "category_name_zh^1.0",
  249 + "sale_category_keyword_zh^1.0",
  250 + "sub_name_zh^1.0"
  251 + ],
  252 + "minimum_should_match": "66%",
  253 + "query": "合金车",
  254 + "tie_breaker": 0.3
  255 + }
  256 + }
  257 + ]
  258 + }
  259 + }
  260 + ]
  261 + }
  262 + },
  263 + "score_mode": "max"
  264 + }
  265 + },
  266 + "size": 1000,
  267 + "track_scores": true
  268 +}
  269 +```
  270 +
  271 +### 工厂搜索实际案例(简化后)
  272 +
  273 +```json
  274 +GET /spu/_search
  275 +{
  276 + "_source": [
  277 + "id",
  278 + "goods_id",
  279 + "brand_id",
  280 + "name_zh"
  281 + ],
  282 + "aggs": {
  283 + "unique_count": {
  284 + "cardinality": {
  285 + "field": "brand_id"
  286 + }
  287 + },
  288 + "category_stats": {
  289 + "terms": {
  290 + "field": "sale_category_one_all",
  291 + "size": 10
  292 + }
  293 + },
  294 + "sale_market_stats": {
  295 + "terms": {
  296 + "field": "supplier_main_market_list",
  297 + "size": 10
  298 + }
  299 + }
  300 + },
  301 + "collapse": {
  302 + "field": "brand_id"
  303 + },
  304 + "from": 222,
  305 + "query": {
  306 + "bool": {
  307 + "filter": [
  308 + {
  309 + "term": {
  310 + "platform_sku_essaone": true
  311 + }
  312 + },
  313 + {
  314 + "term": {
  315 + "platform_rule_essaone": true
  316 + }
  317 + },
  318 + {
  319 + "bool": {
  320 + "should": [
  321 + {
  322 + "bool": {
  323 + "must_not": {
  324 + "exists": {
  325 + "field": "auth_level_list"
  326 + }
  327 + }
  328 + }
  329 + },
  330 + {
  331 + "term": {
  332 + "auth_level_list": "1"
  333 + }
  334 + }
  335 + ]
  336 + }
  337 + },
  338 + {
  339 + "terms": {
  340 + "status": [2,4,5]
  341 + }
  342 + },
  343 + {
  344 + "terms": {
  345 + "goods_copyright": [
  346 + "1",
  347 + "2",
  348 + "3"
  349 + ]
  350 + }
  351 + }
  352 + ],
  353 + "must": [
  354 + {
  355 + "bool": {
  356 + "minimum_should_match": 1,
  357 + "should": [
  358 + {
  359 + "multi_match": {
  360 + "fields": [
  361 + "brand_name_zh^10.0",
  362 + "name_zh^2.0",
  363 + "supplier_name^8.0"
  364 + ],
  365 + "minimum_should_match": "66%",
  366 + "query": "义乌市童吉拉",
  367 + "tie_breaker": 0.3
  368 + }
  369 + } ]
  370 + }
  371 + }
  372 + ]
  373 + }
  374 + },
  375 + "size": 20
  376 +}
  377 +```
  378 +
  379 +
  380 +### ES 索引配置方面,为提升查询性能,是否需要将副本数设置为1。
  381 +但是为了不影响写入性能,在每次全量前,先关闭副本,全量写入完成后再打开副本。
  382 +```json
  383 +PUT /spu_test/_settings
  384 +{
  385 + "number_of_replicas": 1
  386 +}
  387 +```
  388 +
  389 +
  390 +### 预热
  391 +2025/6/26 今天早上7点多一次查询(q=木质手工艺品玩具) ES查询阶段耗时20多秒,但是第二次查询就只要几百ms,改变query耗时也正常。
  392 +
  393 +
  394 +目前已经设置慢查询日志:
  395 +
  396 +PUT /spu,spu_test/_settings
  397 +{
  398 + "index.search.slowlog.threshold.query.warn": "10s",
  399 + "index.search.slowlog.threshold.query.info": "5s",
  400 + "index.search.slowlog.threshold.query.debug": "2s",
  401 + "index.search.slowlog.threshold.query.trace": "500ms",
  402 + "index.search.slowlog.threshold.fetch.warn": "1s",
  403 + "index.search.slowlog.threshold.fetch.info": "800ms",
  404 + "index.search.slowlog.threshold.fetch.debug": "500ms",
  405 + "index.search.slowlog.threshold.fetch.trace": "200ms"
  406 +}
  407 +
  408 +
  409 +PUT /spu,spu_test/_settings
  410 +{
  411 + "index.search.slowlog.threshold.query.warn": "1s",
  412 + "index.search.slowlog.threshold.query.info": "800ms",
  413 + "index.search.slowlog.threshold.query.debug": "600ms",
  414 + "index.search.slowlog.threshold.query.trace": "400ms",
  415 + "index.search.slowlog.threshold.fetch.warn": "500ms",
  416 + "index.search.slowlog.threshold.fetch.info": "400ms",
  417 + "index.search.slowlog.threshold.fetch.debug": "200ms",
  418 + "index.search.slowlog.threshold.fetch.trace": "100ms"
  419 +}
  420 +
  421 +动态调整日志级别 (无需重启)
  422 +通过集群设置 API 临时调整:
  423 +PUT /_cluster/settings
  424 +{
  425 + "transient": {
  426 + "logger.index.search.slowlog": "info"
  427 + }
  428 +}
  429 +
  430 +验证配置是否生效
  431 +GET /spu,spu_test/_settings?include_defaults=true&filter_path=**.slowlog
  432 +
  433 +日志文件
  434 +logs/<cluster_name>.log
  435 +
  436 +
  437 +
  438 +
  439 +## 慢查询记录
  440 +
  441 +
  442 +### 07/02 早上 7:45~7:47,100个里面又有8个超过1.5S的, 4个超过5S , 2个超过14S
  443 +
  444 +#### 8888888946992436
  445 +2025-07-02 07:45:32,092 - INFO - [REQ: 8888888946992436 UID: 10639] REQUEST POST structure: {"keyword":"плащ","kt":"kwd","page":1,"size":100,"request_id":8888888946992436,"extra":{"userId":10639,"businessPlatform":"essa"}}
  446 +
  447 +2025-07-02 07:45:46,981 - INFO - [REQ: 8888888946992436 UID: 10639] qt:kwd total:14.889394521713257ms TIMING: QA=46ms, queryEncoding=0ms, userProfile=1ms, ES=14824ms, BgeReranking=1ms, BizReranking=1ms, Reranking=2ms, total=14889ms, sku_id_list_filling=12ms
  448 +
  449 +2025-07-02 07:45:46,968 - INFO - [REQ: 8888888946992436 UID: 10639] ES_query_timing # ProductKeywordSearch # 14824.28 # {"size":1000,"from":0,"_source":{"includes":["name_zh","is_star","category_name_zh","sub_name_zh","label_id_list","is_video","brand_id","category_id","sale_category_all","price_range","on_sell_days_boost","ru_name"]},"query":{"function_score":{"query":{"bool":{"must":[{"bool":{"should":[{"multi_match":{"query":"плащ","fields":["name_ru^2.0","goods_keyword_ru^1.0","category_name_ru^1.0","sale_category_keyword_ru^1.0","sub_name_ru^1.0"],"minimum_should_match":"66%","tie_breaker":0.3,"_name":"base_query"}},{"knn":{"field":"embedding_name_ru","query_vector":[-0.035206761211156845,0.020660383626818657,-0.04898383840918541,0.01842888817191124,-0.059921182692050934,-0.013516250066459179,0.003757030935958028,0.014033733867108822,-0.027964092791080475,0.01029364112764597,-0.00787576287984848,0.02625346928834915,-0.01542199682444334,0.026301803067326546,0.052108507603406906,-0.050406284630298615,0.00483988830819726,0.04060962051153183,0.009472930803894997,-0.0005112694925628603,0.004651694558560848,0.0034800730645656586,0.018641093745827675,0.029394179582595825,0.020360751077532768,0.001675301929935813,-0.005129559896886349,-0.000619593309238553,-0.04827551171183586,-0.00630217557772994,0.020039061084389687,0.018405847251415253,0.034706272184848785,-0.08860606700181961,-0.04726770892739296,-0.032688140869140625,-0.018302561715245247,0.011481991037726402,-0.046269889920949936,0.014546985737979412,0.003089814679697156,0.010171250440180302,-0.011071375571191311,-0.01992928236722946,0.021175755187869072,0.01124000083655119,0.0372454971075058,-0.034685004502534866,-0.01343931071460247,0.02121714875102043,-0.023612814024090767,0.03798554837703705,0.06504618376493454,-0.009450038895010948,0.005906036589294672,0.030142072588205338,-0.03246299922466278,-0.030096540227532387,-0.0849074274301529,-0.020739320665597916,-0.03408554196357727,-0.0029811616986989975,-0.023305756971240044,0.027784742414951324,0.04067830741405487,0.109839528799057,-0.0005762992077507079,0.018221285194158554,-0.007281845901161432,-0.04129931703209877,-0.04749192297458649,-0.0005632156971842051,0.0058455271646380424,-0.004661038983613253,-0.05732613801956177,0.007009096443653107,0.05625062435865402,-0.025481490418314934,0.013432115316390991,0.005354376044124365,0.048216819763183594,-0.010861121118068695,0.0279295165091753,0.001105348696000874,-0.015214173123240471,-0.013066167943179607,-0.05451373755931854,0.004907973110675812,-0.041388705372810364,0.011942931450903416,0.025908607989549637,-0.004652232397347689,0.011163195595145226,-0.056879933923482895,-0.029385222122073174,0.005944914650171995,0.010291633196175098,0.009789329022169113,0.04474876821041107,0.009474224410951138,0.019974328577518463,-0.012655979953706264,-0.020499292761087418,-0.015026221051812172,0.031605109572410583,-0.026804130524396896,0.023546280339360237,0.055264607071876526,0.04840846732258797,-0.018858103081583977,0.004723322577774525,-0.01294822245836258,0.0012377514503896236,0.01827247440814972,0.025621123611927032,-0.023270349949598312,-0.014992653392255306,0.01914968341588974,0.015052393078804016,-0.013205647468566895,0.0169048048555851,0.004617445170879364,0.016027752310037613,-0.01378362812101841,-0.012757807970046997,-0.0346602164208889,-0.015302776359021664,-0.028003660961985588,0.0269561018794775,0.0047284201718866825,0.02838684618473053,0.03655833378434181,-0.01723506674170494,-0.005107777193188667,0.00955332349985838,-0.028216000646352768,0.022160036489367485,-0.011552958749234676,0.0027140516322106123,-0.06404043734073639,0.03287180885672569,0.06553228199481964,-0.03408421576023102,-0.01947455108165741,0.01903623901307583,-0.030194343999028206,0.08181223273277283,-0.001817873097024858,-0.013434878550469875,0.01553320698440075,0.008037151768803596,-0.0016663833521306515,0.061162009835243225,0.002955813892185688,0.031158601865172386,-0.015486419200897217,-0.023676788434386253,0.01596381515264511,0.013413977809250355,0.003498759353533387,-0.014206847175955772,0.06292533874511719,-0.005962688941508532,-0.010250173509120941,0.010891546495258808,-0.06812363117933273,0.019118888303637505,0.0033251780550926924,-0.011573049239814281,-0.019931120797991753,0.025516562163829803,-0.030447019264101982,0.02210240252315998,0.0037979227490723133,0.01469342689961195,0.010654212906956673,0.05843355879187584,0.010645532049238682,0.04514821618795395,-0.05915722995996475,-0.03231963887810707,-0.0037186243571341038,-0.015574388206005096,-0.053289689123630524,-0.062142301350831985,0.032532062381505966,-0.004566668067127466,-0.0005688689998351038,0.012460852973163128,-0.0002137328847311437,-0.03864103928208351,-0.053204890340566635,-0.003222765401005745,-0.0375785157084465,0.013661065138876438,0.036554817110300064,-0.005308432504534721,-0.021835779771208763,0.01610834337770939,-0.024434847757220268,0.019568176940083504,0.021495573222637177,0.027674177661538124,0.012535114772617817,-0.030019603669643402,-0.0057942504063248634,-0.028912071138620377,-0.017957061529159546,0.061209600418806076,-0.022746963426470757,0.004394537769258022,0.03157713636755943,-0.007674273569136858,0.0009010087815113366,-0.027206333354115486,-0.012480284087359905,-0.0025779965799301863,0.051328953355550766,0.01902339980006218,0.013034356757998466,-0.006923840846866369,-0.01160359662026167,0.021379830315709114,0.03169575333595276,0.040882863104343414,-0.0033913704100996256,0.01899077370762825,0.08345057815313339,-0.010554501786828041,-0.03491298854351044,-0.057687703520059586,0.04501834139227867,-0.008133002556860447,-0.02618131972849369,-0.029568562284111977,0.002545944880694151,-0.001665174262598157,0.03253322094678879,0.0024745927657932043,-0.006849205121397972,-0.05318983271718025,-0.025619570165872574,0.014735052362084389,0.02763821743428707,-0.007577501703053713,0.0063603585585951805,-0.00365810701623559,0.025731217116117477,0.03233180195093155,-0.022458139806985855,0.024351079016923904,0.011603618040680885,-0.03997845575213432,-0.043126173317432404,0.024063793942332268,0.0016773768002167344,0.04188883677124977,-0.009149405173957348,-0.01712734065949917,-0.001971685793250799,0.007741072215139866,0.030701320618391037,-0.02069244161248207,0.03917993977665901,0.023362010717391968,-0.05359603092074394,-0.07414817065000534,0.04290693253278732,0.025545785203576088,-0.023132413625717163,-0.029064863920211792,-0.018788963556289673,-0.0072210486978292465,-0.021664045751094818,-0.02780369482934475,0.010197662748396397,-0.029631970450282097,-0.06248059496283531,0.056149572134017944,0.03446534276008606,0.012978330254554749,0.020114615559577942,0.014626489952206612,0.0014688351657241583,0.007488865405321121,0.0018029020866379142,-0.026877358555793762,-0.05628906562924385,0.023198025301098824,-0.05422384664416313,-0.018185559660196304,-0.016266608610749245,0.07812158763408661,0.014885681681334972,-0.03208523988723755,0.024400467053055763,-0.023752763867378235,-0.14391297101974487,0.013684358447790146,-0.00910066906362772,-0.003774787997826934,0.002778866793960333,-0.007355159148573875,-0.049925338476896286,0.0068326424807310104,-0.015949470922350883,0.04995362088084221,0.02202575094997883,-0.050666406750679016,-0.017593706026673317,0.005538220517337322,0.010944854468107224,0.00591089203953743,-0.03195786848664284,-0.0350082665681839,0.04533974826335907,-0.04418160021305084,-0.058949049562215805,-0.024030668660998344,0.06094866618514061,0.006638273596763611,-0.011429576203227043,0.028663814067840576,-0.018866879865527153,-0.01470297109335661,-0.07419563084840775,-0.0006075186538510025,-0.01832914724946022,0.055656205862760544,-0.005896612536162138,0.06476810574531555,-0.002154070418328047,0.039329275488853455,0.03643323481082916,0.02897184155881405,0.012239593081176281,-0.013209196738898754,0.01667504385113716,-0.020171934738755226,-0.007978314533829689,0.002015035366639495,0.0060122255235910416,-0.0005796809564344585,-0.022573299705982208,0.010048048570752144,-0.028690429404377937,-0.0049275285564363,0.011733840219676495,-0.027727371081709862,0.00846127886325121,-0.012962596490979195,-0.018655503168702126,-0.004388416651636362,-0.0027830314356833696,0.021990278735756874,-0.010932429693639278,0.055302660912275314,-0.02620832622051239,-0.01626540906727314,0.022029872983694077,0.041417475789785385,-0.018135935068130493,0.023432670161128044,-0.014476905576884747,-0.021904973313212395,0.05106840282678604,-0.009241272695362568,0.008491065353155136,-0.009605452418327332,-0.010890216566622257,-0.020538344979286194,-0.03786062076687813,-0.018376335501670837,0.005948869977146387,-0.022558849304914474,-0.029248986393213272,-0.09795139729976654,0.0022951881401240826,-0.02722097747027874,-0.02994513511657715,0.02718617580831051,0.010087048634886742,-0.03410033509135246,0.006080645136535168,0.04884191229939461,0.022310344502329826,0.23470163345336914,0.05436817556619644,0.015961380675435066,-0.003585796570405364,0.04928544908761978,-0.015531239099800587,-0.03634936735033989,0.013561204075813293,-0.0127008818089962,-0.04123814404010773,0.04028059169650078,-0.022995449602603912,-0.05858377367258072,-0.025912167504429817,0.002051947871223092,0.028178082779049873,-0.024679195135831833,-0.033295053988695145,0.057560041546821594,0.012898346409201622,-0.001159863779321313,-0.05980786308646202,-0.009578239172697067,-0.006334761623293161,0.008928714320063591,-0.023135699331760406,-0.020989403128623962,0.03972852602601051,-0.0281743835657835,-0.0030933714006096125,-0.030967606231570244,-0.023228729143738747,0.04275300353765488,-0.003396248444914818,-0.021202215924859047,-0.036934223026037216,0.002650831826031208,-0.027669982984662056,-0.02926342748105526,0.023184143006801605,-0.03600231930613518,-0.04196419566869736,0.028035933151841164,-0.012389490380883217,-0.025327419862151146,0.004440063610672951,0.02531650848686695,0.006087713409215212,-0.010013606399297714,0.0007868186803534627,0.01828184723854065,-0.04047589749097824,-0.01882169395685196,0.01670665293931961,-0.0018401563866063952,-0.06178411841392517,-0.004959224723279476,-0.009559997357428074,-0.03630327060818672,0.019544923678040504,0.03323837369680405,0.0019047134555876255,-0.055654801428318024,0.0120793916285038,0.024345638230443,0.04413655027747154,0.038333743810653687,-0.03837909549474716,0.036039143800735474,0.03441465646028519,-0.025983402505517006,0.020418977364897728,0.0023564579896628857,-0.03032052516937256,0.008935485035181046,-0.002342129359021783,-0.023637691512703896,0.04967671260237694,0.0023628254421055317,0.017998643219470978,-0.013052172027528286,-0.020086176693439484,-0.021621353924274445,0.01856628805398941,-0.004594834987074137,5.3746927733300254e-05,0.02068163827061653,0.011181456036865711,0.004704579710960388,-0.06800582259893417,-0.025769870728254318,0.031559403985738754,-0.03243835270404816,-0.042171161621809006,-0.033968374133110046,-0.028492704033851624,0.030332721769809723,0.013217239640653133,-0.05065273120999336,0.0012672850862145424,0.01903768628835678,-0.01986546255648136,-0.0302716176956892,-0.046229422092437744,0.012420049868524075,-0.057180698961019516,0.011192794889211655,-0.011805238202214241,-0.009777616709470749,0.027752839028835297,0.009869647212326527,0.022393478080630302,-0.014004047028720379,-0.03816772252321243,0.02939590811729431,-0.022599423304200172,0.06637869030237198,0.0007234956719912589,0.04250507056713104,0.01874270848929882,-0.034795913845300674,-0.03439943492412567,-0.012029746547341347,-0.026585975661873817,-0.02341972105205059,-0.08398526161909103,-0.001064875046722591,0.010337086394429207,-0.027291441336274147,0.04357384517788887,-0.022910315543413162,-0.028094787150621414,-0.058925777673721313,0.03177836537361145,0.06688185781240463,-0.007260899059474468,0.07961610704660416,0.01818729378283024,0.04384874179959297,0.0069672237150371075,-0.03676052391529083,-0.026600651443004608,-0.009718179702758789,0.02413475140929222,0.002316404366865754,0.013218769803643227,0.025685036554932594,-0.0267532616853714,-0.0005175225087441504,0.008881115354597569,0.00849118735641241,0.021110543981194496,0.01012480165809393,-0.04864375665783882,0.026049554347991943,-0.033437345176935196,0.01862046681344509,0.015985814854502678,-0.04058758541941643,-0.034810714423656464,0.002337781013920903,0.023734498769044876,0.01936843805015087,0.024209536612033844,-0.011239565908908844,0.004950506146997213,0.02515280991792679,0.031176459044218063,-0.007186027243733406,-0.06590321660041809,-0.01442632731050253,-0.03848455473780632,-0.05621578171849251,0.021169142797589302,0.0638895109295845,0.014107379131019115,-0.001493399846367538,-0.0025435914285480976,-0.006533127278089523,-0.03929860144853592,0.026615334674715996,-0.04061077907681465,0.018028495833277702,-0.01668223924934864,-0.0038626976311206818,0.026101356372237206,-0.03197198361158371,-0.0065635270439088345,0.0019417291041463614,-0.0024077303241938353,0.009724567644298077,0.12885814905166626,-0.042364951223134995,-0.015280397608876228,0.0021025585010647774,0.005213343538343906,0.028361251577734947,0.008384518325328827,-0.005955472122877836,-0.025096453726291656,-0.020202528685331345,-0.06277716904878616,0.0037493319250643253,-0.011746613308787346,-0.009712602011859417,0.011140778660774231,0.013527371920645237,0.021172339096665382,-0.003329736879095435,-0.005730032920837402,0.015588180162012577,-0.01058022491633892,-0.061124950647354126,-0.027063122019171715,0.011708902195096016,-0.037272900342941284,0.04661867022514343,0.051509588956832886,-0.032604824751615524,-0.01939493976533413,-0.04458850622177124,-0.025845350697636604,0.08357544243335724,-0.03925212100148201,0.02475445531308651,0.001424501882866025,0.036441098898649216,-0.0008853881736285985,-0.0065232799388468266,-0.008607328869402409,0.0036739481147378683,0.013437087647616863,-0.0005483806598931551,0.013671726919710636,-0.010975610464811325,0.0252169668674469,0.004811613820493221,0.03503024950623512,0.008273469284176826,-0.04754671826958656,-0.0032335694413632154,-0.020629990845918655,0.020103249698877335,0.05603678897023201,-0.009146715514361858,0.047989606857299805,-0.02159910649061203,-0.008421017788350582,0.06128425896167755,0.029185334220528603,-0.013512684032320976,0.022962575778365135,0.01999785378575325,-0.030678022652864456,0.012006080709397793,0.02959463745355606,0.033092010766267776,-0.015923049300909042,-0.009248358197510242,-0.002102521015331149,0.0006527969962917268,0.05228109285235405,-0.011770941317081451,0.03377839922904968,0.0016989668365567923,-0.049906544387340546,0.01880759932100773,-0.0570840910077095,-0.004508663900196552,-0.012727982364594936,-0.009242513217031956,-0.003627593396231532,-0.02874729037284851,-0.004071712028235197,0.0028062432538717985,0.011863901279866695,0.013188064098358154,0.004998673684895039,0.02011021599173546,0.0007077555055730045,-0.034099280834198,-0.008439776487648487,-0.041815366595983505,-0.02208874374628067,0.004590209573507309,-0.005805503576993942,0.023512832820415497,0.027854664251208305,0.027635710313916206,-0.030326588079333305,-0.02209583669900894,-0.02466949261724949,-0.03720000013709068,0.04560352489352226,-0.00042570539517328143,-0.02821272797882557,-0.0056007071398198605,0.0023014284670352936,-0.013366803526878357,-0.014828696846961975,-0.02920413762331009,-0.0011925845174118876,-0.048540111631155014,-0.021844858303666115,-0.03979949280619621,0.04372791945934296,0.008035936392843723,-0.057898178696632385,-0.013198129832744598,0.04429883509874344,0.0064583527855575085,0.03409983962774277,0.013824653811752796,0.009123317897319794,0.025508053600788116,0.008969003334641457,0.03677615150809288,0.008993231691420078,-0.02603071555495262,0.030776629224419594,0.012125672772526741,0.0314396433532238,-0.011129194870591164,0.043794889003038406,-2.519373083487153e-05,-0.01874178647994995,0.005505834240466356,-0.018103158101439476,-0.01456343661993742,-0.04242011159658432,-0.00860234722495079,-0.006875118240714073,-0.003689249511808157,-0.035918280482292175,-0.005150370299816132,0.02011486329138279,0.038744986057281494,-0.025435179471969604,-0.033850330859422684,0.04369243234395981,0.010407148860394955,0.0490582212805748,0.044982362538576126,-0.02326131798326969,0.03907119110226631,0.013851706869900227,0.0053246659226715565,0.02681494876742363,-0.021451245993375778,-0.011437231674790382,-0.022223282605409622,0.03694619610905647,0.010058378800749779,-0.020366022363305092,0.027209483087062836,0.020124191418290138,-0.014966033399105072,-0.011139456182718277,0.0030029986519366503,-0.003157819854095578,-0.07452484965324402,0.045879751443862915,-0.07768410444259644,-0.023344967514276505,-0.016970690339803696,0.03432521969079971,-0.00745960371568799,-0.04227651655673981,0.03599528595805168,-0.005419539287686348,-0.007087036035954952,0.0005111709469929338,-0.017311006784439087,-0.03848304599523544,-0.010792597196996212,0.03584851697087288,-0.017352934926748276,-0.009887761436402798,0.030739745125174522,0.0006348391762003303,0.01315715629607439,0.03991811349987984,-4.012811405118555e-05,-0.04894297942519188,0.02184920944273472,-0.002984777092933655,-0.03397710993885994,-0.0006168143008835614,0.0389326773583889,0.019963927567005157,-0.035813018679618835,-0.0035148810129612684,-0.036282654851675034,0.02323351800441742,-0.14055253565311432,-0.0011770421406254172,-0.0007910575368441641,-0.009185176342725754,-0.03751031681895256,0.018624840304255486,-0.018372859805822372,-0.05124770477414131,0.00702853687107563,0.0005150049109943211,-0.05871395766735077,-0.014960653148591518,-0.012675967067480087,-0.058344099670648575,0.051571477204561234,0.04626207798719406,0.017907535657286644,-0.012606747448444366,0.00027081245207227767,0.05110858753323555,0.0063804262317717075,-0.015924256294965744,0.05612455680966377,0.005842928774654865,0.0006801928975619376,-0.026026280596852303,0.0050106649287045,0.007201412692666054,-0.05329363793134689,-0.0049592116847634315,0.021987589076161385,-0.048969246447086334,0.04041697084903717,0.05320906266570091,0.05194704607129097,0.01754378341138363,0.030775057151913643,-0.034510236233472824,0.0018061174778267741,0.01754835620522499,0.005041847005486488,0.022270090878009796,-0.03055517002940178,-0.00565745634958148,0.008246875368058681,0.04205388203263283,0.03508912771940231,-0.02427177131175995,-0.0056594498455524445,-0.0029881615191698074,0.02105557732284069,0.03583899140357971,0.010291791521012783,0.034741733223199844,0.05260966345667839,-0.054904673248529434,-0.020404748618602753,-0.004062421154230833,-0.019812684506177902,0.07352986931800842,-0.005233615171164274,0.002713999478146434,-0.015773078426718712,-0.11096750944852829,-0.025007858872413635,0.013125421479344368,-0.050285711884498596,0.0074223908595740795,0.016822388395667076,0.007340242154896259,-0.0060745421797037125,-0.04604845866560936,0.00123889883980155,-0.03444620966911316,0.00013031024718657136,0.008668433874845505,0.02411758340895176,-0.006479873321950436,-0.027701428160071373,-0.0237407423555851,-0.023862380534410477,0.00860349740833044,0.00012163886276539415,0.01104400772601366,-0.0016930673737078905,-0.0050847833044826984,-0.033998653292655945,0.04723867028951645,-0.039987944066524506,-0.018954621627926826,-0.013241901993751526,-0.028065815567970276,-0.008029542863368988,-0.03646733984351158,0.021735386922955513,0.021358124911785126,-0.0015480235451832414,0.013069476000964642,0.010266493074595928,-0.021802479401230812,0.001115710474550724,-0.022975051775574684,-0.012441503815352917,0.0010741831501945853,-0.037787165492773056,0.04443914443254471,0.04280896112322807,-0.01951548084616661,0.0206343624740839,-0.017379995435476303,-0.012229197658598423,0.0359145924448967,0.009906494989991188,0.03398154303431511,-0.054867222905159,-0.034222718328237534,0.027639850974082947,0.017935309559106827,-0.016600653529167175,0.04243488237261772,-0.011090008541941643,-0.0012337255757302046,0.02144838124513626,-0.04755748063325882,0.028430253267288208,0.03696008399128914,0.036666389554739,0.0034356049727648497,0.00029432112933136523,0.026047931984066963,0.026443278416991234,-0.017619002610445023,0.0034682732075452805,0.019300302490592003,0.03479965403676033,-0.016898181289434433,-0.0025240853428840637,0.05310631915926933,-0.007292068097740412,-0.008197016082704067,-0.010833573527634144,-0.0020867902785539627,0.0006007178453728557,-0.031240833923220634,-0.06258007138967514,-0.01165976095944643,-0.01575843244791031,0.008870338089764118,-0.0609193854033947,-0.03396580368280411,0.03464129939675331,-0.018931003287434578,0.016385870054364204,-0.00834841188043356,0.006441039498895407,0.02742983028292656,-0.02848666161298752,0.01015631202608347,0.02084996923804283,0.02939058467745781,0.0029071224853396416,0.0010421921033412218,-0.01346229575574398,0.010960790328681469,-0.01781773753464222,0.0054703461937606335,-0.00636809878051281,-0.030618872493505478,-0.0607629157602787,0.012134232558310032,-0.03560594469308853,0.014712122268974781,-0.02917938120663166,0.024105576798319817,0.04104112461209297,-0.017275553196668625,0.01021703239530325,-0.031021486967802048,0.07045310735702515,-0.02664598636329174,0.012743153609335423,-0.03889269381761551,-0.002920081838965416,0.015536080114543438,0.036099497228860855,0.02382378838956356,0.0014643787872046232,0.04115711897611618,0.004802360199391842,0.03452477231621742,0.035297833383083344,0.026000341400504112,0.051612429320812225,-0.01692250370979309,0.043301522731781006,0.04238201677799225,-0.013184351846575737,0.019781772047281265,-0.02296600304543972,0.0025291864294558764,0.011808125302195549,0.019398607313632965,-0.048333581537008286,-0.018061719834804535,-0.014784661121666431,-0.025583477690815926,-0.027409924194216728,0.01769193634390831,0.0412142239511013,0.010857541114091873,-0.008557923138141632,-0.00978132989257574,-0.009291511960327625,0.029456451535224915,-0.021604234352707863,-0.04070386663079262,0.016536498442292213,0.021561020985245705,-0.02611173316836357,0.03573843836784363,-0.001385204028338194,0.05891196429729462,-0.056763920933008194,-0.00040730182081460953,-0.039218366146087646,0.006287450436502695,-0.017032165080308914,0.009427487850189209,-0.002574730897322297,-0.005260271020233631,0.036468323320150375,0.02548493631184101,0.0020035214256495237,0.04824838414788246,0.030447717756032944,-0.044185418635606766,0.013747095130383968,-0.015019798651337624,-0.03475117310881615,-0.03381308913230896,0.034938208758831024,0.0029158841352909803,0.01635667309165001,0.0012723793042823672],"k":600,"num_candidates":800,"_name":"knn_query"}}],"minimum_should_match":1}}],"filter":[{"term":{"platform_sku_essa":true}},{"term":{"platform_rule_essa":true}},{"terms":{"status":[2,4,5]}}]}},"functions":[{"filter":{"term":{"label_id_list":156}},"weight":1.14},{"filter":{"term":{"label_id_list":157}},"weight":1.13},{"filter":{"term":{"label_id_list":158}},"weight":1.1},{"filter":{"term":{"label_id_list":159}},"weight":1.1},{"filter":{"term":{"label_id_list":162}},"weight":1.05},{"filter":{"term":{"label_id_list":163}},"weight":1.1},{"filter":{"term":{"label_id_list":164}},"weight":1.13},{"filter":{"term":{"label_id_list":165}},"weight":1.15},{"field_value_factor":{"field":"on_sell_days_boost","missing":1.0}},{"filter":{"term":{"is_video":true}},"weight":1.2}],"score_mode":"max","boost_mode":"multiply"}},"track_scores":true,"collapse":{"field":"goods_id"},"aggs":{"unique_count":{"cardinality":{"field":"goods_id"}}}}
  450 +
  451 +
  452 +
  453 +#### 8888886761383165
  454 +
  455 +2025-07-02 07:46:00,929 - INFO - [REQ: 8888886761383165 UID: 15852] qt:kwd_factory total:5.89747166633606ms TIMING: QA=73ms, queryEncoding=28ms, userProfile=1ms, ES=190ms, BgeReranking=0ms, BizReranking=0ms, Reranking=0ms, total=5897ms, brand_statistics_query=5631ms
  456 +
  457 +2025-07-02 07:45:55,032 - INFO - [REQ: 8888886761383165 UID: 15852] REQUEST POST structure: {"keyword":"Double E","kt":"kwd_factory","page":1,"size":100,"request_id":8888886761383165,"extra":{"userId":15852,"businessPlatform":"essaone"}}
  458 +
  459 +2025-07-02 07:45:55,297 - INFO - [REQ: 8888886761383165 UID: 15852] ES_query_timing # FactoryKeywordSearch # 190.35 # {"query":{"bool":{"must":[{"bool":{"should":[{"multi_match":{"query":"Double E","fields":["brand_name_en^10.0","name_en^2.0","supplier_name^8.0"],"minimum_should_match":"66%","tie_breaker":0.3}},{"term":{"no":{"value":"Double E","boost":15.0}}},{"term":{"hs_no":{"value":"Double E","boost":15.0}}},{"term":{"factory_no":{"value":"Double E","boost":15.0}}},{"term":{"factory_no_buyer":{"value":"Double E","boost":15.0}}},{"term":{"supplier_code":{"value":"Double E","boost":15.0}}},{"match":{"factory_no_fuzzy":{"query":"Double E","boost":5.0}}},{"match":{"factory_no_buyer_fuzzy":{"query":"Double E","boost":5.0}}}],"minimum_should_match":1}}],"filter":[{"term":{"platform_sku_essaone":true}},{"term":{"platform_rule_essaone":true}},{"terms":{"status":[2,4,5]}}]}},"_source":["id","goods_id","brand_id","name_zh","category_name_zh","sub_name_zh","label_id_list","category_id","price_range","on_sell_days_boost","brand_name_zh","supplier_name","is_video"],"from":0,"size":100,"collapse":{"field":"brand_id"},"aggs":{"category_stats":{"terms":{"field":"sale_category_one_all","size":10}},"factory_certification_stats":{"terms":{"field":"supplier_certification_type_list","size":10}},"sale_market_stats":{"terms":{"field":"supplier_main_market_list","size":10}},"factory_category_stats":{"terms":{"field":"supplier_main_category_list","size":10}},"unique_count":{"cardinality":{"field":"brand_id"}}}}
  460 +
  461 +#### 8888886160313555
  462 +2025-07-02 07:45:52,314 - INFO - [REQ: 8888886160313555 UID: 16341] qt:kwd total:5.246635437011719ms TIMING: QA=54ms, queryEncoding=0ms, userProfile=1ms, ES=5082ms, BgeReranking=3ms, BizReranking=5ms, Reranking=11ms, total=5247ms, sku_id_list_filling=91ms
  463 +
  464 +2025-07-02 07:45:47,067 - INFO - [REQ: 8888886160313555 UID: 16341] REQUEST POST structure: {"keyword":"домик для игр","kt":"kwd","page":1,"size":100,"request_id":8888886160313555,"extra":{"userId":16341,"businessPlatform":"essa"}}
  465 +
  466 +2025-07-02 07:45:52,222 - INFO - [REQ: 8888886160313555 UID: 16341] ES_query_timing # ProductKeywordSearch # 5082.04 # {"size":1000,"from":0,"_source":{"includes":["name_zh","is_star","category_name_zh","sub_name_zh","label_id_list","is_video","brand_id","category_id","sale_category_all","price_range","on_sell_days_boost","ru_name"]},"query":{"function_score":{"query":{"bool":{"must":[{"bool":{"should":[{"multi_match":{"query":"домик для игр","fields":["name_ru^2.0","goods_keyword_ru^1.0","category_name_ru^1.0","sale_category_keyword_ru^1.0","sub_name_ru^1.0"],"minimum_should_match":"66%","tie_breaker":0.3,"_name":"base_query"}},{"knn":{"field":"embedding_name_ru","query_vector":[-0.010469888336956501,-0.009433825500309467,-0.061066463589668274,0.015439781360328197,-0.04887380078434944,-0.025594189763069153,0.02132314071059227,0.0048728156834840775,-0.024967197328805923,-0.016300074756145477,0.026881838217377663,0.02839415892958641,-0.04787887632846832,0.008348211646080017,0.02851884812116623,-0.020819339901208878,0.03223418444395065,0.022767407819628716,0.03298615664243698,-0.02291654795408249,0.007127368822693825,0.0026097544468939304,0.03312079608440399,0.030420035123825073,0.0018665859242901206,-0.007431185804307461,0.017863251268863678,-0.001749506569467485,-0.014798518270254135,-0.01667628437280655,0.024006366729736328,-0.0035607542376965284,-0.005410423967987299,-0.051832519471645355,-0.035944465547800064,-0.021218450739979744,-0.010114893317222595,-0.028079111129045486,-0.0533841997385025,0.04635569453239441,-0.0012162572238594294,0.0279274620115757,-0.004270642530173063,-0.033846378326416016,0.029734719544649124,-0.029220541939139366,0.04269053414463997,-0.022250592708587646,-0.051402684301137924,0.00989573448896408,-0.04305187985301018,0.01834198832511902,0.047379374504089355,-0.02046145871281624,0.020443573594093323,0.054781723767519,-0.01415993645787239,-0.03219226747751236,-0.043012600392103195,-0.007893793284893036,-0.01194281131029129,-0.020178208127617836,-0.0457143560051918,0.03828400745987892,0.021164067089557648,0.0818348154425621,0.031024565920233727,0.02610183134675026,-0.023838410153985023,-0.03643917664885521,-0.04240600764751434,-0.013539587147533894,-0.033422503620386124,-0.023028532043099403,-0.03987479954957962,0.037250813096761703,0.020570218563079834,-0.03727980703115463,-0.021551992744207382,0.008813940919935703,0.013401217758655548,-0.03705735504627228,0.03132335841655731,0.013271518982946873,-0.04067348316311836,-0.025765778496861458,-0.018480906262993813,0.0351085290312767,0.01488423254340887,-0.0028665210120379925,0.009210212156176567,-0.0050658416002988815,0.030113283544778824,-0.04046862572431564,-0.026331497356295586,-0.011537943966686726,0.024856189265847206,-0.003682077629491687,0.026156049221754074,0.024270538240671158,0.006325250957161188,-0.009220371022820473,-0.030239824205636978,-0.01933831162750721,0.005819987040013075,-0.02187834493815899,0.005806083790957928,0.03514980152249336,0.005680521950125694,0.0015755404019728303,0.018678558990359306,0.01218269020318985,0.005215473007410765,0.006414385512471199,0.009669029153883457,-0.03394971787929535,-0.01018771342933178,0.012081903405487537,-0.011565321125090122,0.017589492723345757,0.03712606802582741,0.014796657487750053,0.03933378681540489,-0.008113304153084755,0.006041175685822964,0.03321465477347374,-0.019459377974271774,0.0314057394862175,-0.0029240089934319258,0.0013709934428334236,0.028914669528603554,0.06471606343984604,0.007002886850386858,-0.012658798135817051,-0.04317999258637428,-0.01186620444059372,-0.0003211218863725662,0.020922966301441193,-0.003911396488547325,-0.053643420338630676,0.0021015468519181013,0.047227781265974045,-0.00348144443705678,-0.036834292113780975,0.03750087320804596,-0.008714203722774982,0.024695945903658867,-0.003665439784526825,-0.02675502561032772,-0.022107955068349838,-0.011632490903139114,0.020526042208075523,0.02676335908472538,0.03569071739912033,0.017682095989584923,-0.01834474503993988,0.0018101560417562723,0.0283984262496233,0.05491636320948601,0.003809621324762702,0.0006344207795336843,-0.02211061678826809,0.004625074565410614,0.020883994176983833,0.00015821929264348,-0.02832794189453125,0.0008159314747899771,0.0272744819521904,-0.027715962380170822,-0.02472168765962124,-0.016808174550533295,-0.05462613329291344,0.01775122433900833,0.014273782260715961,0.0008496608934365213,0.008177808485925198,0.0421871617436409,0.0045638978481292725,0.042220886796712875,-0.06000344827771187,-0.015377563424408436,0.011407480575144291,-0.03646248206496239,-0.01713411509990692,-0.04549218714237213,0.008391285315155983,0.002547923941165209,0.003514634445309639,-7.575080962851644e-05,0.027596233412623405,-0.03235990181565285,-0.02061750926077366,0.026209574192762375,-0.027568824589252472,0.045371562242507935,0.005951724015176296,-0.00968377199023962,-0.021565992385149002,0.013237068429589272,-0.013479852117598057,-0.0017748709069564939,0.014049606397747993,0.05706736817955971,-0.004590840544551611,-0.004989347420632839,-0.029409339651465416,-0.010748337022960186,-0.034739598631858826,0.046425726264715195,-0.04140014201402664,0.002544855233281851,0.036837805062532425,-0.037906888872385025,0.0013478754553943872,-0.041077353060245514,-0.03370291367173195,-0.018066709861159325,-0.016500622034072876,-0.010342623107135296,0.006782337557524443,-0.007797015365213156,0.011681020259857178,0.03112754039466381,0.04650038108229637,0.03888101875782013,-0.0280715674161911,0.05207274481654167,0.09879706799983978,0.02158382348716259,0.027143163606524467,-0.04732990637421608,-0.0010990563314408064,-0.02125970833003521,-0.059333719313144684,0.003452498698607087,0.009645221754908562,-0.010461045429110527,-0.006256204564124346,0.006562483962625265,-0.012693407014012337,-0.041277870535850525,-0.03793799504637718,0.009225663729012012,0.014676553197205067,-0.029448574408888817,0.019804179668426514,0.0010417350567877293,0.034564901143312454,-0.006257682107388973,-0.026684997603297234,-0.047370005398988724,-0.013308132067322731,-0.026585856452584267,-0.014774832874536514,0.013124870136380196,0.010718361474573612,-0.01895284280180931,-0.006912903394550085,-0.006600252352654934,-0.01494550984352827,0.035866040736436844,0.0033980663865804672,-0.016810467466711998,0.038974154740571976,0.061462365090847015,-0.03711969032883644,-0.04634862393140793,0.007261885795742273,0.04931870102882385,-0.008722336031496525,-0.0410168282687664,0.005162227898836136,0.010419916361570358,-0.04338258504867554,-0.0035620471462607384,-0.029630742967128754,0.0004580442910082638,-0.04241163656115532,0.04071682319045067,0.00014105312584433705,0.016499493271112442,0.015219377353787422,0.03846654295921326,0.008888534270226955,0.011078225448727608,0.034640733152627945,0.02468424290418625,-0.02980225533246994,0.03709685429930687,-0.04838785156607628,-0.022547060623764992,-0.04328358918428421,0.0513724759221077,0.020648853853344917,-0.01620667055249214,-0.0037202714011073112,-0.03920559957623482,-0.14737793803215027,-0.015798239037394524,0.009418384172022343,0.029613904654979706,0.010793381370604038,-0.01496070995926857,-0.06054462119936943,0.02468664012849331,-0.006591952871531248,0.0889967605471611,-0.005320643074810505,-0.05315868929028511,-0.012014172971248627,0.0038997710216790438,-0.003502458333969116,-0.011375060304999352,-0.00010943621600745246,-0.03431030735373497,-0.012095400132238865,-0.03467661514878273,-0.05062715709209442,-0.03093382529914379,0.022824974730610847,0.04939018934965134,-0.021028684452176094,0.004197969101369381,0.037393391132354736,-0.028176335617899895,-0.01585490256547928,-0.02675454132258892,-0.001398522756062448,0.010839952155947685,-0.0014937809901311994,0.005020319949835539,-0.0392594039440155,0.035468436777591705,0.024752793833613396,0.03639066964387894,0.022926686331629753,0.04597996547818184,0.02241627685725689,-0.0012659834465011954,-0.00739333825185895,0.02420814335346222,0.03704681247472763,-0.0196627639234066,-0.031841784715652466,-0.006799183785915375,-0.03352772817015648,0.02181745134294033,0.05579682067036629,-0.013558600097894669,0.030181091278791428,-0.006316977087408304,-0.013952523469924927,0.012330206111073494,-0.041256241500377655,0.03192669153213501,-0.01914273202419281,0.08461452275514603,-0.04409714788198471,-0.01214772742241621,0.011330503039062023,0.018481537699699402,-0.006005553063005209,0.050334520637989044,-0.002672649221494794,-0.008288771845400333,0.06209006905555725,-0.0010046516545116901,0.010663624852895737,-0.031831953674554825,0.022650688886642456,-0.0212539155036211,-0.03193394094705582,-0.012190799228847027,-0.01092712301760912,-0.016085412353277206,0.0294950008392334,-0.09827454388141632,-0.03515492379665375,-0.03178056702017784,0.011391546577215195,0.017250820994377136,-0.008856121450662613,-0.04064458608627319,-0.015738215297460556,0.006248313933610916,-0.018025370314717293,0.22370760142803192,0.006043099332600832,0.012936385348439217,-0.025930719450116158,0.06032849848270416,-0.006991071160882711,-0.011622984893620014,0.037625912576913834,-0.011367491446435452,-0.04600599780678749,-0.0017747886013239622,0.017549537122249603,-0.0005504885921254754,-0.027553657069802284,0.009912733919918537,0.04041628912091255,0.00668737106025219,-0.04864263907074928,0.056667692959308624,-0.013048314489424229,0.0067961267195641994,-0.018381819128990173,-0.02903132699429989,0.022398315370082855,0.019530439749360085,-0.02770918980240822,-0.010601629503071308,0.03488731384277344,-0.044833723455667496,0.006666871719062328,-0.0008869143784977496,-0.00881689041852951,0.04928088188171387,-0.002849663607776165,-0.03115912340581417,-0.04198518022894859,-0.005231834482401609,-0.019640298560261726,-0.023163769394159317,-0.004315787926316261,-0.04009106755256653,-0.02463514357805252,-0.0036947547923773527,0.02182174101471901,-0.0372823029756546,0.030221836641430855,0.006193005479872227,0.003403798909857869,-0.03606549650430679,-0.009063707664608955,0.022200630977749825,-0.035799380391836166,-0.0010024507064372301,0.017152471467852592,0.03343266248703003,-0.030394289642572403,-0.0015014258679002523,0.003636636072769761,-0.01756003312766552,0.020411495119333267,0.0021329200826585293,0.011021564714610577,-0.0735861286520958,0.017728058621287346,0.023705432191491127,0.05030510202050209,0.021042807027697563,-0.020785532891750336,0.0334869921207428,0.08741839975118637,-0.0117210503667593,0.0001782165199983865,0.01726897619664669,-0.016497846692800522,-0.010504627600312233,-0.01187414862215519,-0.015835637226700783,0.034667130559682846,0.02805940806865692,0.03733376786112785,0.01915065385401249,-0.02492561750113964,-0.005571269430220127,0.019386373460292816,0.008642815984785557,0.02145669236779213,0.004512604791671038,0.05554104596376419,0.0034787680488079786,-0.029752783477306366,-0.030377579852938652,-0.004558586049824953,-0.06357397139072418,-0.0061086020432412624,-0.017321696504950523,-0.008206392638385296,0.015490153804421425,0.00264244107529521,-0.050804127007722855,0.008118793368339539,0.03476586937904358,-0.025892768055200577,-0.034948062151670456,-0.026809023693203926,-0.002411295659840107,-0.06390640884637833,-0.011082773096859455,0.027057144790887833,-0.004077316261827946,0.01618964411318302,-0.0009810739429667592,0.033004630357027054,-0.029286647215485573,-0.04033875837922096,0.013788820244371891,0.002074463991448283,0.05652409419417381,-0.0017354398733004928,0.03404363989830017,-0.006880622357130051,-0.01774861477315426,-0.018313229084014893,-0.03552359342575073,-0.0241499412804842,-0.03993042930960655,-0.04111562669277191,-0.033971648663282394,0.05698266997933388,-0.023043980821967125,0.07825858145952225,0.042342230677604675,-0.03370245173573494,-0.018297547474503517,0.01990216225385666,0.06232258304953575,-0.005874479189515114,0.07475804537534714,0.017168639227747917,0.03488057479262352,0.007689229678362608,-0.003546604420989752,-0.02382161282002926,0.008269473910331726,0.05184008181095123,0.0005383225507102907,-0.03091702237725258,0.014850238338112831,-0.022906668484210968,0.005280963145196438,0.0021260471548885107,0.0075647649355232716,0.038381244987249374,0.02324162796139717,-0.052792321890592575,0.03654114156961441,0.02748439647257328,-0.026714904233813286,0.030958322808146477,0.01187271811068058,-0.03695902228355408,0.013516424223780632,0.04011475294828415,0.05052071437239647,0.058027807623147964,-0.015193523839116096,-0.028515109792351723,0.02482019178569317,0.047152336686849594,-0.004623717628419399,-0.07297758758068085,-0.022836927324533463,-0.03479558229446411,-0.07144102454185486,0.016290798783302307,0.03177016228437424,0.01441336888819933,0.022974787279963493,-0.013084933161735535,-0.005881442688405514,-0.01334321964532137,0.028493165969848633,-0.019956499338150024,-0.007063222583383322,-0.026240255683660507,0.01777167059481144,0.049458764493465424,0.0020872417371720076,-0.0036216345615684986,0.041699085384607315,0.0014556738315150142,0.010557536035776138,0.12180053442716599,0.0042220959439873695,-0.005183610133826733,0.0054078251123428345,-0.01075050886720419,0.02989562414586544,0.043644167482852936,-0.0026929841842502356,0.05072465538978577,-0.02767416276037693,-0.021618958562612534,0.004661609884351492,-0.05195184424519539,-0.008984383195638657,-0.0016476722666993737,0.001689418568275869,0.004983874969184399,-0.016171567142009735,0.03625691309571266,0.0010089717106893659,-0.01374185923486948,-0.02346370369195938,-0.0194739680737257,-0.004569245968014002,-0.0140912476927042,0.03445490077137947,0.05356881767511368,-0.021733732894062996,-0.025566138327121735,-0.00019305998284835368,-0.0100232670083642,0.018865162506699562,-0.00848840270191431,-0.044497255235910416,-0.013691495172679424,0.05164350941777229,-0.03370695188641548,-0.010106456466019154,-0.014190864749252796,-0.0003716690407600254,-0.037853680551052094,0.009384162724018097,-0.01162363775074482,0.014443009160459042,-0.022771866992115974,0.00011503294081194326,0.023730352520942688,0.019146617501974106,-0.04712327942252159,0.0008851240272633731,-0.016855042427778244,-0.013206337578594685,0.10681824386119843,-0.020240144804120064,0.0525200180709362,0.006826168857514858,-0.0027339737862348557,0.07510307431221008,0.021456290036439896,-0.042665038257837296,0.00046758705866523087,0.005679022520780563,0.0008857414941303432,0.010391597636044025,0.007729665841907263,-0.025840606540441513,-0.02985285222530365,0.007668808568269014,0.0002980357385240495,-0.016171475872397423,0.019020926207304,0.006020192988216877,0.006464902777224779,-0.026913413777947426,-0.043556589633226395,0.008232228457927704,-0.07689546048641205,-0.0052263797260820866,-0.035628072917461395,-0.02966294251382351,-0.005918087437748909,-0.03567393124103546,-0.01247942540794611,0.060361843556165695,0.002807028591632843,-0.027588142082095146,-0.007894536480307579,0.008604361675679684,0.020103173330426216,-0.07210689783096313,0.029876112937927246,-0.023141849786043167,0.0011987691977992654,-0.0008149961940944195,0.006197143346071243,0.020895564928650856,0.00037953004357405007,0.013111161068081856,-0.03845285251736641,0.0016084229573607445,-0.04168611764907837,-0.04236757382750511,0.00733993062749505,-0.03751220181584358,-0.018620682880282402,-0.021968642249703407,0.028136257082223892,0.005372560117393732,-0.010228092782199383,-0.028038909658789635,-0.0023334466386586428,-0.028629278764128685,-0.04670895263552666,-0.052376631647348404,0.03586474433541298,0.018091430887579918,-0.049946997314691544,-0.01514176744967699,0.047803860157728195,0.01699567772448063,0.015328731387853622,0.010712620802223682,0.002123685088008642,0.06415592133998871,0.024631377309560776,0.035582102835178375,0.0012244904646649957,-0.012233590707182884,0.00813966989517212,0.037902217358350754,0.029360517859458923,-0.0486132986843586,0.017687661573290825,0.03299839422106743,-0.013238496147096157,-0.013200326822698116,-0.005730216857045889,-0.01331530325114727,-0.030444618314504623,-0.033732011914253235,0.047386765480041504,-0.009842630475759506,0.005994858685880899,-0.023812925443053246,-0.01362360455095768,0.03314647823572159,0.00647759111598134,0.0250770952552557,0.0414326973259449,0.026004893705248833,0.036320049315690994,0.054730840027332306,-0.03910583257675171,0.012060780078172684,0.041371408849954605,0.002077584620565176,-0.025946158915758133,-0.025974782183766365,-0.02720918506383896,-0.007927898317575455,0.0040055844001472,-0.013832611963152885,-0.02973191626369953,0.03527991473674774,-0.009695704095065594,-0.05575500428676605,-0.03722952678799629,0.013541829772293568,-0.00865274015814066,-0.020357931032776833,0.009639723226428032,-0.0507102832198143,-0.015244240872561932,-0.019348127767443657,0.04555179551243782,0.015294121578335762,-0.007206445559859276,0.06062790006399155,-0.005111909005790949,0.004139820113778114,0.01937681809067726,0.020404402166604996,0.002552285324782133,-0.030844949185848236,0.036409102380275726,-0.006814957596361637,-0.04197080060839653,0.05024629086256027,-0.029270010069012642,0.015528818592429161,0.001503972103819251,-0.007328128442168236,-0.01840047910809517,-0.00045441105612553656,-0.0092100128531456,-0.04498742148280144,-0.009130802936851978,0.04675000160932541,0.06979136168956757,-0.04311365634202957,-0.00877243559807539,-0.0004214404325466603,0.012277666479349136,-0.14219562709331512,-0.00430926913395524,-0.021201396360993385,-0.009498199447989464,-0.017543308436870575,0.017806844785809517,-0.025756800547242165,-0.07828842848539352,0.03590783849358559,0.02816518396139145,-0.07964565604925156,0.008752426132559776,0.042080290615558624,-0.06404416263103485,0.02651718072593212,0.055071402341127396,-0.008800625801086426,-0.028176235035061836,-0.019509777426719666,0.036569271236658096,0.00906379148364067,-0.04683149978518486,0.02234005369246006,0.02516242116689682,0.023896029219031334,-0.04918082430958748,-0.0010268468176946044,-0.023550570011138916,-0.03628400340676308,-0.017949851229786873,0.04402030631899834,-0.04206490516662598,0.04107481241226196,0.04993964731693268,0.03154009208083153,0.025109808892011642,0.013614547438919544,-0.04171719774603844,-0.0031599036883562803,0.020165840163826942,-0.011632400564849377,0.03999967873096466,0.014274412766098976,-0.01187898963689804,0.032295823097229004,-0.012709599919617176,0.05827837809920311,-0.01723158359527588,-0.024798419326543808,0.0030991726089268923,0.032597899436950684,0.029943378642201424,-0.02429444156587124,0.048744626343250275,0.0011137371184304357,-0.007776426151394844,-0.034102633595466614,-0.029111959040164948,0.015030012466013432,0.04656554013490677,-0.04094461724162102,-0.011531602591276169,4.6118831960484385e-05,-0.10001746565103531,-0.010489478707313538,-0.0015569606330245733,-0.027479514479637146,0.0019341816660016775,0.013176586478948593,0.014007719233632088,-0.006951211951673031,-0.0756019651889801,-0.037204310297966,-0.025117047131061554,0.027918003499507904,0.01250455155968666,0.008491392247378826,-0.004520315211266279,-0.023112304508686066,-0.0491146594285965,0.010934853926301003,-0.009928848594427109,-0.0035737405996769667,-0.013385831378400326,0.02666373923420906,0.006644800305366516,-0.016098324209451675,0.03759223222732544,-0.028729181736707687,-0.010834852233529091,-0.020237639546394348,-0.05446283146739006,-0.02220902405679226,-0.021221645176410675,-0.03547218069434166,0.029663149267435074,-0.011989464983344078,-0.009906524792313576,-0.006016987841576338,0.009752561338245869,0.030416961759328842,-0.047963038086891174,-0.013526865281164646,0.018452998250722885,-0.021521203219890594,0.018701469525694847,0.05285897105932236,-0.0010904023656621575,0.006972190923988819,-0.03487509861588478,-0.036200184375047684,0.017229322344064713,0.006422214210033417,0.02873692847788334,-0.041057173162698746,-0.00750432163476944,0.05745010823011398,-0.007179181091487408,-0.017404083162546158,0.017651472240686417,-0.01599116250872612,0.002535711508244276,0.011545952409505844,-0.03415549546480179,0.0005909449537284672,0.01335767563432455,0.05411890894174576,0.007383115589618683,0.007445705588907003,-0.017489442601799965,0.011805353686213493,-0.012042094953358173,0.005274818744510412,0.03236418217420578,0.03646424040198326,-0.06665074825286865,-0.019605418667197227,0.05144963786005974,-0.027477338910102844,-0.03461708873510361,-0.05672290548682213,0.01851639710366726,0.024274040013551712,-0.0470280684530735,0.01059630885720253,-0.004326973110437393,-0.04125908017158508,0.0022801600862294436,-0.045498285442590714,-0.006944847758859396,0.03445719555020332,-0.009896100498735905,-0.012551878578960896,0.01959688775241375,-0.021050885319709778,0.04245401918888092,-0.037523407489061356,-0.03017435409128666,0.009188764728605747,-0.008055423386394978,-0.02664773538708687,0.012918847613036633,-0.014927655458450317,0.04965515434741974,-0.017271872609853745,-0.022227248176932335,-0.0227284487336874,-0.004705421160906553,-0.033305756747722626,0.002648882567882538,-0.005779338534921408,0.014533694833517075,-0.013593053445219994,0.04263252764940262,0.02904282882809639,-0.07667391747236252,0.022012075409293175,0.008652359247207642,0.04519110918045044,-0.01619795337319374,0.00044568892917595804,-0.02074517495930195,0.004130502697080374,0.00022689816250931472,0.053020164370536804,-0.012851173058152199,-0.024143502116203308,0.06575654447078705,0.014508445747196674,0.0024358986411243677,-0.012151635251939297,0.01383469719439745,0.041081752628088,-0.031509026885032654,0.01629532128572464,0.03418257459998131,-0.007328009698539972,0.05706708878278732,-0.0035665929317474365,0.029910331591963768,-0.030345812439918518,0.041055403649806976,-0.034993771463632584,-0.05910377576947212,0.02390240877866745,-0.0036049620248377323,-0.011457656510174274,-0.026312116533517838,-0.009664950892329216,-0.01770581677556038,-0.007549853529781103,-0.007084082346409559,-0.0038768649101257324,0.04494233801960945,0.0034482809714972973,-0.021237505599856377,0.024455199018120766,0.05279000476002693,-0.01997961848974228,0.028929967433214188,-0.01043784897774458,0.036516424268484116,-0.06251353770494461,-0.012730982154607773,-0.01633322983980179,-0.013615496456623077,-0.020573323592543602,0.02139892429113388,-0.0033865063451230526,-0.04148336127400398,0.01212544459849596,-0.015159036964178085,0.01337565016001463,0.03254852071404457,0.0395018570125103,-0.0424620695412159,0.053009994328022,0.01647733338177204,-0.007640088442713022,-0.013958015479147434,0.021169302985072136,-0.006630351766943932,-0.0018147891387343407,-0.0404183603823185],"k":600,"num_candidates":800,"_name":"knn_query"}}],"minimum_should_match":1}}],"filter":[{"term":{"platform_sku_essa":true}},{"term":{"platform_rule_essa":true}},{"terms":{"status":[2,4,5]}}]}},"functions":[{"filter":{"term":{"label_id_list":156}},"weight":1.14},{"filter":{"term":{"label_id_list":157}},"weight":1.13},{"filter":{"term":{"label_id_list":158}},"weight":1.1},{"filter":{"term":{"label_id_list":159}},"weight":1.1},{"filter":{"term":{"label_id_list":162}},"weight":1.05},{"filter":{"term":{"label_id_list":163}},"weight":1.1},{"filter":{"term":{"label_id_list":164}},"weight":1.13},{"filter":{"term":{"label_id_list":165}},"weight":1.15},{"field_value_factor":{"field":"on_sell_days_boost","missing":1.0}},{"filter":{"term":{"is_video":true}},"weight":1.2}],"score_mode":"max","boost_mode":"multiply"}},"track_scores":true,"collapse":{"field":"goods_id"},"aggs":{"unique_count":{"cardinality":{"field":"goods_id"}}}}
  467 +
  468 +#### 8888883840386376
  469 +2025-07-02 07:45:29,565 - INFO - [REQ: 8888883840386376 UID: 9987] qt:kwd_factory total:4.385730504989624ms TIMING: QA=80ms, queryEncoding=34ms, userProfile=1ms, ES=593ms, BgeReranking=0ms, BizReranking=0ms, Reranking=0ms, total=4386ms, brand_statistics_query=3710ms
  470 +
  471 +2025-07-02 07:45:25,179 - INFO - [REQ: 8888883840386376 UID: 9987] REQUEST POST structure: {"keyword":"澳高","kt":"kwd_factory","page":1,"size":100,"request_id":8888883840386376,"extra":{"userId":9987,"businessPlatform":"trader"}}
  472 +
  473 +2025-07-02 07:45:25,854 - INFO - [REQ: 8888883840386376 UID: 9987] ES_query_timing # FactoryKeywordSearch # 592.97 # {"query":{"bool":{"must":[{"bool":{"should":[{"multi_match":{"query":"澳高","fields":["brand_name_zh^10.0","name_zh^2.0","supplier_name^8.0"],"minimum_should_match":"66%","tie_breaker":0.3}},{"term":{"no":{"value":"澳高","boost":15.0}}},{"term":{"hs_no":{"value":"澳高","boost":15.0}}},{"term":{"factory_no":{"value":"澳高","boost":15.0}}},{"term":{"factory_no_buyer":{"value":"澳高","boost":15.0}}},{"term":{"supplier_code":{"value":"澳高","boost":15.0}}},{"match":{"factory_no_fuzzy":{"query":"澳高","boost":5.0}}},{"match":{"factory_no_buyer_fuzzy":{"query":"澳高","boost":5.0}}}],"minimum_should_match":1}}],"filter":[{"term":{"platform_sku_trader":true}},{"term":{"platform_rule_trader":true}},{"bool":{"should":[{"bool":{"must_not":{"exists":{"field":"trader_buyer_ids"}}}},{"term":{"trader_buyer_ids":9987}}]}},{"terms":{"status":[2,4,5]}}]}},"_source":["id","goods_id","brand_id","name_zh","category_name_zh","sub_name_zh","label_id_list","category_id","price_range","on_sell_days_boost","brand_name_zh","supplier_name","is_video"],"from":0,"size":100,"collapse":{"field":"brand_id"},"aggs":{"category_stats":{"terms":{"field":"sale_category_one_all","size":10}},"factory_certification_stats":{"terms":{"field":"supplier_certification_type_list","size":10}},"sale_market_stats":{"terms":{"field":"supplier_main_market_list","size":10}},"factory_category_stats":{"terms":{"field":"supplier_main_category_list","size":10}},"unique_count":{"cardinality":{"field":"brand_id"}}}}
  474 +
  475 +
  476 +### 0701 启动后 第一次查询
  477 +
  478 +2025-07-01 15:10:24,560 - INFO - [REQ: 99996874 UID: 11010] qt:kwd total:15.652546644210815ms TIMING: QA=248ms, queryEncoding=0ms, userProfile=2ms, ES=14733ms, BgeReranking=503ms, BizReranking=7ms, Reranking=514ms, total=15653ms, sku_id_list_filling=144ms
  479 +
  480 +2025-07-01 15:10:08,908 - INFO - [REQ: 99996874 UID: 11010] REQUEST POST structure: {"query":"积木车","kt":"kwd","top_k":5000,"recall_merge_output_size":5000,"rerank_size":1000,"rerank_enabled":true,"page":1,"size":100,"debug":"0","from_search_debug":1,"extra":{"userId":11010,"businessPlatform":"trader"}}
  481 +
  482 +2025-07-01 15:10:24,415 - INFO - [REQ: 99996874 UID: 11010] ES_query_timing # ProductKeywordSearch # 14732.69 # {"size":1000,"from":0,"_source":{"includes":["name_zh","is_star","category_name_zh","sub_name_zh","label_id_list","is_video","brand_id","category_id","sale_category_all","price_range","on_sell_days_boost","brand_name_zh","supplier_name"]},"query":{"function_score":{"query":{"bool":{"must":[{"bool":{"should":[{"multi_match":{"query":"积木车","fields":["name_zh^2.0","goods_keyword_zh^1.0","category_name_zh^1.0","sale_category_keyword_zh^1.0","sub_name_zh^1.0"],"minimum_should_match":"66%","tie_breaker":0.3,"_name":"base_query"}},{"knn":{"field":"embedding_name_zh","query_vector":[-0.0021524359472095966,-0.008107833564281464,-0.029764598235487938,0.0008246809593401849,-0.040078889578580856,-0.006073615048080683,0.011918029747903347,0.019061563536524773,-0.030276576057076454,-0.008857600390911102,0.015921179205179214,0.019418299198150635,-0.004340778570622206,0.032456833869218826,0.026495972648262978,-0.013638369739055634,0.009577512741088867,0.05024699121713638,-0.002644563792273402,-0.056296054273843765,-0.003823563689365983,-0.02251642569899559,0.039393797516822815,0.007878373377025127,0.033576302230358124,0.03129247575998306,-0.0017715205904096365,-0.005420100875198841,0.010666202753782272,-0.03803142532706261,0.04202716797590256,-0.0036040968261659145,-0.0028934082947671413,-0.04637492075562477,-0.0489245168864727,-0.03738679736852646,0.0038137363735586405,-0.016817262396216393,-0.04795883595943451,0.05358966439962387,-0.01840907894074917,0.002011107513681054,0.02920212596654892,-0.006401093676686287,-0.0030216253362596035,-0.0013409669045358896,0.030354607850313187,-0.014434156008064747,-0.007749649230390787,0.026039982214570045,-0.008697780780494213,0.019168002530932426,0.07524910569190979,-0.042920466512441635,-0.008408952504396439,0.013219775632023811,-0.03873486816883087,-0.05833493545651436,-0.083629310131073,-0.029803313314914703,-0.03472751006484032,0.005717243067920208,-0.0226939357817173,-0.0016026428202167153,0.02288738079369068,0.10437139123678207,-0.012227358296513557,0.001420297659933567,-0.011135675013065338,-0.0664505809545517,-0.043076127767562866,-0.0029975650832057,-0.03185959532856941,-0.01608896255493164,-0.037143900990486145,0.03871254622936249,0.02565511129796505,0.0019380551530048251,-0.051922500133514404,0.003943318501114845,0.03325793519616127,-0.02121022157371044,0.013436833396553993,0.02082972601056099,0.0055800192058086395,-0.011569220572710037,-0.019480425864458084,0.004300588276237249,-0.02139301225543022,0.052772145718336105,-0.016601400449872017,-0.01394728198647499,0.009624723345041275,-0.034984245896339417,-0.04199494421482086,-0.030347228050231934,0.003312210086733103,0.02941184490919113,0.04211102053523064,0.0008835332118906081,0.026741022244095802,0.005722839385271072,0.008748107589781284,-0.01780589111149311,-0.028155015781521797,-0.06471167504787445,0.02908491902053356,0.010580305010080338,0.005717920139431953,-0.01443113200366497,-0.007160497829318047,0.03158904239535332,0.00443205377086997,-0.0002449769526720047,0.00032021026709116995,-0.018649997189641,-0.013081124052405357,0.005840871017426252,0.022754283621907234,0.00038412288995459676,0.03662636876106262,0.0015330958412960172,0.028473608195781708,0.002789353020489216,0.013041779398918152,-0.024487949907779694,-0.005734704900532961,-0.008972971700131893,0.013888053596019745,-0.0005149265634827316,0.02040003426373005,0.029574397951364517,-0.030044572427868843,-0.006543997209519148,-0.0024162638001143932,-0.03538169339299202,0.05170788988471031,-0.008383621461689472,-0.018639560788869858,-0.05566595867276192,-0.0006145948427729309,0.06543915718793869,-0.006052026525139809,-0.05874686688184738,0.0069569977931678295,-0.05807267874479294,0.05126497521996498,-0.00788998231291771,-0.008304163813591003,-0.027954386547207832,0.013678958639502525,0.022278638556599617,0.041264116764068604,0.017783891409635544,0.024431833997368813,-0.024646008387207985,0.009298823773860931,0.008236299268901348,-0.03247912600636482,0.015482714399695396,0.00038719220901839435,0.05515728145837784,-0.004987176042050123,-0.008741161786019802,-0.0023540486581623554,-0.06015388295054436,0.06123318150639534,0.027333028614521027,0.003739637788385153,-0.01502145268023014,0.004994833376258612,-0.03815867751836777,0.024375803768634796,0.013542595319449902,0.007177951745688915,0.021070610731840134,0.0926181972026825,0.014546383172273636,0.0328536257147789,-0.05456337705254555,-0.010433388873934746,0.008905144408345222,0.010454634204506874,-0.05243987962603569,-0.04009335860610008,0.032108478248119354,0.021958496421575546,-0.028974879533052444,0.010772105306386948,0.007837618701159954,-0.04730592668056488,-0.057198088616132736,-0.005038625095039606,-0.04818981513381004,0.031043333932757378,0.03901030495762825,0.00877933669835329,-0.015933558344841003,0.006942194886505604,-0.04809608310461044,0.043025385588407516,0.0043589770793914795,0.029627831652760506,-0.0027638510800898075,0.0043422565795481205,-0.00976208969950676,-0.007741814479231834,-0.01441408321261406,0.04136406257748604,-0.030481336638331413,0.015116587281227112,0.05261996388435364,-0.010116422548890114,-0.006042817607522011,-0.023958636447787285,-0.0458344928920269,-0.02643308974802494,0.040540117770433426,0.011701489798724651,0.02358323335647583,-0.035595376044511795,-0.027484813705086708,-0.008031305857002735,0.029444141313433647,0.0028918662574142218,-0.021969232708215714,0.022328602150082588,0.08823686093091965,0.0068029602989554405,-0.02103363908827305,-0.024456510320305824,0.023317944258451462,-0.025757895782589912,-0.010184992104768753,-0.016762834042310715,0.0018494194373488426,-0.0026936104986816645,0.010300536639988422,0.052759379148483276,0.027439579367637634,-0.010008060373365879,0.022467883303761482,-0.011797384358942509,0.022044146433472633,-1.3175530511944089e-05,-0.00045528641203418374,0.030866634100675583,0.03751451522111893,-0.01813993789255619,-0.02804294228553772,0.0014048550510779023,0.004565953277051449,-0.0016563588287681341,-0.023749910295009613,-0.015372049994766712,0.021440651267766953,0.01252153143286705,-0.013254334218800068,-0.01739756017923355,-0.029223432764410973,0.017711658030748367,0.03152080997824669,-0.004094158764928579,0.04269825294613838,0.020384935662150383,-0.04358230158686638,-0.03132731094956398,0.033803541213274,0.024181393906474113,-0.04478638991713524,-0.03499162942171097,0.021012023091316223,-0.008845007047057152,-0.024362096562981606,-0.0139074781909585,-0.027427630499005318,-0.040660783648490906,-0.0196492001414299,0.06112941354513168,0.022548330947756767,0.0338263139128685,-0.03196163475513458,0.00892527773976326,-0.00610659783706069,0.027038536965847015,-0.018952051177620888,-0.014648749493062496,-0.031623926013708115,0.027128929272294044,-0.087367482483387,0.008742256090044975,-0.004130226559937,0.06409017741680145,0.012657399289309978,-0.020537547767162323,0.007053192239254713,0.012734713964164257,-0.1552649736404419,-0.03443276882171631,-0.005799517966806889,0.013326657004654408,-0.0018917110282927752,-0.006266586482524872,-0.09289218485355377,-0.02573857270181179,-0.030639585107564926,0.07345457375049591,-0.00020668204524554312,-0.05569712445139885,-0.0016944733215495944,-0.01832824945449829,-0.019985295832157135,0.010904115624725819,0.020684650167822838,-0.01103052869439125,-0.0027708131819963455,-0.03966747596859932,-0.05894359201192856,-0.00985708273947239,0.04881586506962776,0.016122115775942802,-0.010426975786685944,-0.015283441171050072,0.013112197630107403,-0.013165329582989216,-0.035223446786403656,-0.0008697658777236938,-0.02840181067585945,-0.0010744782630354166,-0.012925480492413044,0.044555746018886566,0.009398666210472584,0.061517134308815,0.03688885271549225,0.028642358258366585,-0.01860814169049263,0.022029319778084755,0.008004609495401382,0.00821618176996708,0.016734670847654343,0.006471497472375631,0.003730524331331253,-0.008796396665275097,-0.0074549890123307705,0.02069988287985325,-0.030744746327400208,-0.006338813342154026,0.0253937728703022,-0.034629128873348236,0.030959444120526314,-0.004648637492209673,-0.02333318255841732,-0.010571219027042389,0.01853341795504093,0.03412136808037758,-0.014929739758372307,0.06304692476987839,-0.08330893516540527,0.002655221149325371,0.01382172666490078,0.04286998137831688,-0.014280414208769798,0.032440152019262314,-0.021224746480584145,0.00020794977899640799,0.054403550922870636,-0.01180355902761221,-0.01072473544627428,-0.02522001601755619,0.011840219609439373,-0.014453714713454247,-0.038930755108594894,-0.006260146852582693,-0.05281693488359451,-0.05747189000248909,0.012676840648055077,-0.08696306496858597,-0.010713816620409489,0.007824697531759739,-0.02255372144281864,0.011827881447970867,-0.0065089804120361805,-0.03725752979516983,-0.018521690741181374,0.04106614366173744,0.018148278817534447,0.23312987387180328,-0.014090578071773052,0.016248833388090134,0.01127681229263544,0.05765477567911148,0.015727991238236427,0.00946797151118517,0.0031675961799919605,-0.03734290227293968,-0.03255750983953476,0.0182870514690876,0.007358734030276537,-0.022447505965828896,-0.026112454012036324,0.01635131426155567,0.04619167745113373,0.02413603663444519,-0.0407564602792263,0.09370268881320953,-0.025074772536754608,-0.00029483612161129713,-0.018697509542107582,-0.01781277358531952,0.017940673977136612,-0.02972322516143322,0.00024119814042933285,-0.022535981610417366,0.009964799508452415,-0.021998129785060883,0.024504350498318672,-0.005922492127865553,0.0021572797559201717,0.04125651344656944,0.0047308299690485,0.013808893971145153,-0.008898098953068256,-0.03205633908510208,-0.018167994916439056,0.0030818094965070486,0.007267059292644262,-0.02025766484439373,-0.02215166948735714,-0.030655503273010254,0.03830377012491226,0.005981022026389837,0.03742852807044983,0.020476529374718666,0.017463959753513336,-0.04439929872751236,0.0004590617900248617,0.0256186630576849,-0.04552275314927101,-0.009011787362396717,0.057703666388988495,-0.00494146766141057,-0.03310084342956543,0.005579948425292969,0.015488170087337494,-0.024067174643278122,0.031143829226493835,-0.022571805864572525,0.002964159706607461,-0.058006830513477325,0.0283556766808033,0.040942154824733734,0.017844954505562782,0.03505164012312889,0.0143186766654253,0.019413070753216743,0.047896355390548706,0.006573976017534733,0.02589588426053524,-0.006083318963646889,-0.05251375213265419,0.032565075904130936,0.005573251750320196,-0.029710937291383743,0.014190850779414177,0.0360872745513916,0.0035467869602143764,0.016834037378430367,-0.019506607204675674,-0.025557391345500946,0.017378561198711395,0.033644337207078934,-0.01754351332783699,-0.012809148989617825,0.01448732241988182,0.0279574953019619,-0.01765974797308445,-0.04071679338812828,0.0009586800588294864,-0.023854324594140053,-0.02147866226732731,-0.07723361998796463,-0.009058748371899128,0.040198519825935364,0.01204153336584568,-0.04439648985862732,0.011944795958697796,0.017168762162327766,-0.010023520328104496,-0.006161050871014595,-0.017953239381313324,-0.0008542825817130506,0.013084064237773418,0.030334994196891785,-0.0037808723282068968,0.014176527969539165,0.006537510547786951,0.024642817676067352,0.024845825508236885,-0.022497717291116714,0.003762215841561556,-0.033537302166223526,-0.02540391869843006,0.0312526598572731,0.0014003848191350698,0.018620852380990982,0.06406458467245102,-0.03934227675199509,-0.026771441102027893,-0.026208680123090744,-0.04102228581905365,-0.0270833857357502,-0.0371842123568058,0.03195386752486229,-0.0005223327898420393,-0.03742726892232895,0.07725945860147476,0.032983504235744476,-0.031122945249080658,-0.045543745160102844,0.032277967780828476,0.05918898805975914,-0.027791693806648254,0.06387126445770264,0.023617131635546684,0.05752670764923096,-0.02803068235516548,-0.010680115781724453,-0.022160986438393593,-0.011746326461434364,-0.008686578832566738,0.007741359528154135,-0.0062912022694945335,0.015117891132831573,-0.0504550077021122,-0.027555646374821663,0.005645196884870529,0.03199009969830513,0.04541085660457611,0.018509844318032265,-0.04988311603665352,0.0019933488219976425,0.007733427453786135,-0.009433378465473652,0.008698632940649986,-0.021730277687311172,-0.03974450007081032,0.023893440142273903,0.03154609352350235,0.033038459718227386,0.05710946395993233,-0.024973005056381226,0.016246620565652847,0.024769118055701256,0.04433866962790489,0.014308245852589607,-0.045840609818696976,0.027106719091534615,-0.019007112830877304,-0.04810561612248421,0.02759348414838314,0.08240367472171783,0.02096753567457199,-0.00416744127869606,-0.020258115604519844,-0.01906486786901951,0.013792135752737522,-0.00884083192795515,-0.01788301207125187,0.01874888874590397,-0.03870024532079697,-0.002507546916604042,0.023538006469607353,-0.019283248111605644,-0.01345799583941698,0.01689094491302967,-0.003734003519639373,-0.015246883034706116,0.10167922079563141,0.002215425716713071,-0.01618504896759987,-0.0015069530345499516,-0.03562147170305252,-0.004937139339745045,0.0007552902097813785,-0.0033826816361397505,0.004935006611049175,-0.018421879038214684,-0.0266331285238266,-0.0032839688938111067,-0.025602977722883224,-0.013660518452525139,0.00856244657188654,-0.02488720417022705,0.01565670408308506,0.010058961808681488,-0.009137501008808613,-0.007183379959315062,-0.029949260875582695,-0.016903936862945557,-0.02664032205939293,-0.0026719740126281977,-0.02189408615231514,0.03345991671085358,0.0245782732963562,-0.0582994781434536,-0.00568669056519866,0.0040232595056295395,-0.01667124032974243,0.052253250032663345,-0.0023887353017926216,-0.03843231499195099,-0.018974334001541138,0.0374433770775795,-0.029200579971075058,0.006642875727266073,0.04284786805510521,0.005079883616417646,0.044204726815223694,-0.050280727446079254,-0.0030483368318527937,0.018859531730413437,0.016609109938144684,0.04063723236322403,0.03662716597318649,0.017424730584025383,-0.05511152744293213,0.012393343262374401,-0.052537936717271805,-0.011534972116351128,0.09142953902482986,-0.037017758935689926,0.03191547840833664,-0.0011108381440863013,-0.015503648668527603,0.09541337937116623,0.04027377814054489,-0.02521558478474617,0.0025058649480342865,0.02207014337182045,-0.004655528347939253,-0.014539115130901337,0.01584828458726406,0.02960776910185814,-0.03246964141726494,-0.015777749940752983,-0.028405562043190002,-0.0325256809592247,0.04164791852235794,-0.015093624591827393,0.01791227050125599,-0.0053864638321101665,-0.062485549598932266,0.014980792067945004,-0.07676522433757782,0.01933562196791172,-0.02318069152534008,-0.03381315991282463,-0.01226354856044054,-0.029262298718094826,-0.03077603131532669,0.0043533798307180405,0.032050326466560364,-0.0032636383548378944,0.011057293973863125,0.012763677164912224,0.02708243392407894,-0.04477400332689285,-0.005059266462922096,-0.02746930904686451,-0.01495356298983097,0.012080458924174309,-0.02930055372416973,0.022455070167779922,-0.006186312064528465,0.012239658273756504,-0.056182049214839935,-0.012763277627527714,-0.03393477573990822,-0.026735682040452957,0.010735822841525078,-0.030875341966748238,-0.019251223653554916,-0.051349807530641556,0.04196283966302872,-0.029140431433916092,-0.022665003314614296,-0.028535345569252968,0.02563866414129734,-0.031149370595812798,-0.02313033491373062,-0.041975896805524826,0.033878181129693985,0.018033476546406746,-0.04503728821873665,0.01451121736317873,0.01986190304160118,-0.0112045519053936,0.0022888975217938423,0.010853433981537819,-0.03081909380853176,0.03367147967219353,0.008152400143444538,-0.008445621468126774,-0.0069310967810451984,-0.005846841726452112,0.04007423669099808,-0.010478340089321136,0.003632578067481518,-0.05679529160261154,-0.007903935387730598,0.015483321622014046,-0.005587068852037191,0.014209503307938576,0.004649599082767963,-0.004043999128043652,-0.041941024363040924,-0.0037290018517524004,-0.0003034354595001787,-0.02196478843688965,-0.0035335738211870193,-0.013874325901269913,0.010820210911333561,0.0057076942175626755,-0.03366489335894585,-0.004135465249419212,0.0280380230396986,0.03273744136095047,0.018154531717300415,0.04654344171285629,-0.037046708166599274,0.0475095771253109,0.03073061630129814,-0.009450764395296574,-0.01001717709004879,0.00536694098263979,-0.025302181020379066,0.008918129839003086,0.019043093547225,-0.011608882807195187,-0.014153755269944668,0.03197164088487625,-0.007570689544081688,-0.053325723856687546,-0.012190615758299828,-0.013835873454809189,-0.007214938290417194,-0.033833518624305725,0.02794158272445202,-0.043069664388895035,-0.005416421685367823,-0.01889304257929325,0.048966776579618454,0.0072764926590025425,0.013816933147609234,0.06535563617944717,0.006311641540378332,-0.006707347463816404,-0.0352039635181427,-0.007175379898399115,0.0071813007816672325,0.0032109459862113,0.04923095181584358,-0.0004961849772371352,-0.022697051987051964,0.0007138533401302993,-0.034034986048936844,0.016270918771624565,0.003717052284628153,0.01697886735200882,-0.01975543424487114,0.039609394967556,-0.02062390185892582,-0.06586196273565292,0.00756759662181139,0.03938873112201691,0.03567376732826233,-0.048646848648786545,-0.03521135076880455,-0.02724856324493885,0.007512927986681461,-0.14108328521251678,0.03747677803039551,-0.01291686575859785,-0.028617428615689278,-0.05360802263021469,0.02828209288418293,-0.027074536308646202,-0.054799556732177734,0.021222947165369987,-0.016730189323425293,-0.0714416578412056,-0.00894789770245552,0.04949968680739403,-0.036847881972789764,0.01872086524963379,0.06436192244291306,0.019862260669469833,-0.030302345752716064,-0.007061121519654989,0.015498452819883823,-0.00441434932872653,-0.005172411911189556,0.0715278908610344,0.031627822667360306,-0.0035775310825556517,-0.033065617084503174,0.010293131694197655,0.01225349772721529,-0.024923870339989662,0.016770552843809128,-0.006837135646492243,-0.05347704514861107,0.01712893508374691,0.08052338659763336,0.0452919527888298,0.027423730120062828,0.017372475937008858,-0.04497986659407616,-0.013707904145121574,0.0180472694337368,0.019366011023521423,0.029807746410369873,-0.0020171261858195066,0.027545781806111336,0.0005783095839433372,0.0052664210088551044,0.02249046228826046,-0.00868252757936716,-0.013710943050682545,0.009558163583278656,0.002748706843703985,0.023087885230779648,0.002986074425280094,0.029210377484560013,0.013242463581264019,-0.023239193484187126,-0.020963486284017563,-0.055765364319086075,0.024110082536935806,0.05231046304106712,-0.00956584233790636,0.02121114730834961,-0.025239259004592896,-0.0946902483701706,-0.039695486426353455,-0.005382890347391367,-0.034302305430173874,0.0018533205147832632,0.06796300411224365,0.027097562327980995,0.013307681307196617,-0.059225697070360184,-0.006225021556019783,-0.009755522944033146,0.020239073783159256,0.022693298757076263,0.0411948598921299,0.006173071917146444,-0.04946613311767578,-0.0362771637737751,-0.020803051069378853,0.025593405589461327,-0.0006749304011464119,0.003253212431445718,0.012986235320568085,-0.0032602206338196993,-0.03639553487300873,0.05997848883271217,-0.05154813826084137,0.008660460822284222,-0.016708508133888245,-0.02752944640815258,-0.024387666955590248,-0.004524093121290207,0.004924986977130175,0.007002477068454027,-0.013311495073139668,0.013337369076907635,-0.02140575833618641,-0.01811077445745468,-0.003214634954929352,0.007181718945503235,0.007522390689700842,-0.017910225316882133,-0.0013092863373458385,0.023208608850836754,0.019766826182603836,-0.0020718665327876806,0.015326851047575474,-0.01997850090265274,-0.023913022130727768,-0.027809714898467064,0.00522984191775322,-0.006423330400139093,-0.05896889045834541,-0.008351332508027554,0.037767525762319565,-0.010563126765191555,-0.04010838270187378,0.012037806212902069,0.01449983287602663,-0.008654217235744,0.03958940505981445,-0.041072919964790344,-0.020386384800076485,0.016278039664030075,0.03609130531549454,-0.00932556577026844,0.02303696796298027,-0.011356515809893608,0.01134386658668518,-0.029857710003852844,0.041478242725133896,0.02560768648982048,0.027723217383027077,-0.013846679590642452,-0.006710059009492397,0.0533745177090168,-0.004539508372545242,-0.037180494517087936,-0.05059074983000755,0.010428684763610363,-0.0013235608348622918,-0.050717439502477646,-0.02790592983365059,-0.013537339866161346,-0.037436746060848236,-0.00787926185876131,-0.03954906016588211,-0.05071116238832474,0.026204537600278854,0.002853244775906205,-0.004444602411240339,0.008540390059351921,0.0037303552962839603,0.04376672953367233,-0.027974246069788933,0.007798444014042616,-0.002806631848216057,0.01825649105012417,0.0049882205203175545,-0.008621595799922943,-0.00796885509043932,0.026042580604553223,0.001026156242005527,0.014937580563127995,-0.025604236871004105,0.01384399738162756,-0.03421280160546303,-0.01651141606271267,-0.033375389873981476,-0.010832262225449085,-0.0071794334799051285,0.03804642707109451,0.03441499173641205,-0.054669156670570374,0.021820666268467903,-0.005702161230146885,0.039233241230249405,-0.003689537523314357,0.012676684185862541,0.0074905212968587875,0.022044047713279724,0.01034513022750616,0.04489839822053909,0.0026726643554866314,-0.016389921307563782,0.0721321702003479,0.030039990320801735,0.046596869826316833,0.008214130997657776,-0.01008486095815897,0.059578366577625275,-0.005294167436659336,0.05520564317703247,0.03682423755526543,-0.024427372962236404,0.0493122823536396,-0.0029275345150381327,0.047900039702653885,-0.03625209257006645,-0.008139371871948242,-0.016370030120015144,-0.013061241246759892,-0.025937354192137718,0.018791822716593742,0.007310884539037943,-0.022234100848436356,-0.01127785537391901,-0.01773921214044094,-0.022473379969596863,-0.021747006103396416,-0.0039264364168047905,0.024716513231396675,-0.013713193126022816,-0.019176652655005455,0.007130912970751524,0.03963853791356087,-0.024430224671959877,0.052942048758268356,-0.006402516271919012,0.02781028486788273,-0.0398385263979435,0.006198063492774963,-0.02492978423833847,-0.004867245443165302,-0.06440611183643341,-0.02933618240058422,0.0036015156656503677,-0.026202373206615448,0.022264158353209496,0.0016737349797040224,0.0047467234544456005,0.015019385144114494,0.025666475296020508,-0.02535399980843067,0.03414227440953255,0.019933506846427917,0.04195677861571312,-0.062302686274051666,0.016360249370336533,-0.0017109195468947291,0.014784248545765877,0.006924598477780819],"k":600,"num_candidates":800,"_name":"knn_query"}}],"minimum_should_match":1}}],"filter":[{"term":{"platform_sku_trader":true}},{"term":{"platform_rule_trader":true}},{"bool":{"should":[{"bool":{"must_not":{"exists":{"field":"trader_buyer_ids"}}}},{"term":{"trader_buyer_ids":11010}}]}},{"terms":{"status":[2,4,5]}}]}},"functions":[{"filter":{"term":{"label_id_list":156}},"weight":1.14},{"filter":{"term":{"label_id_list":157}},"weight":1.13},{"filter":{"term":{"label_id_list":158}},"weight":1.1},{"filter":{"term":{"label_id_list":159}},"weight":1.1},{"filter":{"term":{"label_id_list":162}},"weight":1.05},{"filter":{"term":{"label_id_list":163}},"weight":1.1},{"filter":{"term":{"label_id_list":164}},"weight":1.13},{"filter":{"term":{"label_id_list":165}},"weight":1.15},{"field_value_factor":{"field":"on_sell_days_boost","missing":1.0}},{"filter":{"term":{"is_video":true}},"weight":1.2},{"filter":{"terms":{"sku_id":[2388172,2185613,2121891]}},"weight":1.2}],"score_mode":"max","boost_mode":"multiply"}},"track_scores":true,"collapse":{"field":"goods_id"},"aggs":{"unique_count":{"cardinality":{"field":"goods_id"}}}}
  483 +
  484 +
  485 +
  486 +2025-06-29 21:58:26,099 - INFO - [REQ: 7621648571687939 UID: 12883] TIMING: QA=89ms, queryEncoding=38ms, userProfile=0ms, ES=12407ms, BgeReranking=43ms, BizReranking=1ms, Reranking=44ms, total=12594ms, sku_id_list_filling=50ms
  487 +
  488 +{"size":1000,"from":0,"_source":{"includes":["name_zh","is_star","category_name_zh","sub_name_zh","label_id_list","is_video","brand_id","category_id","sale_category_all","price_range","on_sell_days_boost","brand_name_zh","supplier_name"]},"query":{"function_score":{"query":{"bool":{"must":[{"bool":{"should":[{"multi_match":{"query":"婴儿游泳叭圈","fields":["name_zh^2.0","goods_keyword_zh^1.0","category_name_zh^1.0","sale_category_keyword_zh^1.0","sub_name_zh^1.0"],"minimum_should_match":"66%","tie_breaker":0.3,"_name":"base_query"}},{"knn":{"field":"embedding_name_zh","query_vector":[-0.01478106901049614,0.013851337134838104,-0.055754996836185455,0.00896596722304821,-0.035678550601005554,0.011876722797751427,-0.0468246228992939,0.002370002679526806,-0.008833633735775948,-0.013886653818190098,0.005371053237468004,0.014607803896069527,-0.026950594037771225,0.009789489209651947,0.037642937153577805,-0.01866260915994644,0.005209847819060087,0.02765592560172081,0.023023366928100586,-0.04377084970474243,-0.022735562175512314,0.00786507222801447,-0.02201155759394169,-0.0025800715666264296,0.02735256962478161,0.008907552808523178,-0.0007465820526704192,-5.53255777049344e-05,-0.013690521009266376,-0.026607664301991463,0.00973280519247055,0.019667286425828934,-0.017879927530884743,-0.06314889341592789,-0.009382741525769234,-0.06508748978376389,-0.019463876262307167,0.006836523301899433,-0.043444592505693436,0.0657905861735344,-0.011680386029183865,-0.005935718771070242,0.015079094097018242,0.02610080875456333,0.02284662239253521,-0.014283453114330769,0.01882733218371868,-0.025137750431895256,-0.02017633244395256,-0.024488935247063637,-0.018697349354624748,0.014619751833379269,0.029269011691212654,-0.017477717250585556,0.006322234403342009,0.03211721405386925,-0.021374624222517014,-0.029504645615816116,-0.06616988778114319,-0.036163579672575,-0.013338882476091385,-0.01617359183728695,-0.04116946458816528,0.026660947129130363,0.008928346447646618,0.10984474420547485,0.010123053565621376,-0.01621401309967041,-0.027820462360978127,-0.04593786224722862,-0.038563843816518784,0.025001462548971176,0.004857074469327927,-0.0024321400560438633,-0.04466858133673668,0.05484404042363167,0.008686342276632786,-0.0003515953430905938,0.008685621432960033,-0.018227847293019295,0.047262199223041534,-0.008053619414567947,-0.01761087030172348,0.007228255737572908,-0.03889349102973938,0.02386181242763996,-0.0228823684155941,-0.022754788398742676,0.0016211157198995352,-0.0035532936453819275,-0.021663568913936615,-0.006626194342970848,0.022327415645122528,-0.035443294793367386,0.019731944426894188,0.04754151403903961,0.017493415623903275,-0.022076735273003578,0.04263211041688919,0.01102732215076685,0.019614174962043762,0.009782286360859871,-0.027961768209934235,-0.0315760001540184,0.0027029807679355145,-0.03642409294843674,0.06655669212341309,0.024716848507523537,0.01797829382121563,0.004849161021411419,0.0043105133809149265,0.006638331804424524,-0.014820436015725136,0.04238307103514671,0.024094264954328537,-0.03936127573251724,-0.05168687179684639,0.011486952193081379,-0.0034848363138735294,-0.012619306333363056,0.0060675060376524925,-8.145697938743979e-05,0.027002284303307533,-0.018612802028656006,0.020482657477259636,1.8866128812078387e-05,-0.019893649965524673,-0.0193052776157856,0.012323510833084583,0.029035022482275963,0.03360322490334511,0.05084170773625374,-0.017852783203125,0.020378144457936287,-0.01218657661229372,-0.006937084719538689,0.053081151098012924,0.03357801213860512,-0.022793013602495193,-0.02143709734082222,0.02176191657781601,0.055819615721702576,0.0038024240639060736,-0.012173552066087723,0.0005114141386002302,-0.018635105341672897,0.01824198290705681,0.0255444273352623,-0.0282748956233263,0.004239222966134548,-0.00812776479870081,4.7788598749320954e-05,0.0557871051132679,0.019567588344216347,-0.00028773516532965004,-0.02875434421002865,-0.03580142557621002,-0.002113121096044779,-0.020758362486958504,0.05183732509613037,0.017015770077705383,0.01906605437397957,-0.03805425390601158,-0.0051781125366687775,-0.02848101407289505,-0.006052127107977867,0.033519964665174484,0.03536006063222885,0.012120080180466175,0.0025614923797547817,0.0009862167062237859,-0.03235156834125519,0.02071847766637802,0.03410404548048973,0.016081364825367928,0.011789122596383095,0.01911352388560772,0.004926277324557304,0.005005321465432644,-0.043821439146995544,-0.017150579020380974,0.0077651748433709145,0.0003986236115451902,-0.008670051582157612,-0.022377822548151016,0.011790684424340725,-0.01683042012155056,-0.00673762708902359,0.008468764834105968,0.026806943118572235,-0.0197699423879385,-0.03254053369164467,-0.03715294227004051,-0.039610929787158966,-0.004791934043169022,0.006890779361128807,0.024904610589146614,-0.025197915732860565,-0.0005258696037344635,0.012641497887670994,0.015375467017292976,0.03656463697552681,0.00463845394551754,-0.012778306379914284,-0.02092798426747322,-0.009456257335841656,-0.0372374951839447,-0.05441342294216156,0.044130802154541016,0.015424227342009544,0.044802676886320114,0.0038794628344476223,-0.024197202175855637,-0.0016400220338255167,-0.06931869685649872,-0.03873330354690552,0.014769361354410648,-0.008807665668427944,0.025098230689764023,0.00847370084375143,-0.03129679709672928,-0.03269540145993233,0.03355540335178375,0.023353222757577896,0.027102727442979813,0.008923940360546112,0.04196964204311371,0.10648612678050995,-0.01744609698653221,0.0019266846356913447,-0.04089239239692688,0.009922600351274014,-0.02765544317662716,-0.01203931588679552,-0.050821978598833084,0.008588070049881935,0.010486271232366562,0.025894107297062874,0.04791936278343201,-0.024667799472808838,-0.00992124155163765,-0.00803361926227808,0.044752370566129684,0.016711989417672157,0.013201702386140823,0.02621462382376194,0.009587633423507214,-0.022157341241836548,-0.008772636763751507,0.01040724292397499,0.004230833612382412,-0.019854040816426277,-0.05337895452976227,0.018900614231824875,0.012507457286119461,-0.0319330058991909,0.01058110874146223,-0.017747901380062103,-0.01473324280232191,-0.02729983814060688,0.033364370465278625,0.02851911075413227,0.018694497644901276,0.041170090436935425,0.028144676238298416,-0.07330892235040665,-0.03439082205295563,0.04874039068818092,0.03849935531616211,0.01481616124510765,0.01821759343147278,0.04376925528049469,0.01881401054561138,-0.005508360452950001,-0.004167346749454737,-0.0013212383491918445,-0.05223914235830307,-0.03634573146700859,0.018378322944045067,-0.0016303635202348232,0.01748119667172432,-0.01921321079134941,0.03549399599432945,-0.008009825833141804,-0.010965736582875252,-0.02458971180021763,-0.04181395098567009,-0.009720382280647755,-0.0021291307639330626,-0.05341916158795357,0.012093105353415012,-0.013677773997187614,0.07378465682268143,0.00434280838817358,-0.022366447374224663,0.00948258861899376,0.003781229257583618,-0.1555849015712738,-0.0041153645142912865,0.01299531664699316,0.009006157517433167,0.03128419816493988,-0.010516228154301643,-0.06446821987628937,0.013601542450487614,-0.006822902709245682,0.02624053880572319,0.010732783004641533,-0.05096074193716049,0.0010267082834616303,-0.0007933431770652533,0.01767350360751152,-0.009459401480853558,0.010237998329102993,-0.041718993335962296,-0.003640588838607073,-0.05284066125750542,-0.02430730126798153,-0.0174898412078619,0.06647244095802307,0.003071338403970003,-0.039079729467630386,-0.012542522512376308,-0.01507965661585331,-0.0016694598598405719,-0.03522174805402756,-0.025427043437957764,-0.041190698742866516,-0.008656288497149944,-0.0063092345371842384,0.023110253736376762,0.006343475077301264,0.05140964686870575,-0.009329622611403465,0.005937517154961824,0.024093065410852432,-0.02117406763136387,0.030527882277965546,-0.02994326502084732,0.019458932802081108,0.022885756567120552,0.03633096069097519,-0.03274504467844963,-0.025193624198436737,0.0304874274879694,-0.05045784264802933,-0.007156927138566971,0.0002632219111546874,-0.03667321428656578,0.03343961760401726,-0.000727548380382359,-0.018832417204976082,0.0076104020699858665,-0.016495658084750175,-0.0035339281894266605,-0.00010041255154646933,0.10188901424407959,-0.05503101274371147,-0.04886370897293091,0.019153127446770668,-0.0003434721438679844,-0.01879286579787731,0.0037846900522708893,-0.010261395014822483,-0.030383341014385223,0.0449259988963604,0.0151467090472579,0.038852814584970474,0.021958941593766212,-0.037593062967061996,-0.016459163278341293,0.0003842625592369586,-0.021652141585946083,-0.015943245962262154,-0.036421410739421844,-0.024624494835734367,-0.11945565044879913,-0.033100925385951996,-0.013826696202158928,0.017142070457339287,-0.013971383683383465,-0.03479816019535065,-0.05463365837931633,-0.0020317421294748783,0.02610885538160801,0.022207291796803474,0.21845991909503937,-0.02780364826321602,0.023863818496465683,-0.011493273079395294,0.08531605452299118,0.012615252286195755,-0.010676571168005466,-0.036802876740694046,-0.014996654354035854,-0.0263341274112463,-0.0040845926851034164,0.011440129019320011,-0.004952683579176664,-0.028654273599386215,-0.0062589398585259914,0.030777733772993088,0.012617946602404118,-0.03648025915026665,0.06575017422437668,0.015085623599588871,0.018838845193386078,0.024512935429811478,-0.0015220518689602613,-0.007385345175862312,0.018611734732985497,-0.028969021514058113,0.00487673282623291,0.03168795257806778,-0.017651529982686043,-0.005381002556532621,-0.017931491136550903,-0.002306448994204402,0.01627206802368164,0.013113864697515965,0.01910778507590294,-0.02273484505712986,-0.010903236456215382,-0.0049823070876300335,0.0011703984346240759,0.03453369066119194,-0.015177121385931969,-0.040049318224191666,0.01880592852830887,0.008752460591495037,0.006948732305318117,0.032821688801050186,0.0027854437939822674,-0.016814159229397774,0.002083203522488475,-0.013623842969536781,0.03191106393933296,-0.021625621244311333,-0.019676540046930313,0.015622952952980995,-0.0051697115413844585,-0.021825358271598816,-0.014015468768775463,-0.03397766873240471,-0.03862281143665314,0.03535090759396553,-0.006396847777068615,0.01572374813258648,-0.06387334316968918,0.03954891487956047,-0.006397388409823179,0.0037548078689724207,0.023829136043787003,9.457120904698968e-05,0.03977523371577263,0.03808773308992386,-0.03438703343272209,0.014624951407313347,0.001777412835508585,-0.028416862711310387,0.007620793767273426,-0.0234756451100111,-0.04015370458364487,0.039268117398023605,0.05067522078752518,-0.025800518691539764,0.0029162170831114054,-0.036653295159339905,0.006617528386414051,-0.0023436537012457848,0.048798732459545135,-0.026369046419858932,0.0008179753785952926,0.015046457760035992,0.019027266651391983,0.015989897772669792,-0.0773497074842453,0.02108943648636341,-0.009692764841020107,-0.01411244086921215,-0.05539141222834587,-0.00019587167480494827,-0.04371081665158272,-0.00780189223587513,-0.06135943904519081,-0.017464954406023026,-0.0301265437155962,-0.028353843837976456,-0.025363223627209663,-0.02946850098669529,0.00931487325578928,-0.012315673753619194,-0.03513934463262558,0.0016309469938278198,-0.01579628325998783,-0.004110914655029774,0.0027306871488690376,0.03724566474556923,0.002088683657348156,-0.02753308042883873,-0.014915152452886105,0.012392194010317326,0.03233878314495087,0.014463855884969234,0.04662397876381874,0.02207363024353981,-0.031118452548980713,-0.02729225344955921,-0.0042227343656122684,0.001124575617723167,-0.05390911549329758,-0.008073769509792328,-0.0014239713782444596,0.00010771185043267906,-0.031153246760368347,0.08069302141666412,-0.019543075934052467,-0.03459890931844711,-0.016283633187413216,0.03887354955077171,0.07352855056524277,-0.01916314661502838,0.07098814845085144,-0.0008823427488096058,0.05033054202795029,0.009257132187485695,0.01544534508138895,-0.01632613316178322,-0.0073908427730202675,0.0041620139963924885,0.00028659816598519683,-0.02209390513598919,0.004789973143488169,-0.051337771117687225,0.011900941841304302,0.007190568372607231,-0.028105808421969414,0.0337865874171257,-0.006938908249139786,-0.055526476353406906,0.022452108561992645,0.002936147153377533,0.00015098188305273652,0.02942933514714241,-0.01374303549528122,-0.03190475329756737,0.0023280722089111805,0.004387746565043926,0.017975622788071632,0.042441319674253464,0.0007961687515489757,0.031680405139923096,0.0367724671959877,0.06029003486037254,0.001455040299333632,-0.02433570846915245,-0.010561436414718628,-0.047577131539583206,-0.06454086303710938,0.015613190829753876,0.035283610224723816,0.029546108096837997,-0.023531636223196983,-0.011892357841134071,-0.008414669893682003,0.02767297439277172,0.006754468660801649,-0.007680680602788925,0.06519999355077744,-0.004525003954768181,0.008401394821703434,-0.015983067452907562,0.04275241866707802,-0.015080669894814491,0.01675167866051197,0.007849342189729214,0.02977675572037697,0.09612622857093811,-0.03471335396170616,-0.014554859139025211,-0.020872734487056732,-0.015555774793028831,-0.014786469750106335,0.017185816541314125,-0.05108167603611946,0.0021739527583122253,-0.06985857337713242,0.022304313257336617,-0.00222887028940022,0.011173094622790813,-0.017673956230282784,0.012225472368299961,-0.016644855961203575,0.03229503706097603,0.007167766336351633,0.0033094247337430716,-0.02083534374833107,-0.017056914046406746,-0.04563407227396965,-0.005314118694514036,0.00310131860896945,-0.028124401345849037,0.013000357896089554,0.022255398333072662,-0.04717923328280449,-0.02639474719762802,0.010452956892549992,-0.031058011576533318,0.04243765398859978,-0.009517954662442207,-0.02080993540585041,-0.0005526000750251114,0.023046601563692093,0.012260761111974716,-0.0019523088121786714,0.007185761816799641,0.002181322779506445,0.03151383996009827,-0.04993157088756561,-0.023618897423148155,0.021357083693146706,0.010918384417891502,-0.004538852255791426,0.06100621819496155,-0.0017870509764179587,-0.05889042094349861,0.0027137589640915394,-0.07317900657653809,-0.041735175997018814,0.08429314196109772,-0.05671488493680954,0.06442365795373917,0.0354963056743145,-0.025663673877716064,0.06414318829774857,0.05483851209282875,-0.024175375699996948,0.04028810188174248,0.002226137323305011,-0.008576133288443089,0.011495297774672508,0.0018570836400613189,0.02222803793847561,-0.0062371306121349335,0.021282950416207314,-0.029733702540397644,-0.029702357947826385,0.061734508723020554,0.003357925219461322,0.026944750919938087,-0.032651323825120926,-0.051689714193344116,0.04495692998170853,-0.046758972108364105,0.0014234259724617004,-0.0025414228439331055,-0.0486932210624218,-0.00418674573302269,-0.013157233595848083,0.006386986002326012,0.03507566824555397,0.01690962165594101,-0.021793877705931664,0.018052101135253906,-0.02032056823372841,-0.0027471340727061033,-0.016039947047829628,0.0024960834998637438,-0.04305771365761757,-0.06217969208955765,0.03233333304524422,0.014101964421570301,0.03885553404688835,0.028143204748630524,-0.014434010721743107,-0.011160621419548988,-0.010956748388707638,-0.051842521876096725,-0.0646885558962822,0.028717122972011566,-0.03722773864865303,-0.012082679197192192,-0.023010235279798508,0.0040945434011518955,-0.019186733290553093,0.018434736877679825,-0.012584713287651539,0.019905321300029755,-0.018455762416124344,-0.018555570393800735,-0.045438501983881,0.01525320578366518,0.004327711183577776,-0.09070004522800446,0.028358854353427887,0.045083608478307724,0.03717751428484917,0.024484196677803993,-0.009517953731119633,-0.009431657381355762,0.0007591199828311801,0.017409102991223335,0.06607170403003693,-0.01292390562593937,0.009375844150781631,0.01923065446317196,0.011820650659501553,0.008648121729493141,-0.04057059437036514,0.06847608834505081,-0.020203202962875366,-0.02259386144578457,-0.05245798081159592,0.020434347912669182,-0.04065997153520584,-0.06251334398984909,-0.02322198450565338,0.004597546067088842,-0.031775906682014465,-0.021978188306093216,0.009289751760661602,0.01025489903986454,0.014906561933457851,0.005595193710178137,-0.019608698785305023,0.04747878387570381,0.0006679797661490738,0.04260798543691635,0.013650446198880672,-0.02289482206106186,0.009342600591480732,0.019170006737113,-0.028037922456860542,-0.016723046079277992,0.010602147318422794,-0.0016515008173882961,0.020876746624708176,0.021600842475891113,-0.010055010206997395,-0.02209591120481491,0.051245685666799545,0.01684993878006935,-0.05305066332221031,-0.004865389317274094,0.035080794245004654,0.020746706053614616,-0.04443787783384323,0.009561375714838505,-0.06022968888282776,0.026691311970353127,-0.02212226577103138,0.006741049233824015,0.018080970272421837,-0.0005539057892747223,0.033643968403339386,-0.00415909243747592,0.001371117657981813,0.005385630764067173,-0.015839895233511925,0.015070218592882156,-0.002025729976594448,0.059577375650405884,-0.023244954645633698,-0.020561033859848976,0.02746720053255558,-0.020906876772642136,-0.001754920114763081,0.015423501841723919,0.020282695069909096,-0.03059510514140129,0.009342650882899761,-0.002001990331336856,-0.06397468596696854,-0.016133993864059448,0.039345528930425644,0.02325895056128502,-0.04873299226164818,0.010032864287495613,-0.023813521489501,0.01412157341837883,-0.15013840794563293,0.0206006970256567,-0.030519740656018257,-0.022590965032577515,-0.03461434692144394,0.02087264694273472,-0.033773887902498245,-0.06551176309585571,-0.00900537520647049,0.010553039610385895,-0.027387361973524094,0.01118522696197033,0.03152376413345337,-0.046793147921562195,0.04595666751265526,0.03732357174158096,-0.009744451381266117,-0.005071235354989767,0.005475230515003204,0.040578410029411316,2.0922398107359186e-05,-0.02326490730047226,0.042800888419151306,0.03803618997335434,-0.024454444646835327,-0.05303192138671875,0.0034539808984845877,0.05011993646621704,-0.034634049981832504,-0.03731266036629677,0.008109056390821934,-0.07372862845659256,0.03926841914653778,0.06551004201173782,-0.0016884456854313612,0.011396174319088459,0.03958761319518089,-0.028950288891792297,0.002899997169151902,0.03617142140865326,0.023285118862986565,0.028067653998732567,0.015173045918345451,0.015815529972314835,-0.006588934920728207,-0.041654907166957855,0.023007646203041077,0.014868589118123055,0.007916150614619255,0.02663443610072136,-0.00999829825013876,0.00835407618433237,-0.00020843675883952528,0.05323968827724457,0.020891036838293076,-0.003166407812386751,-0.05414595454931259,-0.006688897032290697,-0.0015168627724051476,0.05566542595624924,0.00024420907720923424,-0.02238735742866993,-0.042112432420253754,-0.06698784232139587,-0.04556874558329582,0.017894426360726357,-0.040310896933078766,0.024108150973916054,0.025999978184700012,-0.012061280198395252,-0.009200457483530045,-0.009663197211921215,-0.03138483688235283,-0.002211964223533869,0.044647179543972015,0.023203222081065178,0.027417588979005814,0.008448517881333828,-0.009476922452449799,-0.026989677920937538,-0.013745793141424656,-0.009974215179681778,-0.006622327025979757,0.038578376173973083,0.020160555839538574,0.032086264342069626,-0.003854320617392659,0.048850324004888535,-0.03679690882563591,0.0057219816371798515,-0.02013472467660904,-0.03279758617281914,-0.005566930398344994,-0.04384991154074669,-0.005179742816835642,0.009159478358924389,-0.03545248135924339,0.0075321621261537075,-0.004065976943820715,-0.01934107206761837,0.020382894203066826,-0.0008584719034843147,-0.0008569291094318032,-0.0007807754445821047,-0.007518603466451168,0.029353540390729904,-0.005292690359055996,0.01426500454545021,0.013820198364555836,-0.002452387008816004,-0.012918669730424881,-0.046238236129283905,0.00434484425932169,0.004476596135646105,-0.05840316414833069,0.029132850468158722,0.00028053982532583177,0.013025021180510521,-0.03464808687567711,0.005014083813875914,-0.0037589529529213905,0.026595911011099815,0.03855610638856888,-0.04750613868236542,-0.00877139251679182,-0.004393431358039379,0.053048375993967056,0.03228847682476044,-0.029813574627041817,-0.007241407409310341,0.04123177006840706,-0.016475485637784004,0.003159452462568879,0.04989185929298401,0.007689014542847872,-0.015696948394179344,-0.006765330210328102,0.04697233438491821,-0.007351558189839125,0.012446551583707333,-0.007458018604665995,-0.006826048716902733,0.023742282763123512,-0.01563541777431965,-0.03223681449890137,0.008433869108557701,-0.044248830527067184,-0.002161342417821288,-0.06325572729110718,-0.01196405477821827,0.022096144035458565,-0.0231863334774971,-0.025602921843528748,0.060683321207761765,-0.05777692422270775,0.05511962249875069,-0.024466678500175476,0.024175086989998817,0.02553471177816391,0.019947540014982224,-0.04073907434940338,-0.028768563643097878,-0.025981882587075233,-0.012215648777782917,-0.01380565483123064,-0.01764128915965557,0.010345992632210255,-0.0008497639209963381,-0.03824533149600029,-0.003192206844687462,-0.016891472041606903,0.011801679618656635,-0.01573183946311474,0.02528231032192707,0.013951204717159271,-0.0830749049782753,0.02304237149655819,0.005945422686636448,0.08387743681669235,0.0021430361084640026,0.015207139775156975,-0.015361592173576355,0.012571867555379868,0.006508325692266226,0.04382672533392906,0.040645040571689606,-0.020613893866539,0.04337363690137863,0.007515987381339073,0.0527033694088459,0.026706496253609657,0.028836559504270554,0.04965084418654442,-0.0281118992716074,0.0543968603014946,0.054192300885915756,-0.023229757323861122,0.0430452786386013,-0.01894526183605194,0.010333853773772717,-0.040242280811071396,0.024844098836183548,-0.020945783704519272,-0.011371318250894547,-0.01287319790571928,-0.01366319041699171,-0.002420879667624831,-0.005416229832917452,-0.0484641008079052,0.007767138537019491,0.009371640160679817,-0.008116692304611206,0.02182227000594139,0.04527978599071503,-0.0007171550532802939,0.0002759904891718179,-0.027400778606534004,0.01034535001963377,-0.029638037085533142,0.04628844931721687,0.01131171640008688,0.011546695604920387,-0.06597190350294113,0.03318529948592186,-0.030854588374495506,-0.015634773299098015,-0.03665293753147125,-0.033912889659404755,0.014279810711741447,-0.031054912135004997,0.021645866334438324,0.014051077887415886,-0.005874996539205313,0.020198483020067215,0.045445170253515244,0.012097031809389591,0.02301936224102974,-0.03352238982915878,0.02399611286818981,-0.04141134396195412,0.038192395120859146,-0.003725903807207942,0.06473561376333237,-0.007683128118515015],"k":600,"num_candidates":800,"_name":"knn_query"}}],"minimum_should_match":1}}],"filter":[{"term":{"platform_sku_trader":true}},{"term":{"platform_rule_trader":true}},{"bool":{"should":[{"bool":{"must_not":{"exists":{"field":"trader_buyer_ids"}}}},{"term":{"trader_buyer_ids":12883}}]}},{"terms":{"status":[2,4,5]}}]}},"functions":[{"filter":{"term":{"label_id_list":156}},"weight":1.14},{"filter":{"term":{"label_id_list":157}},"weight":1.13},{"filter":{"term":{"label_id_list":158}},"weight":1.1},{"filter":{"term":{"label_id_list":159}},"weight":1.1},{"filter":{"term":{"label_id_list":162}},"weight":1.05},{"filter":{"term":{"label_id_list":163}},"weight":1.1},{"filter":{"term":{"label_id_list":164}},"weight":1.13},{"filter":{"term":{"label_id_list":165}},"weight":1.15},{"field_value_factor":{"field":"on_sell_days_boost","missing":1.0}},{"filter":{"term":{"is_video":true}},"weight":1.2}],"score_mode":"max","boost_mode":"multiply"}},"track_scores":true,"collapse":{"field":"goods_id"},"aggs":{"unique_count":{"cardinality":{"field":"goods_id"}}}}
  489 +
  490 +
  491 +2025-06-28 15:07:36,526 - INFO - [REQ: 0 UID: -1] TIMING: QA=113ms, queryEncoding=0ms, userProfile=0ms, ES=20945ms, BgeReranking=1974ms, BizReranking=9ms, Reranking=1987ms, total=23079ms, sku_id_list_filling=23ms
  492 +```bash
  493 +{"size": 1000, "from": 0, "_source": {"includes": ["name_zh", "is_star", "category_name_zh", "sub_name_zh", "label_id_list", "is_video", "brand_id", "category_id", "sale_category_all", "price_range", "on_sell_days_boost", "brand_name_zh", "supplier_name"]}, "query": {"function_score": {"query": {"bool": {"must": [{"bool": {"should": [{"multi_match": {"query": "新款拉布布6寸搪胶PVC卡头袋6款混装", "fields": ["name_zh^2.0", "goods_keyword_zh^1.0", "category_name_zh^1.0", "sale_category_keyword_zh^1.0", "sub_name_zh^1.0"], "minimum_should_match": "66%", "tie_breaker": 0.3, "_name": "base_query"}}, {"knn": {"field": "embedding_name_zh", "query_vector": [0.04777948185801506, -0.009930620901286602, -0.03340917453169823, -0.010704109445214272, -0.0495409220457077, 0.014086474664509296, 0.0036832967307418585, -0.013905951753258705, -0.00912229623645544, -0.02091393806040287, 0.005698441993445158, 0.01829547993838787, -0.017833806574344635, 0.04031107947230339, 0.031932197511196136, 0.01550996769219637, -0.03871632367372513, -0.0013923225924372673, 0.014080504886806011, -0.02680817060172558, -0.010332519188523293, 0.002413432113826275, -0.03353426605463028, 0.026190491393208504, 0.043260280042886734, 0.033913154155015945, -0.021475736051797867, 0.007874957285821438, -0.032225947827100754, -0.007520684506744146, 0.008848990313708782, 0.039138346910476685, 0.002573886653408408, -0.04758479446172714, -0.008340752683579922, -0.049250971525907516, 0.00864164624363184, 0.035917505621910095, -0.05339735001325607, 0.03549637272953987, -0.00036399468081071973, 0.012647312134504318, 0.05966982990503311, 0.005590304732322693, 0.04215541109442711, -0.009710724465548992, -0.013751043006777763, -0.010458292439579964, -0.01092573907226324, -0.031235473230481148, 0.03520767390727997, -0.02142075076699257, 0.05230945721268654, -0.08563978224992752, 0.005584254860877991, 0.025608506053686142, -0.005313157569617033, -0.05565866827964783, -0.04408181831240654, -0.04115551337599754, -0.03133457154035568, 0.0035521043464541435, 0.010418717749416828, 0.008755940943956375, -0.014455541968345642, 0.0792229026556015, -0.0006479261792264879, 0.026836542412638664, -0.0099220871925354, -0.04345971718430519, -0.03007948026061058, 0.012955267913639545, -0.0005541691207326949, -0.009107008576393127, -0.06151101365685463, 0.002716085407882929, 0.05793072283267975, 0.018348004668951035, -0.010979007929563522, 0.021718094125390053, 0.0311488825827837, 0.01106400229036808, -0.01580420695245266, -0.009378353133797646, 0.018424641340970993, 0.0033540285658091307, -0.05074841156601906, -0.018410172313451767, -0.06399434059858322, 0.008303754962980747, 0.0008616647101007402, 0.01031291764229536, 0.0024627535603940487, -0.02586234174668789, 0.0064286766573786736, 0.055150166153907776, -0.005198394414037466, -0.02913581021130085, 0.02242407575249672, -0.0035910012666136026, -0.0044089690782129765, 0.06864335387945175, 0.040900155901908875, 0.014038962312042713, -0.01387964840978384, -0.048606064170598984, 0.0013360632583498955, -0.0005932460771873593, 0.0003368504985701293, -0.024940822273492813, 0.008088236674666405, 0.04601464793086052, 0.010241185314953327, 0.004739545285701752, 0.03083225153386593, -0.0336325578391552, -0.015431303530931473, -0.04710129648447037, 0.01660567708313465, 0.010237863287329674, 0.025120045989751816, -0.005079660564661026, 0.04518229514360428, -0.028497137129306793, 0.008398430421948433, -0.049911994487047195, -0.026090597733855247, 0.008263975381851196, -0.011193313635885715, 0.005899224430322647, 0.02586648240685463, -0.01744774542748928, -0.05286448821425438, -0.0037355232052505016, -0.020177341997623444, -0.00937901996076107, 0.004217286594212055, -0.024037707597017288, -0.008115537464618683, -0.02264280430972576, -0.0010051490971818566, 0.07857394218444824, -0.019911985844373703, -0.009416090324521065, 0.004931884352117777, -0.022695835679769516, 0.05615118518471718, 0.01858239434659481, 0.026104934513568878, -0.032858431339263916, 0.0020107044838368893, 0.019154125824570656, 0.01621229574084282, 0.03562867268919945, 0.03500063717365265, -0.04617758095264435, 0.01572221703827381, 0.05247366428375244, -0.023827500641345978, 0.04365061968564987, 0.0006273780600167811, 0.03074229694902897, -0.02591243013739586, -0.03805765137076378, -0.015149170532822609, 0.03779711201786995, 0.02580627053976059, 0.030128315091133118, -0.011303736828267574, 0.03516492247581482, 0.026869751513004303, -0.02845270186662674, 0.059881582856178284, 0.003097916953265667, 0.04811083525419235, 0.003229842521250248, 0.054461948573589325, -0.013254344463348389, 0.023268887773156166, -0.07977989315986633, -0.019608188420534134, 0.038743309676647186, 0.021014267578721046, -0.03317583352327347, -0.030563242733478546, 0.012792572379112244, 0.006061076652258635, -0.027493035420775414, 0.014338426291942596, 0.017754076048731804, 0.004996004980057478, -0.029846904799342155, 0.03648756444454193, -0.038578759878873825, 0.02735607512295246, 0.04637077450752258, -0.032901331782341, 0.010212377645075321, -0.009683933109045029, 0.002401115372776985, 0.015017108991742134, 0.004918758757412434, 0.011426692828536034, 0.006396048236638308, -0.048814959824085236, 0.002921796403825283, 0.019042879343032837, 0.015430758707225323, 0.03393460437655449, -0.04169744253158569, -0.017125923186540604, 0.05922950804233551, 0.008733823895454407, -0.019725129008293152, -0.047633539885282516, -0.0011968417093157768, 0.006019105203449726, 0.014745817519724369, -0.020885944366455078, 0.027048124000430107, -0.04038321226835251, 0.035100437700748444, -0.019358128309249878, 0.06470426172018051, -0.018287939950823784, -0.030778348445892334, -0.03218177706003189, 0.0794251337647438, 0.02252604067325592, -0.026251694187521935, 0.003392222337424755, 0.025379657745361328, -0.012761044315993786, -0.03338577225804329, -0.05206181854009628, 0.01462528109550476, -0.034688081592321396, 0.019273769110441208, 0.0273684561252594, 0.018803877755999565, -0.045315977185964584, -0.03252853825688362, 0.0229090116918087, 0.03802607208490372, -0.0030987553764134645, 0.035308338701725006, -0.0042693340219557285, 0.053714025765657425, -0.021115798503160477, -0.03247977793216705, 0.014298364520072937, 0.021359127014875412, -0.05025552585721016, -0.058426227420568466, -0.028225066140294075, -0.008211921900510788, 0.041396282613277435, -0.0175744891166687, -0.03840591385960579, 0.010588625445961952, -0.011450069956481457, 0.04409050568938255, 0.027623001486063004, 0.006111210212111473, 0.03232325240969658, 0.01910562254488468, -0.013157332316040993, 0.014519988559186459, 0.014888674952089787, -0.025160839781165123, -0.0019194727065041661, -0.009782499633729458, -0.007831890136003494, -0.01422909740358591, -0.06268665194511414, 0.036630041897296906, -0.057012889534235, -0.027425779029726982, 0.051897820085287094, 0.00182741426397115, 0.03560733422636986, 0.025675274431705475, -0.012190687470138073, -0.0068927849642932415, 0.03648059442639351, -0.018904387950897217, -0.04686117172241211, -0.011108235456049442, 0.018694736063480377, -0.012015921995043755, 0.02588983066380024, 0.021791545674204826, 0.0568043552339077, -0.01771237701177597, -0.036844413727521896, 0.03542793542146683, 0.017389442771673203, -0.13236093521118164, 0.005069363862276077, -0.04356488585472107, 0.01762949861586094, 0.0036568883806467056, 0.0357181541621685, -0.04984300583600998, 0.004781763534992933, -0.023634064942598343, -0.006006993819028139, 0.022758550941944122, -0.05710079148411751, 0.025989431887865067, 0.007507902104407549, 0.004580166190862656, -0.027463912963867188, -0.02052846923470497, 0.01266541238874197, 0.0032631719950586557, -0.01589594967663288, -0.019410576671361923, -0.042919766157865524, 0.06982193142175674, -0.01324536558240652, -0.021568164229393005, -0.016236338764429092, 0.023161690682172775, -0.009671044535934925, 0.03011992573738098, -0.04479934275150299, 0.031769800931215286, 0.07410213351249695, 0.004593612626194954, 0.012650864198803902, 0.032900370657444, 0.04676395654678345, -0.005481184460222721, 0.03707682713866234, -0.0343339703977108, 0.014170031994581223, 0.0037862148601561785, 0.005158451851457357, 0.03605901822447777, 0.012319646775722504, 0.02190830372273922, -0.03371215984225273, 0.0013277997495606542, 0.015922417864203453, -0.03311590105295181, -0.02045893669128418, 0.0022150904405862093, 0.024235514923930168, 0.05243319272994995, -0.06884219497442245, -0.032121241092681885, -0.02057197317481041, 0.02464400604367256, 0.023941263556480408, 0.008417989127337933, 0.028591185808181763, -0.03475973382592201, -0.10133542120456696, 0.030981674790382385, -0.0059692696668207645, -0.02728826366364956, 0.018892623484134674, 0.017253372818231583, -0.010950181633234024, 0.010115663520991802, -0.04097826033830643, 0.047668490558862686, 0.005775030702352524, -0.0330018550157547, -0.015302733518183231, -0.026839636266231537, 0.03990592807531357, -0.08095647394657135, -0.010236202739179134, -0.023906735703349113, -0.11363940685987473, -0.02794370800256729, -0.007577626965939999, -0.010191259905695915, -0.031102292239665985, -0.005952379200607538, -0.015238235704600811, 0.021037837490439415, 0.048086635768413544, 0.02485371194779873, 0.2202252894639969, 0.006417000666260719, -0.01582985185086727, -0.020443500950932503, 0.049587927758693695, -0.010321233421564102, -0.019389592111110687, -0.0219429899007082, -0.013874799944460392, -0.021901890635490417, -0.04813386872410774, 0.054123375564813614, 0.0005942619172856212, -0.034767698496580124, -0.008833615109324455, 0.025376304984092712, -0.00027705455431714654, -0.018086474388837814, 0.06567089259624481, 0.02201266773045063, 0.009660826064646244, -0.050511252135038376, -0.009195378981530666, -0.02317940630018711, -0.03656037524342537, -0.030937548726797104, -0.004057656973600388, 0.01446757186204195, -0.0033005152363330126, 0.05119867995381355, -0.0002796838525682688, 0.004812772385776043, -0.01656021922826767, -0.033608417958021164, -0.00369013543240726, -0.04403204470872879, -0.009051754139363766, 0.00161420414224267, -0.006753283087164164, 0.04965002462267876, -0.03266602382063866, -0.031390659511089325, 0.012554764747619629, 0.0403885543346405, -0.008178787305951118, -0.0088236965239048, 0.01938529685139656, 0.022512517869472504, 0.01890033483505249, 0.004583593457937241, -0.018219444900751114, -0.03660663217306137, -0.05960412696003914, 0.018526002764701843, 0.008329992182552814, -0.03104996681213379, -0.0039648874662816525, -0.026751268655061722, -0.006567014381289482, 0.06237832084298134, 0.021959850564599037, 0.008299740962684155, -0.05067161098122597, 0.019776970148086548, -0.03001045435667038, 0.03048914484679699, 0.0013995312619954348, -0.0014632665552198887, -0.008871791884303093, 0.014849912375211716, 0.031150512397289276, 0.044207923114299774, 0.03997069597244263, -0.026292748749256134, 0.06572143733501434, -0.015270156785845757, 0.02528577856719494, 0.024951178580522537, 0.04410326108336449, 0.019941337406635284, -0.04207945242524147, 0.02629714272916317, -0.050845757126808167, 0.006399694364517927, 0.003688838565722108, -0.027066392824053764, 0.03403649106621742, 0.014691866934299469, -0.013028793036937714, -0.02166789583861828, -0.03168860450387001, -0.004749130457639694, -0.03046979196369648, -0.04633525758981705, -0.025907719507813454, -0.020302731543779373, 0.015615634620189667, -0.006162186618894339, -0.02793055586516857, -0.007741870824247599, 0.004227485507726669, -0.03796316310763359, 0.012767232023179531, -0.032471198588609695, -0.023150276392698288, 0.014846229925751686, -0.029468009248375893, -0.031153546646237373, 0.013394993729889393, -0.001276634749956429, 0.037979044020175934, 0.03422647342085838, -6.681141530862078e-05, -0.023563414812088013, -0.007209332659840584, -0.028135180473327637, -0.009307583793997765, 0.0011493850033730268, 0.03275229036808014, -0.0026970740873366594, -0.010681141167879105, -0.006956904660910368, 0.005157421343028545, -0.013205036520957947, -0.012163165956735611, -0.06095128506422043, -0.020321063697338104, -0.0014993196818977594, -0.03912986442446709, 0.030664371326565742, 0.006285347510129213, -0.03537425026297569, 0.0011132827494293451, -0.002627303823828697, -0.02077833004295826, -0.05684716999530792, 0.02123040333390236, 0.004172665998339653, 0.010015258565545082, 0.044045340269804, -0.01734968088567257, -0.05638998746871948, -0.03383277729153633, 0.0023396736942231655, 0.003095283405855298, -0.01121941115707159, -0.007378653157502413, -0.043002281337976456, 0.005443307105451822, 0.059094544500112534, 0.011385264806449413, 0.0419551320374012, 0.042968254536390305, -0.0774039775133133, -0.00788707472383976, -0.02445562370121479, -0.01815369911491871, 0.025737736374139786, -0.027459727600216866, -0.014745943248271942, 0.007133605889976025, -0.016498398035764694, 0.027850404381752014, 0.02756435237824917, -0.011284667067229748, 0.029066434130072594, -0.03676832839846611, 0.03978204354643822, -0.0025798329152166843, -0.020186856389045715, 0.0056440820917487144, -0.03432284668087959, -0.03640623018145561, -0.014417240396142006, 0.04473884031176567, 0.013192025013267994, 0.04739168658852577, -0.034630272537469864, -0.030753694474697113, 0.014856823720037937, 0.02894255891442299, -0.009841032326221466, -0.009405701421201229, 0.005677532404661179, -0.0051913075149059296, 0.01481472048908472, -0.026325812563300133, -0.008713497780263424, 0.012898151762783527, 0.00781390629708767, -0.03967709466814995, 0.05917689576745033, -0.02620290033519268, 0.00016539564239792526, -0.007338281720876694, -0.023503435775637627, -0.008488921448588371, -0.007586051244288683, -0.025655874982476234, -0.03180738165974617, -9.595941082807258e-05, -0.0014381863875314593, 0.03718188405036926, -0.04928509145975113, -0.004411920439451933, -0.003151774639263749, -0.028855348005890846, 0.04923743009567261, 0.013488849624991417, -0.05147544667124748, 0.043314557522535324, -0.014842656441032887, 0.022192806005477905, -0.0020392360165715218, -0.035835329443216324, 0.03502439334988594, 0.009316188283264637, 0.03170185163617134, -0.09451442211866379, -0.003776612924411893, -0.022116290405392647, -0.0037039185408502817, 0.03516470268368721, 0.019655559211969376, 0.020455220714211464, 0.013385603204369545, 0.011516926810145378, -0.059251200407743454, -0.011112687177956104, -0.003960699774324894, 0.0020073282066732645, 0.033514946699142456, -0.017258314415812492, 0.0032192098442465067, -0.0056349909864366055, 0.007177143823355436, 0.012908353470265865, 0.027367528527975082, -0.019316252321004868, -0.006990907248109579, 0.013136813417077065, 0.029212450608611107, -0.016587860882282257, 0.0742068886756897, -0.0253263209015131, 0.056160278618335724, -0.04185504838824272, -0.027046799659729004, 0.08385784924030304, 0.012786808423697948, 0.03263417258858681, 0.00393373379483819, 0.009683518670499325, -0.03565293550491333, 0.0032062623649835587, -0.047266602516174316, -0.019129816442728043, 0.008513612672686577, 0.014801079407334328, -0.006046884693205357, -0.028829116374254227, 0.05553624406456947, -0.045485176146030426, 0.012523164041340351, -0.005150144454091787, -0.07684548199176788, 0.061715416610240936, -0.0598946288228035, 0.005060529336333275, -0.028888961300253868, -0.0338757187128067, -0.003549030050635338, -0.009436641819775105, 0.006171475164592266, 0.04165922850370407, -0.01835727132856846, 0.0071646119467914104, -0.007417601998895407, 0.03760436922311783, 0.022616975009441376, -0.032044071704149246, -0.02622726745903492, 0.030637577176094055, 0.03051326982676983, 0.021725120022892952, -0.04843033477663994, 0.012934836558997631, 0.039799466729164124, 0.008545289747416973, -0.03943444788455963, 0.022497834637761116, 0.007327898871153593, -0.019910702481865883, 0.031814564019441605, -0.007273372728377581, 0.015735039487481117, 0.010907175950706005, 0.03955914080142975, -0.025769470259547234, -0.005889975931495428, 0.0005858503864146769, 0.014834903180599213, -0.03149813413619995, -0.04521970823407173, -0.006687577348202467, -0.026763979345560074, -0.00509474566206336, -0.031613316386938095, -0.0020705198403447866, 0.019639665260910988, 0.008036686107516289, -0.03357526287436485, 0.0050591048784554005, 0.0235908180475235, 0.04358188807964325, -0.012675202451646328, 0.054179996252059937, -0.03303862363100052, 0.01800481230020523, 0.013439487665891647, -0.0331696942448616, -0.006646042224019766, -0.008015387691557407, 0.02479076199233532, 0.01766308583319187, 0.0047085764817893505, -0.011375757865607738, -0.022349664941430092, 0.003323541721329093, -0.03494121879339218, 0.013091305270791054, 0.028886917978525162, -0.005134818144142628, -0.02668473683297634, 0.04115688055753708, 0.030776608735322952, 0.036811713129282, 0.005347450263798237, 0.030731532722711563, -0.018174750730395317, -0.07439709454774857, 0.0007084792596288025, 0.026525957509875298, -0.014472294598817825, 0.01803109236061573, -0.008008803240954876, -0.008096081204712391, 0.0016154551412910223, 0.009521991945803165, -0.008798073045909405, -0.02784651331603527, 0.02028413861989975, -0.030358843505382538, -0.03808901458978653, 0.028802677989006042, 0.004689248278737068, -0.014882923103868961, 0.03565177321434021, 2.2172058379510418e-05, 0.002019741339609027, -0.025061428546905518, 0.015963824465870857, -0.0025464214850217104, -0.011338664218783379, -0.03938833624124527, 0.03270866349339485, 0.013487349264323711, -0.01151502039283514, 0.03501705080270767, -0.029465090483427048, 0.008064762689173222, -0.042369548231363297, -0.024592360481619835, 0.039809320122003555, 0.03941027447581291, -0.0028148856945335865, 0.009110087528824806, 0.0026326305232942104, -0.019704431295394897, 0.026456378400325775, -0.02716045267879963, -0.001671018311753869, 0.004271715879440308, -0.01659168303012848, 0.06367179751396179, 0.0019519432680681348, -0.028779685497283936, -0.00702137965708971, 0.004163833335042, 0.008933528326451778, -0.007324162870645523, 0.007078149821609259, -0.006141898687928915, 0.04244047775864601, -0.13298696279525757, 0.012966402806341648, -0.03154488280415535, -0.03700488805770874, -0.018856942653656006, -0.012444576248526573, -0.005103344563394785, -0.03948184475302696, -0.028914108872413635, -0.0072982837446033955, -0.02986934594810009, -0.028557509183883667, 0.09025005251169205, -0.026758549734950066, -0.006023159250617027, 0.05640563741326332, -0.005632275715470314, -0.01717621274292469, 0.014517580159008503, 0.0454145222902298, 0.011968364007771015, -1.3410058272711467e-05, 0.05054366961121559, 0.0033770177979022264, -0.035783667117357254, -0.0318947471678257, 0.038639068603515625, -0.005597645882517099, -0.04365755617618561, -0.02643357217311859, -0.004100318998098373, -0.05701404809951782, 0.036614082753658295, 0.07144607603549957, 0.00420637521892786, -0.04369935020804405, 0.026639623567461967, -0.03725285455584526, 0.011092692613601685, -0.017785832285881042, 0.014629203826189041, -0.010082025080919266, 0.008299797773361206, 0.013835153542459011, 0.030219702050089836, 0.02464393712580204, 0.032783590257167816, 0.015998510643839836, -0.008723448030650616, 0.020838847383856773, 0.02846018224954605, 0.02805771864950657, -0.021776167675852776, -0.0016920430352911353, 0.06633155792951584, -0.019061263650655746, -0.0328797809779644, -0.028227362781763077, 0.05113675445318222, 0.06641838699579239, -0.05942663550376892, 0.0312500074505806, -0.04965898394584656, -0.07419794797897339, -0.0277184396982193, -0.02882068231701851, -0.024945655837655067, 0.005923386663198471, 0.011076993308961391, 0.027987975627183914, -0.02077493630349636, -0.028385980054736137, -0.030823830515146255, 0.008996518328785896, -0.002466692356392741, -0.0020947083830833435, 0.01321386732161045, -0.011298672296106815, -0.012045539915561676, -0.024114659056067467, 0.002305290661752224, 0.012567861005663872, 0.0001450990530429408, -0.013723531737923622, -0.028525030240416527, -0.024195358157157898, -0.016579115763306618, 0.013486876152455807, -0.05165085941553116, 0.005675381049513817, -0.06880886107683182, -0.012922380119562149, -0.015354347415268421, -0.0025346409529447556, 0.012384090572595596, 0.04576214775443077, -0.001901125768199563, 0.022474762052297592, -0.03674108907580376, 0.0009729872108437121, -0.0008665743516758084, -0.03519943729043007, -0.03061450831592083, 0.051718953996896744, 0.024544652551412582, -0.005045407917350531, -0.003099393332377076, -0.036030903458595276, -0.00561000918969512, 0.017606595531105995, -0.027757544070482254, 0.022533517330884933, -0.0341557078063488, 0.028968194499611855, -0.012559563852846622, -0.013012143783271313, -0.009422944858670235, 0.020035695284605026, -0.034719012677669525, -0.00832070130854845, 0.02455293759703636, -0.00452392315492034, 0.02556878700852394, -0.01182394940406084, -0.03588307648897171, -0.031479790806770325, 0.02734064869582653, -0.01209928747266531, -0.02146436646580696, 0.015257798135280609, 0.03879304602742195, -0.0029163069557398558, -0.013043739832937717, 0.0381423719227314, -0.023813871666789055, 0.0028275649528950453, -0.03091074712574482, 0.05272400751709938, -0.019261367619037628, -0.014952140860259533, -0.011153286322951317, 0.000254094076808542, -0.028622997924685478, -0.023533131927251816, 0.008362245745956898, -0.0020938331726938486, -0.030148902907967567, 0.014103627763688564, -0.08394484221935272, -0.04881484806537628, -0.0023162513971328735, -0.02025669626891613, 0.005037359427660704, 0.026365777477622032, -0.04714160040020943, -0.026581356301903725, 0.011109788902103901, -0.01296536810696125, 0.006858957465738058, 0.048172395676374435, -0.020886855199933052, -0.01881789229810238, -0.019760163500905037, 0.05811499431729317, -0.009254585951566696, 0.05162379890680313, -0.006809046491980553, -0.007441614754498005, -0.05994577705860138, -0.025426752865314484, -0.0033068074844777584, 0.04109293967485428, -0.04208334535360336, 0.018692992627620697, 0.007629444357007742, -0.033140428364276886, -0.02147962525486946, 0.0001421299675712362, 0.06099719926714897, -0.015410018153488636, 0.018314551562070847, 0.02164696529507637, 0.0053083403035998344, 0.03678344935178757, 0.021801859140396118, 0.038568999618291855, -0.037796493619680405, 0.03040582500398159, -0.003390856087207794, 0.04997026175260544, 0.016475005075335503, -0.015403793193399906, 0.028834087774157524, -0.011071411892771721, 0.033636901527643204, -0.0040565612725913525, -0.03536051884293556, 0.027958054095506668, 0.011154691688716412, 0.06971411406993866, -0.025246834382414818, 0.003079240908846259, -0.022101325914263725, -0.01735907606780529, -0.07825532555580139, 0.0024802186526358128, 0.038880981504917145, -0.011109908111393452, 0.03661657124757767, 0.06753414124250412, -0.005024592392146587, 0.0290799792855978, 0.02365652285516262, -0.0006422005826607347, 0.009236408397555351, -0.0036766263656318188, -0.011293289251625538, 0.013936956413090229, 0.013035985641181469, 0.06735581159591675, 0.010661225765943527, 0.023256629705429077, -0.06919150054454803, -0.020434653386473656, -0.01039141695946455, 0.026040272787213326, 0.023702194914221764, -0.014527097344398499, 0.0451965257525444, -0.009080816991627216, -0.021777639165520668, 0.03533657640218735, -0.019043998792767525, 0.042686719447374344, -0.023972440510988235, 0.008945107460021973, 0.0012297232169657946, -0.0024631342384964228, -0.05636504665017128, -0.04025499150156975, 0.006564184091985226, 0.025477567687630653, 0.028906654566526413, 0.03157368674874306], "k": 600, "num_candidates": 800, "_name": "knn_query"}}], "minimum_should_match": 1}}], "filter": [{"bool": {"should": [{"bool": {"must_not": {"exists": {"field": "auth_level_list"}}}}, {"term": {"auth_level_list": "1"}}]}}, {"terms": {"status": [2, 4, 5]}}]}}, "functions": [{"filter": {"term": {"label_id_list": 156}}, "weight": 1.14}, {"filter": {"term": {"label_id_list": 157}}, "weight": 1.13}, {"filter": {"term": {"label_id_list": 158}}, "weight": 1.1}, {"filter": {"term": {"label_id_list": 159}}, "weight": 1.1}, {"filter": {"term": {"label_id_list": 162}}, "weight": 1.05}, {"filter": {"term": {"label_id_list": 163}}, "weight": 1.1}, {"filter": {"term": {"label_id_list": 164}}, "weight": 1.13}, {"filter": {"term": {"label_id_list": 165}}, "weight": 1.15}, {"field_value_factor": {"field": "on_sell_days_boost", "missing": 1.0}}, {"filter": {"term": {"is_video": true}}, "weight": 1.2}], "score_mode": "max", "boost_mode": "multiply"}}, "track_scores": true, "collapse": {"field": "goods_id"}, "aggs": {"unique_count": {"cardinality": {"field": "goods_id"}}}}
  494 +```
  495 +
  496 +### 1k线上搜索词测试
  497 +自己批量测试的1000条 只有一条超过1S、但是这一条耗时16S
  498 +但是这一千条请求,只填充 搜索词、搜索类型、platform几个参数,所以和线上的请求是有些差异的(没有携带各种业务过滤参数和聚合参数)
  499 +
  500 +2025-06-29 22:25:33,402 - INFO - [REQ: 7277635141262495 UID: 10031] TIMING: QA=81ms, queryEncoding=26ms, userProfile=0ms, ES=15532ms, BgeReranking=101ms, BizReranking=1ms, Reranking=103ms, total=15857ms, sku_id_list_filling=135ms
  501 +
  502 +{"keyword":"мяч баскетбольный","kt":"kwd","page":1,"size":100,"request_id":7277635141262495,"extra":{"userId":10031,"businessPlatform":"essaone"}}
  503 +
  504 +{"size":1000,"from":0,"_source":{"includes":["name_zh","is_star","category_name_zh","sub_name_zh","label_id_list","is_video","brand_id","category_id","sale_category_all","price_range","on_sell_days_boost","ru_name"]},"query":{"function_score":{"query":{"bool":{"must":[{"bool":{"should":[{"multi_match":{"query":"мяч баскетбольный","fields":["name_ru^2.0","goods_keyword_ru^1.0","category_name_ru^1.0","sale_category_keyword_ru^1.0","sub_name_ru^1.0"],"minimum_should_match":"66%","tie_breaker":0.3,"_name":"base_query"}},{"knn":{"field":"embedding_name_ru","query_vector":[0.04289894551038742,0.00985910277813673,-0.034268300980329514,0.009927251376211643,-0.02506730891764164,-0.0022724864538758993,0.021023470908403397,0.012512089684605598,-0.007213256787508726,-0.0155626330524683,0.016968950629234314,0.020527228713035583,-0.004494381137192249,0.006936016958206892,0.05834418907761574,-0.043358560651540756,0.021265869960188866,0.00786946713924408,0.02343875914812088,-0.020097509026527405,0.004428471438586712,0.022987786680459976,-0.016837123781442642,0.04001355543732643,0.030128901824355125,-0.020526576787233353,0.0048284707590937614,-0.022848233580589294,-0.017915409058332443,-0.041308656334877014,0.009778021834790707,0.026508575305342674,0.027255931869149208,-0.06618311256170273,-0.04006540775299072,-0.012760354205965996,-0.024845384061336517,-0.027004633098840714,-0.033771444112062454,0.07863473892211914,0.02332051284611225,0.02499188855290413,0.012305475771427155,-0.01007290929555893,0.011017706245183945,-0.003604582278057933,0.04882559925317764,-0.024600690230727196,-0.03751907870173454,-3.09971728711389e-05,-0.04446076974272728,-0.0007124604308046401,0.030276477336883545,-0.012156338430941105,0.02764788269996643,0.011158520355820656,0.008210097439587116,0.003985962830483913,-0.06906936317682266,-0.051149141043424606,-0.02866356074810028,-0.0184809397906065,-0.028303569182753563,0.03160034120082855,0.022804316133260727,0.1030687764286995,0.01340210996568203,0.04044792428612709,-0.0006951108807697892,-0.03142579644918442,-0.030528396368026733,0.020310457795858383,-0.035197384655475616,-0.011375757865607738,-0.0371801033616066,0.03825085982680321,0.027344614267349243,-0.023387355729937553,0.0035810910630971193,-0.0404377281665802,0.028862103819847107,-0.030622778460383415,-0.005130908451974392,0.0004950390430167317,-0.03380196914076805,-2.6819625418283977e-05,-0.014891029335558414,0.017194019630551338,-0.012086699716746807,0.027236061170697212,0.032185476273298264,0.007620120886713266,0.003946945071220398,-0.04464099556207657,-0.016398096457123756,0.0005007923464290798,-0.0005411605816334486,-0.02517220750451088,0.03179505467414856,0.0023020475637167692,0.026991689577698708,0.01480980683118105,-0.04185989126563072,0.005089135374873877,-0.02230026386678219,-0.023846641182899475,0.05685099959373474,0.03465936705470085,0.04211190342903137,0.012890998274087906,0.020012883469462395,0.02514079585671425,-0.014575435779988766,0.01421177014708519,-0.005020988639444113,-0.008809729479253292,-0.03311064466834068,0.02610122039914131,0.026517897844314575,0.017540642991662025,0.03247521445155144,-0.02376544289290905,0.03210864216089249,-0.012699628248810768,-0.016704458743333817,-0.020560186356306076,-0.027206994593143463,-0.007998860441148281,-0.012488827109336853,0.0028613281901925802,-0.005140387453138828,0.013065056875348091,-0.003555877134203911,0.007852277718484402,0.015593836084008217,-0.020180784165859222,0.012655628845095634,0.0064012156799435616,0.003723553381860256,-0.04542943835258484,0.030493926256895065,0.06474622339010239,0.02494131214916706,-0.01618345081806183,0.036915525794029236,-0.015264385379850864,0.05034146457910538,-0.008880356326699257,-0.03250479698181152,-0.0337035246193409,0.01335368026047945,0.0019932782743126154,0.03383878618478775,-0.0009181809145957232,-0.007260815240442753,-0.024388810619711876,-0.00827742274850607,0.018284207209944725,-0.0076889232732355595,0.027997937053442,-0.04451410472393036,0.017110131680965424,0.0067266616970300674,0.022615449503064156,0.001863282872363925,-0.03363585099577904,0.029225816950201988,0.025952380150556564,-0.02188272960484028,-0.022404778748750687,0.014182472601532936,-0.06488898396492004,0.0369846448302269,0.04153203219175339,0.02505381405353546,0.008598348125815392,0.04731282591819763,0.015534567646682262,0.00785487238317728,-0.03959432244300842,-0.014267205260694027,-0.01032619271427393,-0.03399171680212021,-0.013300612568855286,-0.06303181499242783,0.048246119171381,0.00110131676774472,0.015134270302951336,-7.183223351603374e-05,0.002462011529132724,-0.05770685896277428,-0.01607060804963112,0.02726883254945278,-0.03249555826187134,0.04061078280210495,0.0009031521040014923,0.0034274966455996037,-0.025739213451743126,-0.0034957160241901875,-0.02640336938202381,-0.019503125920891762,0.032625310122966766,0.008006369695067406,0.010506460443139076,0.010643737390637398,-0.002503338037058711,0.01156450156122446,-0.04965271055698395,0.0679670125246048,-0.005748685449361801,-0.00778236472979188,0.009481523185968399,0.00871544610708952,-0.02106267213821411,-0.022487947717308998,-0.03128858283162117,-0.016993727535009384,0.013434244319796562,0.0017884609987959266,-0.0024710462894290686,-0.017959944903850555,-0.014335518702864647,0.02691134810447693,0.04465331509709358,0.029495909810066223,-0.02635963261127472,0.035436902195215225,0.10094207525253296,0.004390018992125988,0.0009340281249023974,-0.04524293169379234,0.021418044343590736,-0.05956793203949928,0.0017597863916307688,-0.05903895944356918,0.023769211024045944,0.014180279336869717,-0.008166740648448467,0.02303720824420452,0.010815550573170185,-0.03036920353770256,-0.023754950612783432,0.03811511769890785,0.03625554218888283,-0.020034316927194595,0.032796017825603485,-0.004072101321071386,0.03822813928127289,-0.0031090762931853533,-0.0025291922502219677,0.005204276647418737,-0.0156723503023386,-0.027836056426167488,-0.044359587132930756,0.034850820899009705,-0.008934170007705688,-0.004775969311594963,0.004285341128706932,-0.014048836193978786,-0.0067567178048193455,0.03459908068180084,0.01820729300379753,-0.025760382413864136,0.038231633603572845,0.03333388641476631,-0.05142434313893318,-0.024797087535262108,0.04476439952850342,0.04250452667474747,-0.03723198175430298,-0.028837649151682854,-0.020540906116366386,0.01641450822353363,-0.026654930785298347,-0.008292258717119694,0.044563937932252884,-0.02520473673939705,-0.039976540952920914,0.027995405718684196,0.01803576946258545,0.0010205954313278198,0.020021207630634308,-0.012649457901716232,-0.02098412998020649,0.05638851597905159,0.011408013291656971,-0.027536258101463318,-0.033197518438100815,0.029403110966086388,-0.04456411302089691,-0.014448381029069424,-0.024413950741291046,0.06824693083763123,0.007285042200237513,-0.033849384635686874,0.009168616496026516,-0.012990021146833897,-0.13251660764217377,-0.03280903398990631,-0.014275914989411831,0.020374970510601997,0.00817705038934946,-0.009782730601727962,-0.07158806920051575,-0.011243708431720734,0.002516342792659998,0.06266816705465317,-0.02026326395571232,-0.059042684733867645,0.012037320993840694,0.0031802484299987555,-0.006634697318077087,-0.01198265329003334,-0.02755388244986534,-0.019416136667132378,0.01612813025712967,-0.05008013918995857,-0.03285703435540199,-0.023529058322310448,0.035121552646160126,0.005613523069769144,-0.03597012534737587,0.004668953362852335,0.021609775722026825,-0.012366993352770805,-0.040257230401039124,-0.022291501984000206,-0.06050226464867592,0.049908507615327835,-0.008719722740352154,0.048623498529195786,0.0010433349525555968,0.05249406397342682,0.014562529511749744,-0.01845763809978962,0.02634814940392971,0.017018437385559082,0.022231822833418846,0.0005858801887370646,-0.037503570318222046,0.019017668440937996,0.004650314804166555,-0.002004263922572136,-0.034743182361125946,0.04317222908139229,-0.02504369243979454,-0.01363216433674097,0.0278327614068985,-0.018447358161211014,0.045319415628910065,-0.01395604107528925,-0.009115422144532204,0.011384333483874798,-0.024450641125440598,-0.010400857776403427,-0.020801059901714325,0.0532284714281559,-0.03091302327811718,0.012498337775468826,0.014546402730047703,0.060453787446022034,-0.011982751078903675,0.028568144887685776,-0.04307336360216141,-0.03894389048218727,0.043597202748060226,0.005097685847431421,0.014795859344303608,-0.0128038814291358,0.01343140471726656,-0.021620359271764755,-0.03791474178433418,-0.024414362385869026,-0.010476171039044857,-0.0389404371380806,0.009181478060781956,-0.08720149099826813,-0.06557508558034897,-0.01216561533510685,-0.02261705882847309,0.027464957907795906,0.009873147122561932,-0.03790777176618576,0.03245813772082329,0.006283318158239126,0.04392092302441597,0.18762412667274475,0.0015569078968837857,0.008472210727632046,-0.003119369503110647,0.05156579241156578,0.011710809543728828,-0.018842794001102448,0.02917603589594364,-0.05088569223880768,-0.0287027508020401,-0.003951418213546276,-0.007733418606221676,-0.019249293953180313,-0.023889081552624702,-0.011261733248829842,0.012606333009898663,0.015149480663239956,-0.029680438339710236,0.09333977848291397,-0.00013500450586434454,0.03528391197323799,-0.02519160881638527,-0.014547883532941341,0.014552644453942776,0.02114703506231308,-0.05189337581396103,0.004334751982241869,0.019517457112669945,-0.036815088242292404,0.00011842197272926569,-0.027657296508550644,-0.020344922319054604,0.03771381080150604,-0.0027515485417097807,-0.003933642525225878,-0.03455400466918945,-0.020026030018925667,-0.018802380189299583,-0.02347439154982567,0.02910885214805603,-0.005764256697148085,-0.03580589219927788,-0.019720718264579773,0.03072458691895008,-0.026009108871221542,0.050795771181583405,-0.016409602016210556,-0.047235891222953796,-0.012889576144516468,0.013285423628985882,0.029989730566740036,-0.00787315797060728,0.005495417397469282,0.022965462878346443,0.039564698934555054,-0.0409771129488945,-0.008550125174224377,0.020423047244548798,-0.011985637247562408,0.02098277397453785,0.027929922565817833,0.0025344821624457836,-0.08767720311880112,0.028005370870232582,0.0009481562883593142,0.011713268235325813,0.039828021079301834,-0.019305771216750145,0.04894671216607094,0.040866706520318985,0.022028228268027306,0.016010712832212448,0.023800572380423546,0.003740418003872037,0.00014643646136391908,-0.02804023213684559,-0.011580223217606544,0.021959789097309113,0.010988298803567886,-0.02873842604458332,-0.0015563899651169777,-0.038517072796821594,-0.004493627697229385,0.03620840236544609,-0.006006571464240551,0.016570894047617912,-0.00337125058285892,0.020966172218322754,0.042241454124450684,-0.031139861792325974,-0.05274248123168945,-0.0034346955362707376,-0.028965774923563004,-0.05007054656744003,-0.035811107605695724,0.013463050127029419,-0.010950863361358643,0.03897807002067566,-0.055708568543195724,-0.014721239916980267,0.029290711507201195,-0.021006805822253227,0.0025831153616309166,-0.042123906314373016,-0.00037095314473845065,-0.020786777138710022,0.012342908419668674,-0.009422508999705315,0.009251424111425877,0.003476251382380724,-0.005067756399512291,0.04398060590028763,0.008799305185675621,-0.007124000694602728,0.035534221678972244,0.006025924347341061,-0.00026875341427512467,0.011491668410599232,0.005126778036355972,0.0033774138428270817,-0.04069878160953522,-0.03145385906100273,-0.006302133202552795,-0.02811228670179844,-0.016871342435479164,-0.05399102717638016,-0.027439488098025322,0.04627895727753639,-0.031295616179704666,0.057926613837480545,0.005837196949869394,-0.022443650290369987,-0.03381342068314552,0.027001941576600075,0.05063868314027786,-0.020800843834877014,0.07718729227781296,0.021754147484898567,0.042538195848464966,0.027882715687155724,0.007830724120140076,-0.020669208839535713,0.0020759471226483583,0.025989646092057228,-0.028320474550127983,-0.014761989004909992,0.02385944314301014,-0.056272707879543304,0.030338367447257042,0.03631681576371193,0.03115236945450306,0.001322458265349269,-0.001602170872502029,-0.06074734777212143,0.002262378577142954,-0.002561628818511963,-0.005282154772430658,0.016638249158859253,-0.03494030237197876,-0.030911481007933617,-0.0039108265191316605,0.04560539126396179,-0.007855018600821495,0.037990499287843704,-0.03230845928192139,0.022280914708971977,0.049428973346948624,0.02195615880191326,-0.004151022527366877,-0.05515941604971886,-0.01571415737271309,-0.048389457166194916,-0.04875185340642929,-0.012032483704388142,0.029595505446195602,0.03575676679611206,-0.016226746141910553,0.01148922462016344,-4.673020157497376e-05,0.002419161843135953,0.01062636636197567,-0.004526807926595211,-0.01869310438632965,0.03169547766447067,-0.0039108493365347385,0.027311624959111214,0.013312522321939468,-0.02384008653461933,0.021067989990115166,0.008289112709462643,0.01721593365073204,0.13498540222644806,-0.025301247835159302,-0.016628099605441093,0.002610675757750869,-0.0014455715427175164,-0.0012895830441266298,-0.004241904243826866,-0.021494857966899872,-0.007915129885077477,-0.023129431530833244,-0.06289039552211761,0.0067895399406552315,-0.019609197974205017,0.008477495983242989,-0.02340853586792946,-0.013962173834443092,0.043029122054576874,0.011256991885602474,0.006615206599235535,0.00842709094285965,0.011110953986644745,-0.03900165483355522,-0.02272004447877407,-0.019889919087290764,-0.020560285076498985,0.06560773402452469,0.04035598039627075,-0.014076421968638897,-0.02827203832566738,-0.020347245037555695,0.001084661460481584,0.046784866601228714,-0.03711411729454994,-0.01874317228794098,-0.026953237131237984,0.057653650641441345,-0.05347362905740738,0.00406127842143178,-0.004725798033177853,0.0038419198244810104,0.011449555866420269,-0.04481260105967522,0.026740707457065582,0.005487699527293444,0.015189622528851032,-0.01655558869242668,0.01839543506503105,0.03188752010464668,-0.07560966163873672,0.01762406900525093,0.018275057896971703,-0.0018259439384564757,0.06723477691411972,-0.009778632782399654,0.048699621111154556,0.011191237717866898,-0.023585855960845947,0.06043824926018715,0.033316511660814285,-0.03646458685398102,0.03171839937567711,0.039061401039361954,-0.03299668803811073,0.011758765205740929,0.010716218501329422,0.009823662228882313,0.0055337040685117245,-0.02027781680226326,0.044434238225221634,-0.023417990654706955,0.025252310559153557,-0.01637844741344452,0.026325467973947525,0.012743460945785046,-0.03733571246266365,0.003902609460055828,-0.08160773664712906,-0.0019635192584246397,-0.026534466072916985,-0.02705235593020916,-0.011190318502485752,-0.054863397032022476,-0.022469429299235344,0.011640398763120174,0.03063529171049595,-0.008080911822617054,-0.0083406250923872,0.006630913354456425,0.0009113330743275583,-0.02985531836748123,0.00409055408090353,-0.04290902987122536,-0.0031625544652342796,0.011664650402963161,-0.016200240701436996,0.011208810843527317,0.02941548451781273,0.00859347265213728,-0.04806976392865181,-0.04140814393758774,-0.03160985931754112,-0.06015832722187042,0.0036413148045539856,-0.008150891400873661,-0.01953221671283245,-0.03326787054538727,0.03622032701969147,0.00447751535102725,-0.014975418336689472,-0.020837996155023575,0.00940431747585535,-0.034587785601615906,-0.0346517339348793,-0.031099582090973854,0.028304044157266617,0.031032660976052284,-0.054100193083286285,0.011798872612416744,0.03959617763757706,0.007479812949895859,0.019984576851129532,0.0023249092046171427,0.0017746787052601576,0.06018313020467758,0.0046693491749465466,0.020751764997839928,0.024023782461881638,-0.010837688110768795,-0.025447187945246696,0.04806412383913994,-0.005525335669517517,-0.010020580142736435,0.03294605389237404,0.027606314048171043,-0.03561466559767723,0.01953313499689102,-0.02203267440199852,-0.008873567916452885,-0.03560421243309975,0.0016935168532654643,-0.013018500059843063,0.008578465320169926,-0.03372406214475632,-0.02363605424761772,0.024753427132964134,0.03885240480303764,0.01567702740430832,-0.017730925232172012,0.023637020960450172,0.006857735104858875,0.03580120950937271,0.07028796523809433,-0.04534495621919632,0.0465860590338707,0.0822998434305191,0.014615395106375217,-0.014257163740694523,0.01820719987154007,-0.03359945863485336,-0.0037654018960893154,0.027387084439396858,-0.012686132453382015,-0.03165066987276077,0.025856807827949524,0.013975927606225014,-0.047755271196365356,0.009596090763807297,0.035378195345401764,-0.023031650111079216,-0.052946560084819794,0.03902287408709526,-0.08697628974914551,0.0007650483748875558,-0.02747396193444729,0.039477840065956116,-0.029907599091529846,-0.03874655067920685,0.040488775819540024,-0.002082259627059102,-0.0248007420450449,0.017285620793700218,-0.01977693662047386,-0.033778440207242966,-0.013919990509748459,0.042479753494262695,-0.0031244901474565268,-0.020827699452638626,0.04649842530488968,0.011807293631136417,-0.007776105310767889,0.004212469793856144,0.006400883663445711,-0.021155664697289467,0.013709750957787037,-0.033320777118206024,-0.06184367835521698,0.00829515140503645,0.033842090517282486,0.031176408752799034,-0.03214312344789505,-0.003411807119846344,0.005028052721172571,0.01470850221812725,-0.12694455683231354,0.0018897703848779202,0.01791737787425518,-0.03597062826156616,-0.04750250279903412,0.03563278540968895,-0.056755904108285904,-0.0744595155119896,0.0177844800055027,0.027669426053762436,-0.05378463864326477,-0.01707536168396473,0.0344446562230587,-0.05133352801203728,0.024937760084867477,0.02161405235528946,0.029253298416733742,-0.04146696254611015,-0.022549767047166824,0.03452726826071739,0.029425887390971184,-0.023544203490018845,0.052563101053237915,0.02415809966623783,-0.006997709162533283,-0.036546677350997925,0.0003408585616853088,-0.015558761544525623,-0.04703343287110329,-0.027171388268470764,0.048803865909576416,-0.0120015237480402,0.019953399896621704,0.056174542754888535,0.08862745761871338,0.024920575320720673,0.013407970778644085,-0.042790595442056656,-0.005297323223203421,0.026501381769776344,0.060773059725761414,0.01442534476518631,0.010794523172080517,-0.012532815337181091,0.013845203444361687,-0.013856259174644947,0.03645479679107666,0.000491056649480015,-0.017692672088742256,-0.004449401516467333,0.005704398732632399,0.055144648998975754,0.024484168738126755,0.0009120836621150374,0.02769780158996582,-0.04721996560692787,-0.0437353141605854,-0.03426419943571091,-0.0030353472102433443,0.06532897800207138,0.005175999831408262,0.004642026498913765,-0.010198553092777729,-0.11164741963148117,0.0032722693867981434,-0.0152249401435256,-0.061387427151203156,-0.008149731904268265,0.015415345318615437,0.028577173128724098,0.004164310172200203,-0.03527858853340149,0.004114644601941109,-0.024334382265806198,0.009768039919435978,0.036615774035453796,0.044409748166799545,-0.02218494936823845,-0.013834587298333645,-0.033721648156642914,0.012608193792402744,0.02544715628027916,-0.011161528527736664,0.024172907695174217,0.01728871837258339,-0.034891944378614426,-0.045166727155447006,0.03149036690592766,-0.028676412999629974,-0.025630123913288116,-0.03450291231274605,-0.042594075202941895,-0.004277938045561314,0.004977126140147448,-0.026740560308098793,0.010828261263668537,-0.008786126039922237,0.025455767288804054,0.010332930833101273,-0.029624290764331818,0.025222910568118095,-0.05332495644688606,0.020215490832924843,-0.00725834583863616,-0.014051979407668114,0.025231482461094856,0.02870739810168743,-0.025153715163469315,0.0017486201832070947,0.026120835915207863,-0.01094944030046463,-0.0016203569248318672,-0.004288187250494957,-0.0003944599302485585,-0.04951595887541771,-0.027722930535674095,0.021247882395982742,-0.025441348552703857,-0.029132012277841568,0.02611704356968403,0.03426678851246834,-0.03205306455492973,0.043122775852680206,-0.037530578672885895,0.010123169049620628,0.006026758812367916,0.06166285276412964,0.041947267949581146,-0.028590155765414238,0.005821961909532547,0.03878951445221901,-0.043678734451532364,0.021891968324780464,0.019588861614465714,0.02722681127488613,-0.0072005135007202625,-0.014661637134850025,0.03859248012304306,-0.03036857396364212,-0.025163188576698303,-0.029624272137880325,-0.004484932404011488,-0.02115587703883648,-0.034703899174928665,-0.020665785297751427,0.03465457260608673,-0.032381970435380936,-0.02448100969195366,-0.03633696585893631,-0.0436834841966629,0.023309791460633278,-0.026956286281347275,-0.010952495969831944,0.017641672864556313,-0.0102300513535738,0.003557136282324791,-0.06104337051510811,-0.034807249903678894,-0.005303672980517149,-0.004773163702338934,-0.014427333138883114,-0.0012221967335790396,-0.013541251420974731,0.031239276751875877,0.0007876901072449982,-0.01612892746925354,-0.020762234926223755,-0.012705235742032528,-0.04261665791273117,0.006554049905389547,-0.05181668698787689,-0.0010232614586129785,-0.02920578606426716,0.04016171023249626,0.05727822706103325,-0.0637064278125763,0.042474739253520966,-0.02202245034277439,0.053862642496824265,-0.04091379791498184,-0.00358423194848001,-0.0294108297675848,-0.019521895796060562,0.0008547710021957755,0.05577182397246361,-0.0064692022278904915,-0.039945632219314575,0.03217395022511482,0.008500233292579651,0.0010580146918073297,0.0230677742511034,0.015775218605995178,0.04561731964349747,-0.01410161703824997,0.01426507718861103,0.051053181290626526,-0.015263228677213192,0.06109631061553955,-0.020236019045114517,0.03534768521785736,-0.011433257721364498,0.024448689073324203,-0.002005173359066248,-0.013818801380693913,-0.005125164985656738,-0.011358902789652348,-0.014218742959201336,-0.01632663980126381,-0.0168970488011837,-0.007923102006316185,0.0009882465237751603,0.004870997276157141,-0.0316762775182724,-0.009269092231988907,-0.024636149406433105,-0.03711302578449249,-0.017021233215928078,0.05177905783057213,0.010371671989560127,0.04589727520942688,-0.002231868449598551,0.043219443410634995,-0.06742873787879944,0.012290364131331444,-0.03116980940103531,0.029974913224577904,-0.03351745754480362,0.020384468138217926,0.009360012598335743,-0.026679668575525284,0.03614602982997894,-0.03352091833949089,0.0024363042321056128,0.026183461770415306,-0.00671287951990962,-0.02230038307607174,0.04167525842785835,-0.014078160747885704,-0.01655763015151024,-0.037968363612890244,0.032015733420848846,0.0222366563975811,0.04600703343749046,0.02889135293662548],"k":600,"num_candidates":800,"_name":"knn_query"}}],"minimum_should_match":1}}],"filter":[{"term":{"platform_sku_essaone":true}},{"term":{"platform_rule_essaone":true}},{"terms":{"status":[2,4,5]}}]}},"functions":[{"filter":{"term":{"label_id_list":156}},"weight":1.14},{"filter":{"term":{"label_id_list":157}},"weight":1.13},{"filter":{"term":{"label_id_list":158}},"weight":1.1},{"filter":{"term":{"label_id_list":159}},"weight":1.1},{"filter":{"term":{"label_id_list":162}},"weight":1.05},{"filter":{"term":{"label_id_list":163}},"weight":1.1},{"filter":{"term":{"label_id_list":164}},"weight":1.13},{"filter":{"term":{"label_id_list":165}},"weight":1.15},{"field_value_factor":{"field":"on_sell_days_boost","missing":1.0}},{"filter":{"term":{"is_video":true}},"weight":1.2}],"score_mode":"max","boost_mode":"multiply"}},"track_scores":true,"collapse":{"field":"goods_id"},"aggs":{"unique_count":{"cardinality":{"field":"goods_id"}}}}
  505 +
  506 +
  507 +
  508 +2025-06-28 12:00:09,683 - INFO - [REQ: 175108319225300 UID: -1] TIMING: QA=0ms, queryEncoding=0ms, userProfile=0ms, ES=13905ms, BgeReranking=0ms, BizReranking=5ms, Reranking=6ms, total=14649ms, sku_id_list_filling=732ms
  509 +
  510 +2025-06-28 12:00:34,322 - INFO - [REQ: 175108315581700 UID: -1] TIMING: QA=47ms, queryEncoding=0ms, userProfile=0ms, ES=14587ms, BgeReranking=787ms, BizReranking=1ms, Reranking=789ms, total=16736ms, sku_id_list_filling=1309ms
  511 +
  512 +2025-06-28 12:23:45,140 - INFO - [REQ: 175108461841000 UID: -1] TIMING: QA=0ms, queryEncoding=0ms, userProfile=0ms, ES=5829ms, BgeReranking=0ms, BizReranking=0ms, Reranking=0ms, total=5832ms
  513 +
  514 +2025-06-28 15:07:36,848 - INFO - [REQ: 0 UID: -1] TIMING: QA=139ms, queryEncoding=82ms, userProfile=0ms, ES=13312ms, BgeReranking=2098ms, BizReranking=10ms, Reranking=2111ms, total=15793ms, sku_id_list_filling=199ms
  515 +
  516 +2025-06-28 15:42:52,404 - INFO - [REQ: 17510963864686712 UID: 6712] TIMING: QA=0ms, queryEncoding=0ms, userProfile=1ms, ES=1990ms, BgeReranking=0ms, BizReranking=5ms, Reranking=6ms, total=2090ms, sku_id_list_filling=86ms
  517 +
  518 +
  519 +
  520 +-----------------------------------------
  521 +
  522 +## 参考资料
  523 +
  524 +### 1. 商品搜索、工厂搜索的聚合
  525 +
  526 +#### 1.1 聚合字段优化
  527 +- 商品搜索的 goodsId聚合、和工厂搜索的 brandId聚合,现在的 collapse 是否是最优方案,是否还能同时得到 inner_hits
  528 +
  529 +### 2. aggs 方面
  530 +
  531 +现在的方案是:
  532 +
  533 +```json
  534 +"aggs": {
  535 + "category_stats": {
  536 + "terms": {
  537 + "field": "sale_category_all",
  538 + "size": 100
  539 + }
  540 + }
  541 +}
  542 +```
  543 +
  544 +#### 2.1 top_hits聚合
  545 +预期是通过减少聚合的候选数量(只对topN进行聚合)来提升性能,但是测试好像更差。测试样本量也不够,写法也有好多种,因此看有没有专业建议。
  546 +
  547 +这种方式试了几个好像差不多:
  548 +
  549 +```json
  550 +"aggs": {
  551 + "top_hits_agg": {
  552 + "sampler": {
  553 + "shard_size": 5000 // 关键优化1:仅对前5000文档聚合
  554 + },
  555 + "aggs": {
  556 + // 所有的聚合字段
  557 + }
  558 + }
  559 +}
  560 +```
  561 +
  562 +或者对每个聚合字段加 top_hits 配置,不知道为什么很慢:
  563 +
  564 +```json
  565 +"aggs": {
  566 + "category_stats": {
  567 + "top_hits": {
  568 + "size": 2
  569 + }
  570 + }
  571 +}
  572 +```
  573 +
  574 +#### 2.2 execution_hint优化
  575 +加 "execution_hint": "map" 属性(全内存操作,适用聚合结果数量很小、内存够用的情况)
  576 +
  577 +```json
  578 +"aggs": {
  579 + "tags": {
  580 + "terms": {
  581 + "field": "status",
  582 + "execution_hint": "map"
  583 + }
  584 + }
  585 +}
  586 +```
  587 +
  588 +### 3. 检索表达式
  589 +
  590 +通过function_score设定提权。
  591 +
  592 +```json
  593 +GET /spu/_search
  594 +{
  595 + "aggs": {
  596 + "top_hits_agg": {
  597 + "sampler": {
  598 + "shard_size": 5000 // 关键优化1:仅对前5000文档聚合
  599 + }
  600 + }
  601 + },
  602 + "collapse": {
  603 + "field": "goods_id"
  604 + },
  605 + "from": 0,
  606 + "size": 1000,
  607 + "track_scores": true,
  608 + "query": {
  609 + "function_score": {
  610 + "query": {
  611 + "bool": {
  612 + "filter": [
  613 + {
  614 + "terms": {
  615 + "status": ["2", "4", "5"]
  616 + }
  617 + }
  618 + ],
  619 + "must": [
  620 + {
  621 + "bool": {
  622 + "minimum_should_match": 1,
  623 + "should": [
  624 + {
  625 + "multi_match": {
  626 + "fields": ["name_zh^2.0", "goods_keyword_zh", "category_name_zh", "sale_category_keyword_zh", "sub_name_zh"],
  627 + "query": "合金滑行 喷漆",
  628 + "minimum_should_match": 2,
  629 + "tie_breaker": 0.301
  630 + }
  631 + },
  632 + {
  633 + "knn": {
  634 + "field": "embedding_name_zh",
  635 + "k": 1000,
  636 + "num_candidates": 1000,
  637 + "query_vector": [0.1,1.1,0.6]
  638 + }
  639 + }
  640 + ]
  641 + }
  642 + }
  643 + ]
  644 + }
  645 + },
  646 + "functions": [
  647 + {
  648 + "filter": { "term": { "label_id_list": 156 } },
  649 + "weight": 1.1
  650 + },
  651 + {
  652 + "field_value_factor": {
  653 + "field": "on_sell_days_boost",
  654 + "missing": 1
  655 + }
  656 + }
  657 + ],
  658 + "score_mode": "max",
  659 + "boost_mode": "multiply"
  660 + }
  661 + },
  662 + "rescore": { // 关键优化2:仅对前N结果应用函数评分
  663 + "window_size": 2000,
  664 + "query": {
  665 + "rescore_query": {
  666 + "function_score": {
  667 + "query": {"match_all": {}},
  668 + "functions": [
  669 + {
  670 + "filter": {"term": {"label_id_list": 156}},
  671 + "weight": 1.1
  672 + },
  673 + {
  674 + "field_value_factor": {
  675 + "field": "on_sell_days_boost",
  676 + "missing": 1
  677 + }
  678 + }
  679 + ],
  680 + "score_mode": "max",
  681 + "boost_mode": "multiply"
  682 + }
  683 + }
  684 + }
  685 + }
  686 +}
  687 +```
  688 +
  689 +#### 可以考虑的优化:
  690 +1. 提权只对主检索表达式topN window_size
  691 +
  692 +### 4. ES索引优化
  693 +
  694 +所有的term字段,如果是int类型,改为int,现在是字符串。
  695 +
  696 +不过好像请求用int也能匹配到,所以ES本身检测如果是数值,那么也会为int类型建立一个倒排?这样的话,如果指定为int,只是节省了一些内存(不再需要为字符串类型建立倒排)
  697 +
  698 +### 5. ES配置优化建议
  699 +
  700 +针对单机、低QPS、5百万级别doc,性能优化建议。ES配置方面。
  701 +
... ...
docs/ES/install.sh 0 → 100644
... ... @@ -0,0 +1,47 @@
  1 +
  2 +wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-8.18.0-x86_64.rpm
  3 +# wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-9.0.0-x86_64.rpm
  4 +
  5 +sudo rpm -ivh elasticsearch-8.18.0-x86_64.rpm
  6 +
  7 +sudo systemctl daemon-reload
  8 +sudo systemctl enable elasticsearch.service
  9 +sudo systemctl start elasticsearch.service
  10 +
  11 +
  12 +
  13 +好的,下面是你安装 Elasticsearch 8.18.0 时的详细信息和解释:
  14 +警告:NOKEY
  15 +
  16 +这个警告表示你安装的 RPM 包是用一个密钥(d88e42b4)签名的,但是你的系统没有这个密钥。这通常是无害的,前提是你信任这个包的来源。如果想避免这个警告,你可以导入 Elasticsearch 的 GPG 密钥:
  17 +bash
  18 +sudo rpm --import https://artifacts.elastic.co/GPG-KEY-elasticsearch
  19 +安全自动配置
  20 +
  21 +Elasticsearch 已经自动启用了传输层和 HTTP 层的 TLS 加密,并且为内置的超级用户 elastic 生成了一个密码(6T_Oq+1Gd=E_MZt=zn6X)。你需要保管好这个密码,初次登录时会用到。
  22 +节点配置
  23 +
  24 +如果这个节点需要加入现有的 Elasticsearch 集群,你可以使用集群中生成的 enrollment token 来配置。运行提供的命令来加入集群:
  25 +bash
  26 +/usr/share/elasticsearch/bin/elasticsearch-reconfigure-node --enrollment-token <token-here>
  27 +服务配置
  28 +
  29 +Elasticsearch 没有在安装后自动启动,你需要运行以下命令来使服务自启动并启动它:
  30 +bash
  31 +sudo systemctl daemon-reload
  32 +sudo systemctl enable elasticsearch.service
  33 +sudo systemctl start elasticsearch.service
  34 +tmpfiles.d 的警告
  35 +
  36 +这个警告是由于某个配置文件中引用了 /var/run/elasticsearch,但是这个目录已经不再推荐使用,应该更新为 /run/elasticsearch。这只是一个配置上的小问题,不会影响 Elasticsearch 的正常工作。
  37 +
  38 +下一步:
  39 +
  40 +如果你希望消除 NOKEY 警告,可以导入 GPG 密钥(可选)。
  41 +使用以下命令启动 Elasticsearch 服务:
  42 +bash
  43 +sudo systemctl daemon-reload
  44 +sudo systemctl enable elasticsearch.service
  45 +sudo systemctl start elasticsearch.service
  46 +使用生成的 elastic 用户密码进行初次登录。
  47 +如果你有特殊需求,可以根据提示更新 tmpfiles 配置。
... ...
docs/ES/报警-企业微信消息推送配置说明.md 0 → 100644
... ... @@ -0,0 +1,590 @@
  1 +原始文档地址:
  2 +https://developer.work.weixin.qq.com/document/path/99110
  3 +
  4 +## 目录
  5 +- [如何使用消息推送](#如何使用消息推送)
  6 +- [消息类型及数据格式](#消息类型及数据格式)
  7 + - [文本类型](#文本类型)
  8 + - [markdown类型](#markdown类型)
  9 + - [markdown_v2类型](#markdown_v2类型)
  10 + - [图片类型](#图片类型)
  11 + - [图文类型](#图文类型)
  12 + - [文件类型](#文件类型)
  13 + - [语音类型](#语音类型)
  14 + - [模版卡片类型](#模版卡片类型)
  15 + - [文本通知模版卡片](#文本通知模版卡片)
  16 + - [图文展示模版卡片](#图文展示模版卡片)
  17 +- [消息发送频率限制](#消息发送频率限制)
  18 +- [文件上传接口](#文件上传接口)
  19 +
  20 +## 如何使用消息推送
  21 +
  22 +- 创建者可以在创建消息推送页面、创建完成页面、消息推送详情页面,看到该消息推送特有的 webhookurl。开发者可以按以下说明向这个地址发起 HTTP POST 请求,即可实现给该群组发送消息。下面举个简单的例子。
  23 +
  24 +假设 webhook 是:`https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=693a91f6-7xxx-4bc4-97a0-0ec2sifa5aaa`
  25 +
  26 +> 特别特别要注意:一定要**保护好消息推送的 webhook 地址**,避免泄漏!不要分享到 GitHub、博客等可被公开查阅的地方,否则坏人就可以用你的消息推送来发垃圾消息了。
  27 +
  28 +以下是用 curl 工具往群组推送文本消息的示例(注意要将 url 替换成你的消息推送 webhook 地址,content 必须是 utf8 编码):
  29 +
  30 +```bash
  31 +curl 'https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=693axxx6-7aoc-4bc4-97a0-0ec2sifa5aaa' \
  32 + -H 'Content-Type: application/json' \
  33 + -d '
  34 + {
  35 + "msgtype": "text",
  36 + "text": {
  37 + "content": "hello world"
  38 + }
  39 + }'
  40 +```
  41 +
  42 +- 当前自定义消息推送支持文本(text)、markdown(markdown、markdown_v2)、图片(image)、图文(news)、文件(file)、语音(voice)、模板卡片(template_card)八种消息类型。
  43 +- 消息推送的 text/markdown 类型消息支持在 content 中使用 `@userid` 扩展语法来 @群成员(markdown_v2 类型消息不支持该扩展语法)
  44 +
  45 +## 消息类型及数据格式
  46 +
  47 +### 文本类型
  48 +
  49 +```json
  50 +{
  51 + "msgtype": "text",
  52 + "text": {
  53 + "content": "广州今日天气:29度,大部分多云,降雨概率:60%",
  54 + "mentioned_list":["wangqing","@all"],
  55 + "mentioned_mobile_list":["13800001111","@all"]
  56 + }
  57 +}
  58 +```
  59 +
  60 +| 参数 | 是否必填 | 说明 |
  61 +| --- | --- | --- |
  62 +| msgtype | 是 | 消息类型,此时固定为 text |
  63 +| content | 是 | 文本内容,最长不超过 2048 个字节,必须是 utf8 编码 |
  64 +| mentioned_list | 否 | userid 的列表,提醒群中的指定成员(@某个成员),@all 表示提醒所有人,如果开发者获取不到 userid,可以使用 mentioned_mobile_list |
  65 +| mentioned_mobile_list | 否 | 手机号列表,提醒手机号对应的群成员(@某个成员),@all 表示提醒所有人 |
  66 +
  67 +### markdown 类型
  68 +
  69 +```json
  70 +{
  71 + "msgtype": "markdown",
  72 + "markdown": {
  73 + "content": "实时新增用户反馈<font color=\"warning\">132例</font>,请相关同事注意。\n>类型:<font color=\"comment\">用户反馈</font>\n>普通用户反馈:<font color=\"comment\">117例</font>\n>VIP用户反馈:<font color=\"comment\">15例</font>"
  74 + }
  75 +}
  76 +```
  77 +
  78 +| 参数 | 是否必填 | 说明 |
  79 +| --- | --- | --- |
  80 +| msgtype | 是 | 消息类型,此时固定为 markdown |
  81 +| content | 是 | markdown 内容,最长不超过 4096 个字节,必须是 utf8 编码 |
  82 +
  83 +目前支持的 markdown 语法是如下的子集:
  84 +
  85 +1. 标题(支持 1 至 6 级标题,注意 # 与文字中间要有空格)
  86 +
  87 +```markdown
  88 +# 标题一
  89 +## 标题二
  90 +### 标题三
  91 +#### 标题四
  92 +##### 标题五
  93 +###### 标题六
  94 +```
  95 +
  96 +2. 加粗
  97 +3. 链接
  98 +
  99 +```markdown
  100 +[这是一个链接](https://work.weixin.qq.com/api/doc)
  101 +```
  102 +
  103 +4. 行内代码段(暂不支持跨行)
  104 +5. 引用
  105 +6. 字体颜色(只支持 3 种内置颜色)
  106 +
  107 +```markdown
  108 +<font color="info">绿色</font>
  109 +<font color="comment">灰色</font>
  110 +<font color="warning">橙红色</font>
  111 +```
  112 +
  113 +### markdown_v2 类型
  114 +
  115 +```json
  116 +{
  117 + "msgtype": "markdown_v2",
  118 + "markdown_v2": {
  119 + "content": "# 一、标题\n## 二级标题\n### 三级标题\n# 二、字体\n*斜体*\n\n**加粗**\n# 三、列表 \n- 无序列表 1 \n- 无序列表 2\n - 无序列表 2.1\n - 无序列表 2.2\n1. 有序列表 1\n2. 有序列表 2\n# 四、引用\n> 一级引用\n>>二级引用\n>>>三级引用\n# 五、链接\n[这是一个链接](https:work.weixin.qq.com\\/api\\/doc)\n![](https://res.mail.qq.com/node/ww/wwopenmng/images/independent/doc/test_pic_msg1.png)\n# 六、分割线\n\n---\n# 七、代码\n`这是行内代码`\n```\n这是独立代码块\n```\n\n# 八、表格\n| 姓名 | 文化衫尺寸 | 收货地址 |\n| :----- | :----: | -------: |\n| 张三 | S | 广州 |\n| 李四 | L | 深圳 |\n"
  120 + }
  121 +}
  122 +```
  123 +
  124 +| 参数 | 是否必填 | 说明 |
  125 +| --- | --- | --- |
  126 +| msgtype | 是 | 消息类型,此时固定为 markdown_v2。 |
  127 +| content | 是 | markdown_v2 内容,最长不超过 4096 个字节,必须是 utf8 编码。<br>特殊的,<br>1. markdown_v2 **不支持字体颜色、@群成员** 的语法,具体支持的语法可参考下面说明<br>2. 消息内容在 **客户端 4.1.36 版本以下(安卓端为 4.1.38 以下)** 消息表现为 **纯文本**,建议使用最新客户端版本体验 |
  128 +
  129 +目前支持的 markdown_v2 语法是如下的子集:
  130 +
  131 +1. 标题(支持 1 至 6 级标题,注意 # 与文字中间要有空格)
  132 +
  133 +```markdown
  134 +# 标题一
  135 +## 标题二
  136 +### 标题三
  137 +#### 标题四
  138 +##### 标题五
  139 +###### 标题六
  140 +```
  141 +
  142 +2. 字体
  143 +3. 列表
  144 +
  145 +```markdown
  146 +- 无序列表 1
  147 +- 无序列表 2
  148 + - 无序列表 2.1
  149 + - 无序列表 2.2
  150 +1. 有序列表 1
  151 +2. 有序列表 2
  152 +```
  153 +
  154 +4. 引用
  155 +5. 链接
  156 +
  157 +```markdown
  158 +[这是一个链接](https://work.weixin.qq.com/api/doc)
  159 +![这是一个图片](https://res.mail.qq.com/node/ww/wwopenmng/images/independent/doc/test_pic_msg1.png)
  160 +```
  161 +
  162 +6. 分割线
  163 +7. 代码
  164 +
  165 +```markdown
  166 +`这是行内代码`
  167 +
  168 +```
  169 +这是独立代码块
  170 +```
  171 +```
  172 +
  173 +8. 表格
  174 +
  175 +```markdown
  176 +| 姓名 | 文化衫尺寸 | 收货地址 |
  177 +| :----- | :----: | -------: |
  178 +| 张三 | S | 广州 |
  179 +| 李四 | L | 深圳 |
  180 +```
  181 +
  182 +### 图片类型
  183 +
  184 +```json
  185 +{
  186 + "msgtype": "image",
  187 + "image": {
  188 + "base64": "DATA",
  189 + "md5": "MD5"
  190 + }
  191 +}
  192 +```
  193 +
  194 +| 参数 | 是否必填 | 说明 |
  195 +| --- | --- | --- |
  196 +| msgtype | 是 | 消息类型,此时固定为 image |
  197 +| base64 | 是 | 图片内容的 base64 编码 |
  198 +| md5 | 是 | 图片内容(base64 编码前)的 md5 值 |
  199 +
  200 +> 注:图片(base64 编码前)最大不能超过 2M,支持 JPG、PNG 格式
  201 +
  202 +### 图文类型
  203 +
  204 +```json
  205 +{
  206 + "msgtype": "news",
  207 + "news": {
  208 + "articles" : [
  209 + {
  210 + "title" : "中秋节礼品领取",
  211 + "description" : "今年中秋节公司有豪礼相送",
  212 + "url" : "www.qq.com",
  213 + "picurl" : "https://res.mail.qq.com/node/ww/wwopenmng/images/independent/doc/test_pic_msg1.png"
  214 + }
  215 + ]
  216 + }
  217 +}
  218 +```
  219 +
  220 +| 参数 | 是否必填 | 说明 |
  221 +| --- | --- | --- |
  222 +| msgtype | 是 | 消息类型,此时固定为 news |
  223 +| articles | 是 | 图文消息,一个图文消息支持 1 到 8 条图文 |
  224 +| title | 是 | 标题,不超过 128 个字节,超过会自动截断 |
  225 +| description | 否 | 描述,不超过 512 个字节,超过会自动截断 |
  226 +| url | 是 | 点击后跳转的链接 |
  227 +| picurl | 否 | 图文消息的图片链接,支持 JPG、PNG 格式,较好的效果为大图 1068*455,小图 150*150 |
  228 +
  229 +### 文件类型
  230 +
  231 +```json
  232 +{
  233 + "msgtype": "file",
  234 + "file": {
  235 + "media_id": "3a8asd892asd8asd"
  236 + }
  237 +}
  238 +```
  239 +
  240 +| 参数 | 是否必填 | 说明 |
  241 +| --- | --- | --- |
  242 +| msgtype | 是 | 消息类型,此时固定为 file |
  243 +| media_id | 是 | 文件 id,通过下文的文件上传接口获取 |
  244 +
  245 +### 语音类型
  246 +
  247 +```json
  248 +{
  249 + "msgtype": "voice",
  250 + "voice": {
  251 + "media_id": "MEDIA_ID"
  252 + }
  253 +}
  254 +```
  255 +
  256 +| 参数 | 是否必填 | 说明 |
  257 +| --- | --- | --- |
  258 +| msgtype | 是 | 语音类型,此时固定为 voice |
  259 +| media_id | 是 | 语音文件 id,通过下文的文件上传接口获取 |
  260 +
  261 +### 模版卡片类型
  262 +
  263 +#### 文本通知模版卡片
  264 +
  265 +```json
  266 +{
  267 + "msgtype":"template_card",
  268 + "template_card":{
  269 + "card_type":"text_notice",
  270 + "source":{
  271 + "icon_url":"https://wework.qpic.cn/wwpic/252813_jOfDHtcISzuodLa_1629280209/0",
  272 + "desc":"企业微信",
  273 + "desc_color":0
  274 + },
  275 + "main_title":{
  276 + "title":"欢迎使用企业微信",
  277 + "desc":"您的好友正在邀请您加入企业微信"
  278 + },
  279 + "emphasis_content":{
  280 + "title":"100",
  281 + "desc":"数据含义"
  282 + },
  283 + "quote_area":{
  284 + "type":1,
  285 + "url":"https://work.weixin.qq.com/?from=openApi",
  286 + "appid":"APPID",
  287 + "pagepath":"PAGEPATH",
  288 + "title":"引用文本标题",
  289 + "quote_text":"Jack:企业微信真的很好用~\nBalian:超级好的一款软件!"
  290 + },
  291 + "sub_title_text":"下载企业微信还能抢红包!",
  292 + "horizontal_content_list":[
  293 + {
  294 + "keyname":"邀请人",
  295 + "value":"张三"
  296 + },
  297 + {
  298 + "keyname":"企微官网",
  299 + "value":"点击访问",
  300 + "type":1,
  301 + "url":"https://work.weixin.qq.com/?from=openApi"
  302 + },
  303 + {
  304 + "keyname":"企微下载",
  305 + "value":"企业微信.apk",
  306 + "type":2,
  307 + "media_id":"MEDIAID"
  308 + }
  309 + ],
  310 + "jump_list":[
  311 + {
  312 + "type":1,
  313 + "url":"https://work.weixin.qq.com/?from=openApi",
  314 + "title":"企业微信官网"
  315 + },
  316 + {
  317 + "type":2,
  318 + "appid":"APPID",
  319 + "pagepath":"PAGEPATH",
  320 + "title":"跳转小程序"
  321 + }
  322 + ],
  323 + "card_action":{
  324 + "type":1,
  325 + "url":"https://work.weixin.qq.com/?from=openApi",
  326 + "appid":"APPID",
  327 + "pagepath":"PAGEPATH"
  328 + }
  329 + }
  330 +}
  331 +```
  332 +
  333 +请求参数
  334 +
  335 +| 参数 | 类型 | 必须 | 说明 |
  336 +| --- | --- | --- | --- |
  337 +| msgtype | String | 是 | 消息类型,此时的消息类型固定为 `template_card` |
  338 +| template_card | Object | 是 | 具体的模版卡片参数 |
  339 +
  340 +template_card 的参数说明
  341 +
  342 +| 参数 | 类型 | 必须 | 说明 |
  343 +| --- | --- | --- | --- |
  344 +| card_type | String | 是 | 模版卡片的模版类型,文本通知模版卡片的类型为 `text_notice` |
  345 +| source | Object | 否 | 卡片来源样式信息,不需要来源样式可不填写 |
  346 +| source.icon_url | String | 否 | 来源图片的 url |
  347 +| source.desc | String | 否 | 来源图片的描述,建议不超过 13 个字 |
  348 +| source.desc_color | Int | 否 | 来源文字的颜色,目前支持:0(默认) 灰色,1 黑色,2 红色,3 绿色 |
  349 +| main_title | Object | 是 | 模版卡片的主要内容,包括一级标题和标题辅助信息 |
  350 +| main_title.title | String | 否 | 一级标题,建议不超过 26 个字。**模版卡片主要内容的一级标题 main_title.title 和二级普通文本 sub_title_text 必须有一项填写** |
  351 +| main_title.desc | String | 否 | 标题辅助信息,建议不超过 30 个字 |
  352 +| emphasis_content | Object | 否 | 关键数据样式 |
  353 +| emphasis_content.title | String | 否 | 关键数据样式的数据内容,建议不超过 10 个字 |
  354 +| emphasis_content.desc | String | 否 | 关键数据样式的数据描述内容,建议不超过 15 个字 |
  355 +| quote_area | Object | 否 | 引用文献样式,建议不与关键数据共用 |
  356 +| quote_area.type | Int | 否 | 引用文献样式区域点击事件,0 或不填代表没有点击事件,1 代表跳转 url,2 代表跳转小程序 |
  357 +| quote_area.url | String | 否 | 点击跳转的 url,quote_area.type 是 1 时必填 |
  358 +| quote_area.appid | String | 否 | 点击跳转的小程序的 appid,quote_area.type 是 2 时必填 |
  359 +| quote_area.pagepath | String | 否 | 点击跳转的小程序的 pagepath,quote_area.type 是 2 时选填 |
  360 +| quote_area.title | String | 否 | 引用文献样式的标题 |
  361 +| quote_area.quote_text | String | 否 | 引用文献样式的引用文案 |
  362 +| sub_title_text | String | 否 | 二级普通文本,建议不超过 112 个字。**模版卡片主要内容的一级标题 main_title.title 和二级普通文本 sub_title_text 必须有一项填写** |
  363 +| horizontal_content_list | Object[] | 否 | 二级标题+文本列表,该字段可为空数组,但有数据的话需确认对应字段是否必填,列表长度不超过 6 |
  364 +| horizontal_content_list.type | Int | 否 | 模版卡片的二级标题信息内容支持的类型,1 是 url,2 是文件附件,3 代表点击跳转成员详情 |
  365 +| horizontal_content_list.keyname | String | 是 | 二级标题,建议不超过 5 个字 |
  366 +| horizontal_content_list.value | String | 否 | 二级文本,如果 horizontal_content_list.type 是 2,该字段代表文件名称(要包含文件类型),建议不超过 26 个字 |
  367 +| horizontal_content_list.url | String | 否 | 链接跳转的 url,horizontal_content_list.type 是 1 时必填 |
  368 +| horizontal_content_list.media_id | String | 否 | 附件的 [media_id](#文件上传接口),horizontal_content_list.type 是 2 时必填 |
  369 +| horizontal_content_list.userid | String | 否 | 成员详情的 userid,horizontal_content_list.type 是 3 时必填 |
  370 +| jump_list | Object[] | 否 | 跳转指引样式的列表,该字段可为空数组,但有数据的话需确认对应字段是否必填,列表长度不超过 3 |
  371 +| jump_list.type | Int | 否 | 跳转链接类型,0 或不填代表不是链接,1 代表跳转 url,2 代表跳转小程序 |
  372 +| jump_list.title | String | 是 | 跳转链接样式的文案内容,建议不超过 13 个字 |
  373 +| jump_list.url | String | 否 | 跳转链接的 url,jump_list.type 是 1 时必填 |
  374 +| jump_list.appid | String | 否 | 跳转链接的小程序的 appid,jump_list.type 是 2 时必填 |
  375 +| jump_list.pagepath | String | 否 | 跳转链接的小程序的 pagepath,jump_list.type 是 2 时选填 |
  376 +| card_action | Object | 是 | 整体卡片的点击跳转事件,text_notice 模版卡片中该字段为必填项 |
  377 +| card_action.type | Int | 是 | 卡片跳转类型,1 代表跳转 url,2 代表打开小程序。text_notice 模版卡片中该字段取值范围为 [1,2] |
  378 +| card_action.url | String | 否 | 跳转事件的 url,card_action.type 是 1 时必填 |
  379 +| card_action.appid | String | 否 | 跳转事件的小程序的 appid,card_action.type 是 2 时必填 |
  380 +| card_action.pagepath | String | 否 | 跳转事件的小程序的 pagepath,card_action.type 是 2 时选填 |
  381 +
  382 +#### 图文展示模版卡片
  383 +
  384 +```json
  385 +{
  386 + "msgtype":"template_card",
  387 + "template_card":{
  388 + "card_type":"news_notice",
  389 + "source":{
  390 + "icon_url":"https://wework.qpic.cn/wwpic/252813_jOfDHtcISzuodLa_1629280209/0",
  391 + "desc":"企业微信",
  392 + "desc_color":0
  393 + },
  394 + "main_title":{
  395 + "title":"欢迎使用企业微信",
  396 + "desc":"您的好友正在邀请您加入企业微信"
  397 + },
  398 + "card_image":{
  399 + "url":"https://wework.qpic.cn/wwpic/354393_4zpkKXd7SrGMvfg_1629280616/0",
  400 + "aspect_ratio":2.25
  401 + },
  402 + "image_text_area":{
  403 + "type":1,
  404 + "url":"https://work.weixin.qq.com",
  405 + "title":"欢迎使用企业微信",
  406 + "desc":"您的好友正在邀请您加入企业微信",
  407 + "image_url":"https://wework.qpic.cn/wwpic/354393_4zpkKXd7SrGMvfg_1629280616/0"
  408 + },
  409 + "quote_area":{
  410 + "type":1,
  411 + "url":"https://work.weixin.qq.com/?from=openApi",
  412 + "appid":"APPID",
  413 + "pagepath":"PAGEPATH",
  414 + "title":"引用文本标题",
  415 + "quote_text":"Jack:企业微信真的很好用~\nBalian:超级好的一款软件!"
  416 + },
  417 + "vertical_content_list":[
  418 + {
  419 + "title":"惊喜红包等你来拿",
  420 + "desc":"下载企业微信还能抢红包!"
  421 + }
  422 + ],
  423 + "horizontal_content_list":[
  424 + {
  425 + "keyname":"邀请人",
  426 + "value":"张三"
  427 + },
  428 + {
  429 + "keyname":"企微官网",
  430 + "value":"点击访问",
  431 + "type":1,
  432 + "url":"https://work.weixin.qq.com/?from=openApi"
  433 + },
  434 + {
  435 + "keyname":"企微下载",
  436 + "value":"企业微信.apk",
  437 + "type":2,
  438 + "media_id":"MEDIAID"
  439 + }
  440 + ],
  441 + "jump_list":[
  442 + {
  443 + "type":1,
  444 + "url":"https://work.weixin.qq.com/?from=openApi",
  445 + "title":"企业微信官网"
  446 + },
  447 + {
  448 + "type":2,
  449 + "appid":"APPID",
  450 + "pagepath":"PAGEPATH",
  451 + "title":"跳转小程序"
  452 + }
  453 + ],
  454 + "card_action":{
  455 + "type":1,
  456 + "url":"https://work.weixin.qq.com/?from=openApi",
  457 + "appid":"APPID",
  458 + "pagepath":"PAGEPATH"
  459 + }
  460 + }
  461 +}
  462 +```
  463 +
  464 +请求参数
  465 +
  466 +| 参数 | 类型 | 必须 | 说明 |
  467 +| --- | --- | --- | --- |
  468 +| msgtype | String | 是 | 模版卡片的消息类型为 `template_card` |
  469 +| template_card | Object | 是 | 具体的模版卡片参数 |
  470 +
  471 +template_card 的参数说明
  472 +
  473 +| 参数 | 类型 | 必须 | 说明 |
  474 +| --- | --- | --- | --- |
  475 +| card_type | String | 是 | 模版卡片的模版类型,图文展示模版卡片的类型为 `news_notice` |
  476 +| source | Object | 否 | 卡片来源样式信息,不需要来源样式可不填写 |
  477 +| source.icon_url | String | 否 | 来源图片的 url |
  478 +| source.desc | String | 否 | 来源图片的描述,建议不超过 13 个字 |
  479 +| source.desc_color | Int | 否 | 来源文字的颜色,目前支持:0(默认) 灰色,1 黑色,2 红色,3 绿色 |
  480 +| main_title | Object | 是 | 模版卡片的主要内容,包括一级标题和标题辅助信息 |
  481 +| main_title.title | String | 是 | 一级标题,建议不超过 26 个字 |
  482 +| main_title.desc | String | 否 | 标题辅助信息,建议不超过 30 个字 |
  483 +| card_image | Object | 是 | 图片样式 |
  484 +| card_image.url | String | 是 | 图片的 url |
  485 +| card_image.aspect_ratio | Float | 否 | 图片的宽高比,宽高比要小于 2.25,大于 1.3,不填该参数默认 1.3 |
  486 +| image_text_area | Object | 否 | 左图右文样式 |
  487 +| image_text_area.type | Int | 否 | 左图右文样式区域点击事件,0 或不填代表没有点击事件,1 代表跳转 url,2 代表跳转小程序 |
  488 +| image_text_area.url | String | 否 | 点击跳转的 url,image_text_area.type 是 1 时必填 |
  489 +| image_text_area.appid | String | 否 | 点击跳转的小程序的 appid,必须是与当前应用关联的小程序,image_text_area.type 是 2 时必填 |
  490 +| image_text_area.pagepath | String | 否 | 点击跳转的小程序的 pagepath,image_text_area.type 是 2 时选填 |
  491 +| image_text_area.title | String | 否 | 左图右文样式的标题 |
  492 +| image_text_area.desc | String | 否 | 左图右文样式的描述 |
  493 +| image_text_area.image_url | String | 是 | 左图右文样式的图片 url |
  494 +| quote_area | Object | 否 | 引用文献样式,建议不与关键数据共用 |
  495 +| quote_area.type | Int | 否 | 引用文献样式区域点击事件,0 或不填代表没有点击事件,1 代表跳转 url,2 代表跳转小程序 |
  496 +| quote_area.url | String | 否 | 点击跳转的 url,quote_area.type 是 1 时必填 |
  497 +| quote_area.appid | String | 否 | 点击跳转的小程序的 appid,quote_area.type 是 2 时必填 |
  498 +| quote_area.pagepath | String | 否 | 点击跳转的小程序的 pagepath,quote_area.type 是 2 时选填 |
  499 +| quote_area.title | String | 否 | 引用文献样式的标题 |
  500 +| quote_area.quote_text | String | 否 | 引用文献样式的引用文案 |
  501 +| vertical_content_list | Object[] | 否 | 卡片二级垂直内容,该字段可为空数组,但有数据的话需确认对应字段是否必填,列表长度不超过 4 |
  502 +| vertical_content_list.title | String | 是 | 卡片二级标题,建议不超过 26 个字 |
  503 +| vertical_content_list.desc | String | 否 | 二级普通文本,建议不超过 112 个字 |
  504 +| horizontal_content_list | Object[] | 否 | 二级标题+文本列表,该字段可为空数组,但有数据的话需确认对应字段是否必填,列表长度不超过 6 |
  505 +| horizontal_content_list.type | Int | 否 | 模版卡片的二级标题信息内容支持的类型,1 是 url,2 是文件附件,3 代表点击跳转成员详情 |
  506 +| horizontal_content_list.keyname | String | 是 | 二级标题,建议不超过 5 个字 |
  507 +| horizontal_content_list.value | String | 否 | 二级文本,如果 horizontal_content_list.type 是 2,该字段代表文件名称(要包含文件类型),建议不超过 26 个字 |
  508 +| horizontal_content_list.url | String | 否 | 链接跳转的 url,horizontal_content_list.type 是 1 时必填 |
  509 +| horizontal_content_list.media_id | String | 否 | 附件的 [media_id](#文件上传接口),horizontal_content_list.type 是 2 时必填 |
  510 +| horizontal_content_list.userid | String | 否 | 成员详情的 userid,horizontal_content_list.type 是 3 时必填 |
  511 +| jump_list | Object[] | 否 | 跳转指引样式的列表,该字段可为空数组,但有数据的话需确认对应字段是否必填,列表长度不超过 3 |
  512 +| jump_list.type | Int | 否 | 跳转链接类型,0 或不填代表不是链接,1 代表跳转 url,2 代表跳转小程序 |
  513 +| jump_list.title | String | 是 | 跳转链接样式的文案内容,建议不超过 13 个字 |
  514 +| jump_list.url | String | 否 | 跳转链接的 url,jump_list.type 是 1 时必填 |
  515 +| jump_list.appid | String | 否 | 跳转链接的小程序的 appid,jump_list.type 是 2 时必填 |
  516 +| jump_list.pagepath | String | 否 | 跳转链接的小程序的 pagepath,jump_list.type 是 2 时选填 |
  517 +| card_action | Object | 是 | 整体卡片的点击跳转事件,news_notice 模版卡片中该字段为必填项 |
  518 +| card_action.type | Int | 是 | 卡片跳转类型,1 代表跳转 url,2 代表打开小程序。news_notice 模版卡片中该字段取值范围为 [1,2] |
  519 +| card_action.url | String | 否 | 跳转事件的 url,card_action.type 是 1 时必填 |
  520 +| card_action.appid | String | 否 | 跳转事件的小程序的 appid,card_action.type 是 2 时必填 |
  521 +| card_action.pagepath | String | 否 | 跳转事件的小程序的 pagepath,card_action.type 是 2 时选填 |
  522 +
  523 +## 消息发送频率限制
  524 +
  525 +每个消息推送发送的消息不能超过 20 条/分钟。
  526 +
  527 +## 文件上传接口
  528 +
  529 +> 素材上传得到 media_id,该 media_id 仅三天内有效
  530 +>
  531 +> media_id 只能是对应上传文件的消息推送可以使用
  532 +
  533 +**请求方式:** POST(**HTTPS**)
  534 +
  535 +**请求地址:** `https://qyapi.weixin.qq.com/cgi-bin/webhook/upload_media?key=KEY&type=TYPE`
  536 +
  537 +使用 multipart/form-data POST 上传文件或语音,文件标识名为"media"
  538 +
  539 +**参数说明:**
  540 +
  541 +| 参数 | 必须 | 说明 |
  542 +| --- | --- | --- |
  543 +| key | 是 | 调用接口凭证,消息推送 webhookurl 中的 key 参数 |
  544 +| type | 是 | 文件类型,分别有语音(voice)和普通文件(file) |
  545 +
  546 +POST 的请求包中,form-data 中媒体文件标识,应包含有 **filename**、filelength、content-type 等信息
  547 +
  548 +> filename 标识文件展示的名称。比如,使用该 media_id 发消息时,展示的文件名由该字段控制
  549 +
  550 +**请求示例:**
  551 +
  552 +```
  553 +POST https://qyapi.weixin.qq.com/cgi-bin/webhook/upload_media?key=693a91f6-7xxx-4bc4-97a0-0ec2sifa5aaa&type=file HTTP/1.1
  554 +Content-Type: multipart/form-data; boundary=-------------------------acebdf13572468
  555 +Content-Length: 220
  556 +
  557 +---------------------------acebdf13572468
  558 +Content-Disposition: form-data; name="media";filename="wework.txt"; filelength=6
  559 +Content-Type: application/octet-stream
  560 +
  561 +mytext
  562 +---------------------------acebdf13572468--
  563 +```
  564 +
  565 +**返回数据:**
  566 +
  567 +```json
  568 +{
  569 +"errcode": 0,
  570 +"errmsg": "ok",
  571 +"type": "file",
  572 +"media_id": "1G6nrLmr5EC3MMb_-zK1dDdzmd0p7cNliYu9V5w7o8K0",
  573 +"created_at": "1380000000"
  574 +}
  575 +```
  576 +
  577 +**参数说明:**
  578 +
  579 +| 参数 | 说明 |
  580 +| --- | --- |
  581 +| type | 文件类型,分别有语音(voice)和普通文件(file) |
  582 +| media_id | 媒体文件上传后获取的唯一标识,3 天内有效 |
  583 +| created_at | 媒体文件上传时间戳 |
  584 +
  585 +**上传的文件限制:**
  586 +
  587 +所有类型的文件大小均要求大于 5 个字节
  588 +
  589 +- 普通文件(file):文件大小不超过 20M
  590 +- 语音(voice):文件大小不超过 2M,播放长度不超过 60s,**仅支持** AMR 格式
0 591 \ No newline at end of file
... ...
docs/Usage-Guide.md
... ... @@ -49,9 +49,9 @@ docker run -d \
49 49  
50 50 参考 [Elasticsearch官方文档](https://www.elastic.co/guide/en/elasticsearch/reference/8.11/install-elasticsearch.html)
51 51  
52   -#### 3. 配置环境变量
  52 +#### 3. 配置环境变量(支持多环境)
53 53  
54   -创建 `.env` 文件
  54 +创建 `.env` 文件(以本地 / prod 环境为例)
55 55  
56 56 ```bash
57 57 # MySQL配置
... ... @@ -74,6 +74,11 @@ REDIS_PASSWORD=BMfv5aI31kgHWtlx
74 74 # DeepL翻译API(可选)
75 75 DEEPL_AUTH_KEY=c9293ab4-ad25-479b-919f-ab4e63b429ed
76 76  
  77 +# 运行环境(用于区分 prod / uat / test / dev)
  78 +RUNTIME_ENV=prod
  79 +# ES 索引命名空间前缀(用于按环境隔离索引,prod 通常留空)
  80 +ES_INDEX_NAMESPACE=
  81 +
77 82 # API服务配置
78 83 API_HOST=0.0.0.0
79 84 API_PORT=6002
... ... @@ -101,7 +106,7 @@ cd /home/tw/SearchEngine
101 106 - **后端API**: http://localhost:6002
102 107 - **API文档**: http://localhost:6002/docs
103 108  
104   -### 方式2: 分步启动
  109 +### 方式2: 分步启动(单环境)
105 110  
106 111 #### 启动后端服务
107 112  
... ... @@ -109,7 +114,7 @@ cd /home/tw/SearchEngine
109 114 ./scripts/start_backend.sh
110 115 ```
111 116  
112   -后端API会在 http://localhost:6002 启动
  117 +后端API会在 http://localhost:6002 启动(使用当前 `.env` 中的 ES_HOST / DB_HOST / RUNTIME_ENV / ES_INDEX_NAMESPACE)
113 118  
114 119 #### 启动前端服务
115 120  
... ... @@ -119,7 +124,50 @@ cd /home/tw/SearchEngine
119 124  
120 125 前端界面会在 http://localhost:6003 启动
121 126  
122   -### 方式3: 手动启动
  127 +### 方式3: 多环境示例(prod / uat)
  128 +
  129 +假设有两套环境:
  130 +
  131 +- **prod**:正式环境,RUNTIME_ENV=prod,ES_INDEX_NAMESPACE 为空
  132 +- **uat**:联调环境,RUNTIME_ENV=uat,ES_INDEX_NAMESPACE=uat_
  133 +
  134 +可以在项目根目录准备两个配置文件:
  135 +
  136 +- `.env.prod`:
  137 +
  138 +```bash
  139 +RUNTIME_ENV=prod
  140 +ES_INDEX_NAMESPACE=
  141 +ES_HOST=http://prod-es:9200
  142 +DB_HOST=prod-mysql
  143 +...
  144 +```
  145 +
  146 +- `.env.uat`:
  147 +
  148 +```bash
  149 +RUNTIME_ENV=uat
  150 +ES_INDEX_NAMESPACE=uat_
  151 +ES_HOST=http://uat-es:9200
  152 +DB_HOST=uat-mysql
  153 +...
  154 +```
  155 +
  156 +启动不同环境时:
  157 +
  158 +```bash
  159 +# 启动 UAT 后端 + 索引服务
  160 +cp .env.uat .env
  161 +./scripts/start_backend.sh
  162 +./scripts/start_indexer.sh
  163 +
  164 +# 启动 PROD 后端 + 索引服务
  165 +cp .env.prod .env
  166 +./scripts/start_backend.sh
  167 +./scripts/start_indexer.sh
  168 +```
  169 +
  170 +### 方式4: 手动启动
123 171  
124 172 #### 启动后端API服务
125 173  
... ... @@ -345,19 +393,25 @@ curl -X POST http://localhost:6002/search/image \
345 393  
346 394 ## 8. Suggestion 索引与接口使用
347 395  
348   -### 8.1 构建 Suggestion 索引(全量
  396 +### 8.1 构建 Suggestion 索引(全量,多环境
349 397  
350 398 Suggestion 索引会从:
351 399  
352 400 - ES 商品索引:`title.{lang}`, `qanchors.{lang}`
353 401 - MySQL 日志表:`shoplazza_search_log.query`(含 `language`、`request_params`)
354 402  
355   -聚合生成 `search_suggestions_tenant_{tenant_id}`。
  403 +聚合生成 `{ES_INDEX_NAMESPACE}search_suggestions_tenant_{tenant_id}`。
356 404  
357   -在项目根目录执行
  405 +在项目根目录执行(以 UAT 环境、tenant_id=162 为例)
358 406  
359 407 ```bash
360   -# 为指定租户全量重建 suggestion 索引(会删除旧索引)
  408 +# 1. 切换到 UAT 配置(包含 ES_INDEX_NAMESPACE=uat_)
  409 +cp .env.uat .env
  410 +
  411 +# 2. 启动索引服务(如尚未启动)
  412 +./scripts/start_indexer.sh
  413 +
  414 +# 3. 为指定租户全量重建 suggestion 索引(会删除旧索引)
361 415 python main.py build-suggestions \
362 416 --tenant-id 162 \
363 417 --es-host http://localhost:9200 \
... ... @@ -365,6 +419,9 @@ python main.py build-suggestions \
365 419 --recreate
366 420 ```
367 421  
  422 +UAT 环境下,索引名为:`uat_search_suggestions_tenant_162`;
  423 +prod 环境下(ES_INDEX_NAMESPACE 为空),索引名为:`search_suggestions_tenant_162`。
  424 +
368 425 可选参数:
369 426  
370 427 - `--days`:回溯日志天数(默认 30)
... ... @@ -378,10 +435,73 @@ python main.py build-suggestions \
378 435 全量构建完成后,可直接通过 `/search/suggestions` 获取自动补全结果:
379 436  
380 437 ```bash
  438 +# UAT 环境(本地或 UAT 集群)
381 439 curl "http://localhost:6002/search/suggestions?q=iph&size=5&language=en&with_results=true" \
382 440 -H "X-Tenant-ID: 162"
  441 +
  442 +# PROD 环境(域名 / 端口按实际部署调整)
  443 +curl "https://api.yourdomain.com/search/suggestions?q=iph&size=5&language=en&with_results=true" \
  444 + -H "X-Tenant-ID: 162"
  445 +```
  446 +
  447 +### 8.3 商品索引构建(search_products,多环境例子)
  448 +
  449 +以 tenant_id=162 为例,分别在 UAT / PROD 构建商品索引。
  450 +
  451 +#### UAT 环境(索引前缀 uat_)
  452 +
  453 +```bash
  454 +cd /home/tw/SearchEngine
  455 +
  456 +# 1. 切换到 UAT 环境配置
  457 +cp .env.uat .env
  458 +
  459 +# 2. 启动 indexer 服务(如尚未启动)
  460 +./scripts/start_indexer.sh
  461 +
  462 +# 3. 可选:重建索引结构(会删除旧索引)
  463 +./scripts/create_tenant_index.sh 162
  464 +# 实际创建的索引名为:uat_search_products_tenant_162
  465 +
  466 +# 4. 导入商品数据(全量索引)
  467 +curl -X POST "http://localhost:6004/indexer/reindex" \
  468 + -H "Content-Type: application/json" \
  469 + -d '{
  470 + "tenant_id": "162",
  471 + "batch_size": 500
  472 + }'
383 473 ```
384 474  
  475 +#### PROD 环境(无前缀)
  476 +
  477 +```bash
  478 +cd /home/tw/SearchEngine
  479 +
  480 +# 1. 切换到 PROD 环境配置
  481 +cp .env.prod .env
  482 +
  483 +# 2. 启动 indexer 服务
  484 +./scripts/start_indexer.sh
  485 +
  486 +# 3. 可选:重建索引结构(search_products_tenant_162)
  487 +./scripts/create_tenant_index.sh 162
  488 +
  489 +# 4. 导入商品数据
  490 +curl -X POST "http://localhost:6004/indexer/reindex" \
  491 + -H "Content-Type: application/json" \
  492 + -d '{
  493 + "tenant_id": "162",
  494 + "batch_size": 500
  495 + }'
  496 +```
  497 +
  498 +完成后:
  499 +
  500 +- UAT 环境商品索引:`uat_search_products_tenant_162`
  501 +- PROD 环境商品索引:`search_products_tenant_162`
  502 +
  503 +两套环境的搜索 / suggestion API 调用完全一致,只是连接到各自的后端 / ES。
  504 +
385 505 接口返回结构详见 `docs/搜索API对接指南.md` 的“3.7 搜索建议接口”章节。
386 506  
387 507 ---
... ...
docs/搜索API对接指南.md
... ... @@ -867,20 +867,30 @@ curl &quot;http://localhost:6002/search/12345&quot; -H &quot;X-Tenant-ID: 162&quot;
867 867  
868 868 为租户创建索引需要两个步骤:
869 869  
870   -1. **创建索引结构**(可选,仅在需要更新 mapping 时执行)
  870 +1. **创建索引结构**(可选,仅在需要更新 mapping 或在新环境首次创建时执行)
871 871 - 使用脚本创建 ES 索引结构(基于 `mappings/search_products.json`)
872 872 - 如果索引已存在,会提示用户确认(会删除现有数据)
873 873  
874 874 2. **导入数据**(必需)
875 875 - 使用全量索引接口 `/indexer/reindex` 导入数据
876 876  
877   -**创建索引结构**:
  877 +**创建索引结构(支持多环境 namespace)**:
878 878  
879 879 ```bash
  880 +# 以 UAT 环境为例:
  881 +# 1. 准备 UAT 环境的 .env(包含 UAT 的 ES_HOST/DB_HOST 等)
  882 +# 2. 设置环境前缀(也可以直接在 .env 中配置):
  883 +export RUNTIME_ENV=uat
  884 +export ES_INDEX_NAMESPACE=uat_
  885 +
  886 +# 3. 为 tenant_id=170 创建索引结构
880 887 ./scripts/create_tenant_index.sh 170
881 888 ```
882 889  
883   -脚本会自动从项目根目录的 `.env` 文件加载 ES 配置。
  890 +脚本会自动从项目根目录的 `.env` 文件加载 ES 配置,并根据 `ES_INDEX_NAMESPACE` 创建:
  891 +
  892 +- prod 环境(ES_INDEX_NAMESPACE 为空):`search_products_tenant_170`
  893 +- UAT 环境(ES_INDEX_NAMESPACE=uat_):`uat_search_products_tenant_170`
884 894  
885 895 **注意事项**:
886 896 - ⚠️ 如果索引已存在,脚本会提示确认,确认后会删除现有数据
... ... @@ -910,7 +920,7 @@ curl &quot;http://localhost:6002/search/12345&quot; -H &quot;X-Tenant-ID: 162&quot;
910 920  
911 921 #### 响应格式
912 922  
913   -**成功响应(200 OK)**:
  923 +**成功响应(200 OK)**(示例,实际 `index_name` 会带上 tenant 和环境前缀):
914 924 ```json
915 925 {
916 926 "success": true,
... ... @@ -918,7 +928,7 @@ curl &quot;http://localhost:6002/search/12345&quot; -H &quot;X-Tenant-ID: 162&quot;
918 928 "indexed": 1000,
919 929 "failed": 0,
920 930 "elapsed_time": 12.34,
921   - "index_name": "search_products",
  931 + "index_name": "search_products_tenant_162",
922 932 "tenant_id": "162"
923 933 }
924 934 ```
... ...
full_bulk.sh deleted
... ... @@ -1,2 +0,0 @@
1   -#curl -X POST "http://localhost:6004/indexer/reindex" -H "Content-Type: application/json" -d '{"tenant_id":"162","batch_size":500}'
2   -curl -X POST "http://localhost:6004/indexer/reindex" -H "Content-Type: application/json" -d '{"tenant_id":"170","batch_size":500}'
indexer/README.md
... ... @@ -52,8 +52,10 @@
52 52 4. **索引结构调整为 per-tenant**
53 53 - 在 Java 中已统一使用:
54 54 - `indexName = elasticsearchProperties.buildIndexName(tenantId);`
55   - - 索引命名形如:`search_products_tenant_{tenant_id}`。
56   - - Python 侧对应 `get_tenant_index_name(tenant_id)`。
  55 + - 索引命名形如:`{namespace}search_products_tenant_{tenant_id}`,其中 `namespace` 用于区分 prod/uat/test 等环境。
  56 + - Python 侧通过 `indexer/mapping_generator.get_tenant_index_name(tenant_id)` 统一生成索引名:
  57 + - 索引命名规则为:`{ES_INDEX_NAMESPACE}search_products_tenant_{tenant_id}`;
  58 + - `ES_INDEX_NAMESPACE` 来源于 `config.env_config`,默认 prod 环境为空字符串,其它环境可设置为 `uat_`、`test_` 等。
57 59  
58 60 ### 2.2 Java 侧不再深入关心的部分
59 61  
... ... @@ -512,9 +514,9 @@ if spu.tags:
512 514 - **单文档查看**:`POST /indexer/documents`
513 515 - **健康检查**:`GET /indexer/health`
514 516  
515   -### 10.3 典型测试流程(以 tenant 170, spu_id 223167 为例
  517 +### 10.3 典型测试流程(以 tenant 170, spu_id 223167 为例,支持多环境
516 518  
517   -1. 启动 indexer 服务
  519 +1. 启动 indexer 服务(以本地或 prod 环境为例,.env 中 RUNTIME_ENV=prod, ES_INDEX_NAMESPACE='')
518 520  
519 521 ```bash
520 522 ./scripts/stop.sh
... ... @@ -562,9 +564,10 @@ curl -X POST &quot;http://127.0.0.1:6004/indexer/build-docs-from-db&quot; \
562 564 }
563 565 ```
564 566  
565   -4. 使用 `docs/常用查询 - ES.md` 中的查询,对应验证 ES 索引中的文档
  567 +4. 使用 `docs/常用查询 - ES.md` 中的查询,对应验证 ES 索引中的文档(注意索引名前缀)
566 568  
567 569 ```bash
  570 +# prod / 本地环境:ES_INDEX_NAMESPACE 为空,索引名为 search_products_tenant_170
568 571 curl -u 'essa:***' \
569 572 -X GET 'http://localhost:9200/search_products_tenant_170/_search?pretty' \
570 573 -H 'Content-Type: application/json' \
... ... @@ -579,6 +582,23 @@ curl -u &#39;essa:***&#39; \
579 582 }
580 583 }
581 584 }'
  585 +
  586 +# UAT 环境:假设 .env 中配置 ES_INDEX_NAMESPACE=uat_,
  587 +# 则索引名为 uat_search_products_tenant_170
  588 +curl -u 'essa:***' \
  589 + -X GET 'http://localhost:9200/uat_search_products_tenant_170/_search?pretty' \
  590 + -H 'Content-Type: application/json' \
  591 + -d '{
  592 + "size": 5,
  593 + "_source": ["title", "tags"],
  594 + "query": {
  595 + "bool": {
  596 + "filter": [
  597 + { "term": { "spu_id": "223167" } }
  598 + ]
  599 + }
  600 + }
  601 + }'
582 602 ```
583 603  
584 604 通过这套流程可以完整验证:MySQL → Python 富化 → ES doc → ES 查询 的全链路行为是否符合预期。*** End Patch"""} ***!
... ...
indexer/mapping_generator.py
... ... @@ -9,6 +9,8 @@ import json
9 9 import logging
10 10 from pathlib import Path
11 11  
  12 +from config.env_config import ES_INDEX_NAMESPACE
  13 +
12 14 logger = logging.getLogger(__name__)
13 15  
14 16 # Default index name (deprecated, use get_tenant_index_name instead)
... ... @@ -21,14 +23,15 @@ DEFAULT_MAPPING_FILE = Path(__file__).parent.parent / &quot;mappings&quot; / &quot;search_produ
21 23 def get_tenant_index_name(tenant_id: str) -> str:
22 24 """
23 25 Generate index name for a tenant.
24   -
25   - Args:
26   - tenant_id: Tenant ID
27   -
28   - Returns:
29   - Index name in format: search_products_tenant_{tenant_id}
  26 +
  27 + 索引命名规则统一为:
  28 + {ES_INDEX_NAMESPACE}search_products_tenant_{tenant_id}
  29 +
  30 + 其中 ES_INDEX_NAMESPACE 由 config.env_config.ES_INDEX_NAMESPACE 控制,
  31 + 用于区分 prod/uat/test 等不同运行环境。
30 32 """
31   - return f"search_products_tenant_{tenant_id}"
  33 + prefix = ES_INDEX_NAMESPACE or ""
  34 + return f"{prefix}search_products_tenant_{tenant_id}"
32 35  
33 36  
34 37 def load_mapping(mapping_file: str = None) -> Dict[str, Any]:
... ...
scripts/create_tenant_index.sh
... ... @@ -16,6 +16,7 @@ fi
16 16 ES_HOST="${ES_HOST:-http://localhost:9200}"
17 17 ES_USERNAME="${ES_USERNAME:-}"
18 18 ES_PASSWORD="${ES_PASSWORD:-}"
  19 +ES_INDEX_NAMESPACE="${ES_INDEX_NAMESPACE:-}"
19 20  
20 21 # 检查命令行参数
21 22 if [ $# -eq 0 ]; then
... ... @@ -25,7 +26,8 @@ if [ $# -eq 0 ]; then
25 26 fi
26 27  
27 28 TENANT_ID="$1"
28   -ES_INDEX="search_products_tenant_${TENANT_ID}"
  29 +BASE_INDEX_NAME="search_products_tenant_${TENANT_ID}"
  30 +ES_INDEX="${ES_INDEX_NAMESPACE}${BASE_INDEX_NAME}"
29 31 MAPPING_FILE="mappings/search_products.json"
30 32  
31 33 # 检查 mapping 文件是否存在
... ... @@ -37,6 +39,7 @@ fi
37 39 # 手动确认
38 40 echo "创建索引前,将删除已有的同名索引。"
39 41 echo "索引名称: $ES_INDEX"
  42 +echo "(注意:包含环境前缀 ES_INDEX_NAMESPACE='${ES_INDEX_NAMESPACE}')"
40 43 echo "请输入索引名称 '$ES_INDEX' 来确认:"
41 44 read -r user_input
42 45  
... ...
suggestion/README.md
... ... @@ -26,15 +26,15 @@
26 26  
27 27 ## 2. 总体架构
28 28  
29   -采用双索引架构
  29 +采用双索引架构(支持多环境 namespace 前缀)
30 30  
31   -- 商品索引:`search_products_tenant_{tenant_id}`
32   -- 建议词索引:`search_suggestions_tenant_{tenant_id}`
  31 +- 商品索引:`{ES_INDEX_NAMESPACE}search_products_tenant_{tenant_id}`
  32 +- 建议词索引:`{ES_INDEX_NAMESPACE}search_suggestions_tenant_{tenant_id}`
33 33  
34 34 在线查询主路径:
35 35  
36   -1. 仅查询 `search_suggestions_tenant_{tenant_id}` 得到 suggestion 列表。
37   -2. 对每条 suggestion 进行“结果直达”的二次查询(`msearch`)到 `search_products_tenant_{tenant_id}`:
  36 +1. 仅查询 `{ES_INDEX_NAMESPACE}search_suggestions_tenant_{tenant_id}` 得到 suggestion 列表。
  37 +2. 对每条 suggestion 进行“结果直达”的二次查询(`msearch`)到 `{ES_INDEX_NAMESPACE}search_products_tenant_{tenant_id}`:
38 38 - 使用 suggestion 文本对 `title.{lang}` / `qanchors.{lang}` 执行 `term` / `match_phrase_prefix` 组合查询。
39 39 3. 回填每条 suggestion 的商品卡片列表(例如每条 3~5 个)。
40 40  
... ... @@ -164,17 +164,17 @@ Header:
164 164  
165 165 输入:
166 166  
167   -- `search_products_tenant_{tenant_id}` 文档
  167 +- `{ES_INDEX_NAMESPACE}search_products_tenant_{tenant_id}` 文档
168 168 - MySQL 表:`shoplazza_search_log`
169 169  
170 170 输出:
171 171  
172   -- `search_suggestions_tenant_{tenant_id}` 全量文档
  172 +- `{ES_INDEX_NAMESPACE}search_suggestions_tenant_{tenant_id}` 全量文档
173 173  
174 174 ### 5.1 流程
175 175  
176   -1. 创建/重建 `search_suggestions_tenant_{tenant_id}`。
177   -2. 遍历 `search_products_tenant_{tenant_id}`(`scroll` 或 `search_after`):
  176 +1. 创建/重建 `{ES_INDEX_NAMESPACE}search_suggestions_tenant_{tenant_id}`。
  177 +2. 遍历 `{ES_INDEX_NAMESPACE}search_products_tenant_{tenant_id}`(`scroll` 或 `search_after`):
178 178 - 提取每个商品的 `title.{lang}`、`qanchors.{lang}`。
179 179 - 归一化文本(NFKC、trim、lower、空白折叠)。
180 180 - 产出候选词并累加:
... ... @@ -223,7 +223,7 @@ for tenant_id in tenants:
223 223 item.rank_score = compute_rank_score(item)
224 224 docs.append(to_suggestion_doc(tenant_id, lang, item))
225 225  
226   - bulk_upsert(index=f"search_suggestions_tenant_{tenant_id}", docs=docs)
  226 + bulk_upsert(index=f"{ES_INDEX_NAMESPACE}search_suggestions_tenant_{tenant_id}", docs=docs)
227 227 ```
228 228  
229 229 ## 6. 日志语言解析策略(已新增 language 字段)
... ... @@ -407,7 +407,7 @@ M3(优化):
407 407  
408 408 ## 13. 实验与验证建议
409 409  
410   -以租户 `tenant_id=171` 为例,推荐如下验证流程(其他租户同理):
  410 +以租户 `tenant_id=171` 为例,推荐如下验证流程(其它租户 / 环境同理,可通过 ES_INDEX_NAMESPACE 区分 prod / uat / test):
411 411  
412 412 ### 13.1 构建索引
413 413  
... ... @@ -415,7 +415,7 @@ M3(优化):
415 415 ./scripts/build_suggestions.sh 171 --days 30 --recreate
416 416 ```
417 417  
418   -期望 CLI 输出类似
  418 +期望 CLI 输出类似(prod 环境,ES_INDEX_NAMESPACE 为空)
419 419  
420 420 ```json
421 421 {
... ... @@ -440,11 +440,19 @@ M3(优化):
440 440 ### 13.2 检查索引结构
441 441  
442 442 ```bash
  443 +# prod / 本地环境:ES_INDEX_NAMESPACE 为空
443 444 curl "http://localhost:9200/search_suggestions_tenant_171/_mapping?pretty"
444 445 curl "http://localhost:9200/search_suggestions_tenant_171/_count?pretty"
445 446 curl "http://localhost:9200/search_suggestions_tenant_171/_search?size=5&pretty" -d '{
446 447 "query": { "match_all": {} }
447 448 }'
  449 +
  450 +# UAT 环境:假设 ES_INDEX_NAMESPACE=uat_
  451 +curl "http://localhost:9200/uat_search_suggestions_tenant_171/_mapping?pretty"
  452 +curl "http://localhost:9200/uat_search_suggestions_tenant_171/_count?pretty"
  453 +curl "http://localhost:9200/uat_search_suggestions_tenant_171/_search?size=5&pretty" -d '{
  454 + "query": { "match_all": {} }
  455 +}'
448 456 ```
449 457  
450 458 重点确认:
... ...
suggestion/builder.py
... ... @@ -19,12 +19,22 @@ from sqlalchemy import text
19 19 from config.tenant_config_loader import get_tenant_config_loader
20 20 from utils.es_client import ESClient
21 21 from suggestion.mapping import build_suggestion_mapping
  22 +from config.env_config import ES_INDEX_NAMESPACE
22 23  
23 24 logger = logging.getLogger(__name__)
24 25  
25 26  
26 27 def get_suggestion_index_name(tenant_id: str) -> str:
27   - return f"search_suggestions_tenant_{tenant_id}"
  28 + """
  29 + 生成 suggestion 索引名称。
  30 +
  31 + 命名规则:
  32 + {ES_INDEX_NAMESPACE}search_suggestions_tenant_{tenant_id}
  33 +
  34 + 通过 ES_INDEX_NAMESPACE 统一区分 prod/uat/test 等环境。
  35 + """
  36 + prefix = ES_INDEX_NAMESPACE or ""
  37 + return f"{prefix}search_suggestions_tenant_{tenant_id}"
28 38  
29 39  
30 40 @dataclass
... ...