02 Mar, 2026
1 commit
-
- 新增 `suggestion` 模块: - `suggestion/mapping.py`:`search_suggestions` mapping 生成(多语言 `completion` + `search_as_you_type`) - `suggestion/builder.py`:全量构建程序(扫描 `search_products` 的 `title/qanchors` + MySQL `shoplazza_search_log`) - `suggestion/service.py`:在线查询服务(suggestion 检索 + 结果直达商品二次查询) - `suggestion/__init__.py` - 接入 API 服务初始化: - `api/app.py` 新增 `SuggestionService` 初始化和 `get_suggestion_service()` - 接口实现: - `api/routes/search.py` 的 `GET /search/suggestions` 从“空框架”改为真实调用 - 支持参数: - `q`, `size`, `language` - `with_results`(是否直达商品) - `result_size`(每条 suggestion 商品数) - `debug` - 继续要求 `X-Tenant-ID`(或 query 的 `tenant_id`) - 模型补充: - `api/models.py` 增加 suggestion 请求/响应字段(`language`, `resolved_language`, `with_results`, `result_size`) - CLI 全量构建命令: - `main.py` 新增 `build-suggestions` - 使用方式: - `python main.py build-suggestions --tenant-id 1 --recreate` - 可选:`--days 30 --batch-size 500 --min-query-len 1 --es-host ...` --- 关键实现逻辑(已编码) - 语言归属优先级(按你要求): - `shoplazza_search_log.language` > `request_params.language` > 脚本/模型兜底 - 候选词聚合键: - `(tenant_id, lang, text_norm)`(文档唯一) - 评分: - 基于 `query_count_30d/7d + qanchor_doc_count + title_doc_count` 的离线分 - 结果直达: - 对每条 suggestion 在 `search_products_tenant_{id}` 做二次查询(`qanchors/title` 组合) --- 变更文件 - `api/app.py` - `api/models.py` - `api/routes/search.py` - `main.py` - `suggestion/__init__.py` - `suggestion/mapping.py` - `suggestion/builder.py` - `suggestion/service.py`
06 Feb, 2026
1 commit
-
--- 1. `search/es_query_builder.py`:`_all` 分支 - **普通字段**(如 `tags_all`, `category1_name_all`): - 键以 `_all` 结尾时,先去掉后缀得到 ES 字段名。 - 若值为**数组**:生成 `bool.must`,内含多个 `term`,即多值 **AND**。 - 若值为**单值**:生成一个 `term`。 - **specifications_all**: - 值为 `[{name, value}, ...]` 时,为每一项生成一个 nested 查询,全部放入同一个 `bool.must`,即列表内所有规格条件都要满足(AND)。 原有逻辑不变:不带 `_all` 的字段,数组仍为 OR(`terms`),单值仍为 `term`。 2. `api/models.py`:filters 说明 - 在 `filters` 的 `description` 中补充: - 字段名加 `_all` 表示 AND(如 `tags_all: ['A','B']` 表示同时包含 A 和 B)。 - `specifications_all` 表示列表内所有规格条件都要满足。 3. `docs/搜索API对接指南.md`:文档 - 在 3.3.1 开头说明:任意字段名可加 `_all` 后缀表示多值 AND。 - 在格式示例中增加 `tags_all`、`category1_name_all` 示例。 - 在「支持的值类型」中说明:数组在带 `_all` 时为 AND。 - 新增小节「`*_all` 语义(多值 AND)」:说明用法及 `specifications_all` 行为。 - 在「常用过滤字段」中补充:以上字段均可加 `_all` 后缀。 --- **使用示例** ```json { "filters": { "tags": ["手机", "促销"], "tags_all": ["手机", "促销", "新品"] } } ``` - `tags`:命中「手机」或「促销」或两者都有(OR)。 - `tags_all`:必须同时包含「手机」「促销」「新品」三个标签(AND)。
05 Feb, 2026
2 commits
-
- API:新增请求参数 ai_search,开启时在窗口内走重排流程 - 配置:RerankConfig 移除 enabled/expression/description,仅保留 rerank_window 及 service_url/timeout_sec/weight_es/weight_ai;默认超时 15s - 重排流程:ai_search 且 from+size<=rerank_window 时,ES 取前 rerank_window 条, 调用外部 /rerank 服务,融合 ES 与重排分数后按 from/size 分页;否则不重排 - search/rerank_client:新增模块,封装 build_docs、call_rerank_service、 fuse_scores_and_resort、run_rerank;超时单独捕获并简短日志 - search/searcher:移除 RerankEngine,enable_rerank=ai_search,使用 config.rerank 参数 - 删除 search/rerank_engine.py(本地表达式重排),统一为外部服务一种实现 - 文档:搜索 API 对接指南补充 ai_search 与 relevance_score 说明 - 测试:conftest 中 rerank 配置改为新结构 Co-authored-by: Cursor <cursoragent@cursor.com>
24 Jan, 2026
1 commit
-
2. 设置sku_filter_dimension参数的默认值为option1
06 Jan, 2026
1 commit
-
mappings/search_products.json:把原来的 title_zh/title_en/brief_zh/... 改成 按语言 key 的对象结构( /products/_doc/1 { "title": {"en":...} } ) 同时在这些字段下 预置了全部 analyzer 语言: arabic, armenian, basque, brazilian, bulgarian, catalan, chinese, cjk, czech, danish, dutch, english, finnish, french, galician, german, greek, hindi, hungarian, indonesian, italian, norwegian, persian, portuguese, romanian, russian, spanish, swedish, turkish, thai 实现为 type: object + properties,同时满足“按语言灌入”和“按语言 analyzer”。 索引灌入(全量/增量/transformer)已同步改完 indexer/document_transformer.py:输出从 title_zh/title_en/... 改为: title: {<primary_lang>: 原文, en?: 翻译, zh?: 翻译} brief/description/vendor 同理 category_path/category_name_text 也改为语言对象(避免查询侧继续依赖旧字段) indexer/incremental_service.py:embedding 取值从 title_en/title_zh 改为从 title 对象里优先取 en,否则取 zh,否则取任一可用语言。 查询侧与配置、API/文档已同步 search/es_query_builder.py:查询字段统一改成点路径:title.zh / title.en / vendor.zh / vendor.zh.keyword / category_name_text.zh 等。 config/config.yaml:field boosts / indexes 里的字段名同步为新点路径。 API & formatter: api/result_formatter.py 已支持新结构(并保留对旧 *_zh/_en 的兼容兜底)。 api/models.py、相关 docs/examples 里的 vendor_zh.keyword 等已更新为 vendor.zh.keyword。 文档/脚本:docs/、README.md、scripts/ 里所有旧字段名引用已批量替换为新结构。
22 Dec, 2025
1 commit
05 Dec, 2025
1 commit
-
2. queries
04 Dec, 2025
1 commit
-
核心功能: - 添加 multi_select 字段到 FacetConfig(默认为 true) - 实现 post_filter 支持 disjunctive faceting - 后端自动标记 facet 值的 selected 状态 - 支持 specifications 和普通字段的 multi-select 技术改进: - ESQueryBuilder: 分离 conjunctive/disjunctive filters - ResultFormatter: 根据 current_filters 标记 selected - Searcher: 传递 facet_configs 给 query builder 文档更新: - 添加 multi_select_faceting.md 详细文档 - 更新 API 对接指南,说明新功能 - 添加测试脚本 test_multi_select_facet.py 业界标准: - 遵循 Elasticsearch/Algolia/Amazon 的最佳实践 - 提供探索式搜索体验 - 前后端职责清晰分离
03 Dec, 2025
2 commits
-
{ "facets": [ { "field": "category1_name", "size": 15, "type": "terms" }, "specifications.color", "specifications.size" ] } { "facets": [ {"field": "category1_name", "size": 15, "type": "terms"}, {"field": "specifications.color", "size": 10, "type": "terms"}, {"field": "specifications.size", "size": 10, "type": "terms"} ] } 之前是上面的接口形式,主要是考虑 属性的分面, 因为 款式都是有限的 不需要设定 "size": 10, "type": "terms" 这些参数。 但是从接口设计层面,最好按下面这样,这样的话 specifications.color 和 category1_name 的组装格式 完全一样。前端不需要感知 属性分面 和 类别等其他字段分面的差异。
02 Dec, 2025
1 commit
-
后端请求模型变更(api/models.py) SearchRequest.sku_filter_dimension 从 Optional[str] 改为 Optional[List[str]]。 语义:列表表示一个或多个“维度标签”,例如: 单维度:["color"]、["option1"] 多维度:["color", "size"]、["option1", "option2"] 描述更新为:对 维度组合进行分组,每个组合只保留一个 SKU。 结果格式化与去重逻辑(api/result_formatter.py) ResultFormatter.format_search_results(..., sku_filter_dimension: Optional[List[str]] = None),调用处已同步更新。 单维度旧逻辑升级为多维度逻辑: 新方法:_filter_skus_by_dimensions(skus, dimensions, option1_name, option2_name, option3_name, specifications)。 维度解析规则(按顺序处理,并去重): 若维度是 option1 / option2 / option3 → 对应 option1_value / option2_value / option3_value。 否则,将维度字符串转小写后,分别与 option1_name / option2_name / option3_name 对比,相等则映射到对应的 option*_value。 未能映射到任何字段的维度会被忽略。 对每个 SKU: 按解析出的字段列表(例如 ["option1_value", "option2_value"])取值,组成 key,如 ("red", "L");None 用空串 ""。 按 key 分组,每个 key 只保留遇到的第一个 SKU。 若列表为空或所有维度都无法解析,则 不做过滤,返回原始 skus。 Searcher 参数类型同步(search/searcher.py) Searcher.search(...) 中 sku_filter_dimension 参数类型从 Optional[str] 改为 Optional[List[str]]。 传给 ResultFormatter.format_search_results 时,直接传该列表。 前端参数格式调整(frontend/static/js/app.js) 输入框 #skuFilterDimension 依旧是一个文本框,但解析方式改为: 函数 getSkuFilterDimension(): 读取文本,如:"color" 或 "color,size" 或 "option1, color"。 用逗号 , 拆分,trim() 后过滤空串,返回 字符串数组,例如: "color" → ["color"] "color,size" → ["color", "size"] 若最终数组为空,则返回 null。 搜索请求体中仍使用字段名 sku_filter_dimension,但现在值是 string[] 或 null: body: JSON.stringify({ // ... sku_filter_dimension: skuFilterDimension, // 例如 ["color", "size"] debug: state.debug }) 文档更新(docs/搜索API对接指南.md) 请求体示例中的类型由: "sku_filter_dimension": "string" 改为: "sku_filter_dimension": ["string"] 参数表中: 从 string 改为 array[string],说明为“维度列表,按组合分组,每个组合保留一个 SKU”。 功能说明章节“SKU筛选维度 (sku_filter_dimension)”已调整为 列表语义 + 组合去重,并补充了示例: 单维度: { "query": "芭比娃娃", "sku_filter_dimension": ["color"] } 多维度组合: { "query": "芭比娃娃", "sku_filter_dimension": ["color", "size"] } 使用方式总结 单维度去重(保持旧行为的等价写法) 旧:"sku_filter_dimension": "color" 新:"sku_filter_dimension": ["color"] 多维度组合去重(你新提的需求) 例如希望“每个 SPU 下,同一颜色+尺码组合只保留一个 SKU”: { "query": "芭比娃娃", "sku_filter_dimension": ["color", "size"] }
27 Nov, 2025
2 commits
-
1. 搜索API对接指南.md 在“精确匹配过滤器”部分添加了 specifications 嵌套过滤说明 支持单个规格过滤和多个规格过滤(OR 逻辑) 在“分面配置”部分完善了 specifications 分面说明 添加了两种分面模式:所有规格名称和指定规格名称 在“常见场景示例”部分添加了场景5-8,包含规格过滤和分面的完整示例 2. 搜索API速查表.md 在“精确匹配过滤”部分添加了 specifications 过滤的快速参考 在“分面搜索”部分添加了 specifications 分面的快速参考 更新了完整示例,包含 specifications 的使用 3. Search-API-Examples.md 在“过滤器使用”部分添加了示例4-6,展示 specifications 过滤 在“分面搜索”部分添加了示例2-3,展示 specifications 分面 更新了 Python 和 JavaScript 完整示例,包含 specifications 的使用 在“常见使用场景”部分添加了场景2.1,展示带规格过滤的搜索结果页 4. 索引字段说明v2.md 更新了 specifications 字段的查询示例,包含 API 格式和 ES 查询结构 添加了两种分面模式的说明和示例 更新了“分面字段”说明,明确支持指定规格名称的分面 5. 补充参数 参数说明:sku_filter_dimension 是可选参数,用于按指定维度过滤每个SPU下的SKU 支持的维度: 直接选项字段:option1、option2、option3 规格名称:通过 option1_name、option2_name、option3_name 匹配(如 color、size)
-
1. 搜索API对接指南.md 在“精确匹配过滤器”部分添加了 specifications 嵌套过滤说明 支持单个规格过滤和多个规格过滤(OR 逻辑) 在“分面配置”部分完善了 specifications 分面说明 添加了两种分面模式:所有规格名称和指定规格名称 在“常见场景示例”部分添加了场景5-8,包含规格过滤和分面的完整示例 2. 搜索API速查表.md 在“精确匹配过滤”部分添加了 specifications 过滤的快速参考 在“分面搜索”部分添加了 specifications 分面的快速参考 更新了完整示例,包含 specifications 的使用 3. Search-API-Examples.md 在“过滤器使用”部分添加了示例4-6,展示 specifications 过滤 在“分面搜索”部分添加了示例2-3,展示 specifications 分面 更新了 Python 和 JavaScript 完整示例,包含 specifications 的使用 在“常见使用场景”部分添加了场景2.1,展示带规格过滤的搜索结果页 4. 索引字段说明v2.md 更新了 specifications 字段的查询示例,包含 API 格式和 ES 查询结构 添加了两种分面模式的说明和示例 更新了“分面字段”说明,明确支持指定规格名称的分面
26 Nov, 2025
2 commits
14 Nov, 2025
2 commits
13 Nov, 2025
3 commits
-
创建统一配置文件 config/config.yaml(从 base 配置迁移,移除 customer_name) 创建脚本体系 启动、停止、重启、moc数据到mysql、从mysql灌入数据到ES 这些脚本 restart.sh run.sh 内部调用 启动前后端 scripts/mock_data.sh mock数据 -> mysql scripts/ingest.sh mysql->ES
-
主要变更: 1. 去掉数据源应用结构配置化,我们只针对店匠的spu sku表设计索引,数据灌入流程是写死的(只是满足测试需求,后面外层应用负责数据全量+增量灌入)。搜索系统主要关注如何适配外部搜索需求 目前有两个数据灌入脚本,一种是之前的,一种是现在的从两个店匠的表sku表+spu表读取并且以spu为单位组织doc。 - 配置只关注ES搜索相关配置,提高可维护性 - 创建base配置(店匠通用配置) 2. 索引结构重构(SPU维度) - 所有客户共享search_products索引,通过tenant_id隔离 - 支持嵌套variants字段(SKU变体数组) - 创建SPUTransformer用于SPU数据转换 3. API响应格式优化 - 约定一套搜索结果的格式,而不是直接暴露ES doc的结构(_id _score _source内的字段) - 添加ProductResult和VariantResult模型 - 添加suggestions和related_searches字段 (预留接口,逻辑暂未实现) 4. 数据导入流程 - 创建店匠数据导入脚本(ingest_shoplazza.py) - Pipeline层决定数据源,配置不包含数据源信息 - 创建测试数据生成和导入脚本 5. 文档更新 - 更新设计文档,反映新架构 - 创建BASE_CONFIG_GUIDE.md使用指南
12 Nov, 2025
2 commits
11 Nov, 2025
3 commits
-
## 🎯 Major Features - Request context management system for complete request visibility - Structured JSON logging with automatic daily rotation - Performance monitoring with detailed stage timing breakdowns - Query analysis result storage and intermediate result tracking - Error and warning collection with context correlation ## 🔧 Technical Improvements - **Context Management**: Request-level context with reqid/uid correlation - **Performance Monitoring**: Automatic timing for all search pipeline stages - **Structured Logging**: JSON format logs with request context injection - **Query Enhancement**: Complete query analysis tracking and storage - **Error Handling**: Enhanced error tracking with context information ## 🐛 Bug Fixes - Fixed DeepL API endpoint (paid vs free API confusion) - Fixed vector generation (GPU memory cleanup) - Fixed logger parameter passing format (reqid/uid handling) - Fixed translation and embedding functionality ## 🌟 API Improvements - Simplified API interface (8→5 parameters, 37.5% reduction) - Made internal functionality transparent to users - Added performance info to API responses - Enhanced request correlation and tracking ## 📁 New Infrastructure - Comprehensive test suite (unit, integration, API tests) - CI/CD pipeline with automated quality checks - Performance monitoring and testing tools - Documentation and example usage guides ## 🔒 Security & Reliability - Thread-safe context management for concurrent requests - Automatic log rotation and structured output - Error isolation with detailed context information - Complete request lifecycle tracking 🤖 Generated with Claude Code Co-Authored-By: Claude <noreply@anthropic.com>
08 Nov, 2025
1 commit