27 Nov, 2025

1 commit

  • 1. 前端传递的过滤条件永远是要起作用的
    2. 然后召回模块包括文本相关性召回(中英文都是用)和向量召回,两者相互补充。
    3. 套用function_score以支持两种打分融合和各种提权字段
    4. 只需要build_query 这一层。
    
    实际操作:
    1. 架构简化
    移除了 MultiLanguageQueryBuilder 层级
    只保留单层的 ESQueryBuilder.build_query 方法
    2. 查询结构重构
    实现了 filters and (text_recall or embedding_recall) 结构:
    前端过滤条件:永远起作用(放在 filter 中)
    文本召回:同时搜索中英文字段(multi_match 覆盖 title_zh/en, brief_zh/en 等)
    向量召回:KNN 查询(独立参数,ES 会自动合并)
    Function_score:包装召回部分,支持提权字段配置
    3. 文本匹配字段更新
    在 DEFAULT_MATCH_FIELDS 中添加了中英文字段:
    中文:title_zh, brief_zh, description_zh, vendor_zh, category_path_zh, category_name_zh
    英文:title_en, brief_en, description_en, vendor_en, category_path_en, category_name_en
    语言无关:tags
    4. Function_score 框架保留
    保留了 function_score 配置框架(FUNCTION_SCORE_CONFIG)
    支持 filter_weight、field_value_factor、decay 等提权函数
    可以从配置中扩展提权字段
    5. 测试验证
    所有功能测试通过:
    基本文本搜索
    带过滤条件的搜索
    范围过滤
    分面搜索
    英文查询
    tangwang
     


25 Nov, 2025

1 commit

  • mappings/search_products.json - 完整的ES索引配置(settings + mappings)
    基于 docs/索引字段说明v2-mapping结构.md
    简化 mapping_generator.py
    移除所有config依赖
    直接使用 load_mapping() 从JSON文件加载
    保留工具函数:create_index_if_not_exists, delete_index_if_exists, update_mapping
    更新数据导入脚本
    scripts/ingest_shoplazza.py - 移除ConfigLoader依赖
    直接使用 load_mapping() 和 DEFAULT_INDEX_NAME
    更新indexer模块
    indexer/__init__.py - 更新导出
    indexer/bulk_indexer.py - 简化IndexingPipeline,移除config依赖
    创建查询配置常量
    search/query_config.py - 硬编码字段列表和配置项
    
    使用方式
    创建索引:
    from indexer.mapping_generator import load_mapping, create_index_if_not_existsfrom utils.es_client import ESClientes_client = ESClient(hosts=["http://localhost:9200"])mapping = load_mapping()create_index_if_not_exists(es_client, "search_products", mapping)
    数据导入:
    python scripts/ingest_shoplazza.py \    --db-host localhost \    --db-database saas \    --db-username root \    --db-password password \    --tenant-id "1" \    --es-host http://localhost:9200 \    --recreate
    
    注意事项
    修改mapping:直接编辑 mappings/search_products.json
    字段映射:spu_transformer.py 中硬编码,与mapping保持一致
    config目录:保留但不再使用,可后续清理
    search模块:仍依赖config
    tangwang