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

Azure AI Search+OpenAI RAG配置问题:DOI字段无法在引用中显示

解决Azure AI Search RAG场景中引用面板缺失DOI字段的问题

先排查Azure Studio内的配置问题(无需代码即可解决大部分情况)

  • 确认DOI字段的**可检索(Retrievable)**属性已开启:进入Azure AI Search的索引管理页面,找到目标索引的字段列表,检查DOI字段的Retrievable选项是否勾选。自定义映射时容易遗漏这个设置,导致字段不会被返回给检索请求。
  • 核对索引器的字段映射规则:确保JSON文件中的DOI字段(注意大小写,比如doi或DOI)正确映射到索引中的对应字段,没有拼写错误或映射缺失。
  • 语义配置不影响可检索属性:你设置仅对title和content做语义搜索是正确的,语义搜索的字段范围不会限制DOI字段的可检索性,只要DOI的Retrievable属性开启,就能被检索结果返回。

检查聊天机器人的引用展示逻辑

很多RAG聊天机器人的引用面板默认只提取title和content字段,需要确认在检索结果的处理环节,是否将DOI字段也纳入了引用内容的组装。比如在获取Azure AI Search的返回文档后,要主动提取title和DOI字段,拼接成引用内容,而不是只取前两个字段。

若Studio配置无效,用代码明确设置字段属性(非必须,但更可控)

如果通过Azure Studio调整后仍未解决,可以用Azure SDK直接创建或更新索引,明确指定DOI字段的属性:

from azure.search.documents.indexes import SearchIndexClient
from azure.search.documents.indexes.models import SearchField, SearchFieldDataType, SearchIndex

# 初始化索引客户端
search_client = SearchIndexClient(
    endpoint="你的Azure搜索服务端点",
    credential="你的访问密钥"
)

# 定义索引字段:DOI设为可检索,不参与搜索/过滤/排序
index_fields = [
    SearchField(name="id", type=SearchFieldDataType.String, key=True),
    SearchField(name="title", type=SearchFieldDataType.String, retrievable=True, searchable=True),
    SearchField(name="content", type=SearchFieldDataType.String, retrievable=True, searchable=True),
    SearchField(name="DOI", type=SearchFieldDataType.String, retrievable=True, searchable=False)
]

# 创建或更新索引
target_index = SearchIndex(name="你的索引名称", fields=index_fields)
search_client.create_or_update_index(target_index)

同时在检索结果处理代码中,确保提取DOI字段并加入引用展示:

# 假设retrieved_docs是Azure Search返回的文档列表
for doc in retrieved_docs:
    reference_content = f"标题:{doc['title']} | DOI:{doc['DOI']}"
    # 将reference_content传入聊天机器人的引用面板组件

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.23 09:42:40