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

Vespa无法实现动态高亮,求字符串字段动态摘要示例

动态摘要高亮实现方案

问题分析

当前已为wpsolr_title字段配置summary: dynamic,但查询结果未触发高亮,核心原因是查询语句未主动调用动态摘要函数,也未配置高亮参数。

解决步骤

  1. 修改查询语句,触发动态摘要与高亮
    在YQL中用summary()函数包裹目标字段,并添加highlight配置指定高亮格式:

    {
      "query": "hamster",
      "yql": "select summary(wpsolr_title) as wpsolr_title from wpsolr30 where userInput(@query)",
      "highlight": {
        "enabled": true,
        "style": "html",
        "pre_tag": "<em>",
        "post_tag": "</em>"
      }
    }
    
  2. 确认Schema配置有效性
    确保字段配置包含必要的索引与摘要规则,现有配置无需修改:

    field wpsolr_title type string {
      indexing: index | summary
      summary: dynamic
    }
    
    fieldset default {
      fields: wpsolr_title
    }
    

预期返回结果

修改后的查询会返回带有高亮标记的动态摘要:

{
  "fields": {
    "wpsolr_title": "<em>Hamster</em> one"
  }
}

关键说明

  • summary()函数是触发动态摘要生成的核心,仅直接查询原字段不会激活动态摘要逻辑
  • highlight配置可自定义高亮标签,比如将<em>替换为<strong>,只需调整pre_tag和post_tag的值即可

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.25 23:43:10