You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Typesense仅返回索引中部分匹配结果的原因排查

Typesense搜索结果不全的问题排查与解决

1. 检查默认分页限制

Typesense默认每页仅返回4条结果,这和你遇到的返回数量完全吻合。解决方法是在搜索请求中添加per_page参数,指定更大的数值(比如覆盖你的60条数据,设为100):

示例API请求:

curl -H "X-TYPESENSE-API-KEY: ${TYPESENSE_API_KEY}" \
  "http://localhost:8108/collections/your_collection_name/documents/search?q=BKP&query_by=product_number&per_page=100"

2. 确认字段索引配置

检查你的集合schema,确保product_number字段满足以下要求:

  • 字段类型为string
  • 被包含在query_by参数指定的可搜索字段列表中
  • 如果手动设置过index属性,需确保值为true(默认值为true,但修改后可能影响搜索)

正确的schema片段示例:

{
  "name": "your_collection_name",
  "fields": [
    {"name": "product_number", "type": "string"},
    // 其他字段配置
  ]
}

3. 调整分词策略(可选)

如果确认分页和配置都没问题,但匹配仍有偏差,可以尝试关闭该字段的自动分词,让整个product_number字符串作为完整token被索引。修改schema时添加token_separators: []:

{
  "name": "your_collection_name",
  "fields": [
    {"name": "product_number", "type": "string", "token_separators": []},
    // 其他字段配置
  ]
}

修改schema后需要重新导入所有文档,配置才会生效。

内容的提问来源于stack exchange,提问作者Frodik

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.25 14:15:38