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

使用Marqo添加文档触发MarqoWebError问题求助

解决Marqo add_documents触发MarqoWebError的问题

错误原因

你直接传入单个字符串给add_documents()不符合方法要求。Marqo的add_documents()方法必须接收包含文档字典的列表,每个文档需以键值对形式的字典存在,至少要包含一个用于嵌入和检索的内容字段(比如content)。

修正后的代码

import marqo

# 改为文档字典组成的列表
DOCUMENTS = [{"content": "the document"}]

mq = marqo.Client(url='http://localhost:8882')

# 传入文档列表执行添加
mq.index("my-first-index").add_documents(DOCUMENTS)

额外说明

  • 如果需要给文档指定自定义ID,可以在字典中添加_id字段,示例:
    DOCUMENTS = [{"_id": "doc_001", "content": "the document"}]
    
  • 同时要确认Marqo服务确实在http://localhost:8882正常运行,服务未启动或端口错误也会触发MarqoWebError。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.15 16:06:01