[Feature]: allow per-request retrieval overrides on POST /knowledge-search
Author: MercuialCCreated Sep 30, 2026Updated Sep 30, 2026
Labelsenhancementneeds-triage
Affected Component
Backend Service & API
Problem Description
POST /api/v1/knowledge-search 的请求体只有 query、knowledge_base_id、knowledge_base_ids、knowledge_ids、tag_ids、mentioned_items。检索深度和阈值全部来自租户 RetrievalConfig(GET/PUT /api/v1/tenants/kv/retrieval-config)。
请求里多传的 match_count、vector_threshold 会被 Gin 丢掉,调用方无法在单次搜索里覆盖:
embedding_top_k(默认 50)vector_threshold(默认 0.15)keyword_threshold(默认 0.3)rerank_top_k(默认 10,决定最终返回条数)rerank_threshold(默认 0.2)POST /knowledge-bases/{id}/hybrid-search能传match_count和两个阈值,但它不走重排和 MMR,不能代替这条接口。
Proposed Solution
这五个字段在 POST /knowledge-search 上可选:
- 不传:仍用租户检索配置,缺省值与现在的
GetEffective*相同。 - 传入:本次请求使用传入值,不写回租户配置。
字段用指针,以便区分「没传」和「传了 0」。
rerank_threshold: 0是合法覆盖。校验范围与租户 PUT 相同:向量 / 关键词阈值 0–1,重排阈值 −10–10,两个 Top K 0–200。 不改变: - 召回池公式和 500 上限
embedding_top_k <= 0在normalizedMatchCount里仍变成 50rerank_top_k <= 0时 MMR 至少留 1 条/hybrid-search、/wiki-search、知识问答、租户检索设置
Alternatives
No response
Impact
Many users would benefit
Use Case
No response
Additional Information
No response
Confirmation
- I have searched existing issues and confirmed this is a new request
- I understand this request may need discussion and evaluation
Source: Tencent/WeKnora