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

Solr通过Schema API创建多源copyField提示源不匹配如何解决

错误原因

  • 你的请求存在两个问题:
    1. 源字段列表中director:多写了末尾的冒号,和Schema中实际存在的字段名不匹配
    2. 8.6版本之前的Apache Solr不支持直接给add-copy-field的source参数传数组,需要单独配置每个源字段的拷贝规则

兼容全版本的正确调用方式

你可以在单次请求的add-copy-field指令中传入规则数组,批量添加所有拷贝字段配置:

curl -X POST -H 'Content-type:application/json' --data-binary '{
  "add-copy-field": [
    {"source": "title", "dest": "default_search_field"},
    {"source": "description", "dest": "default_search_field"},
    {"source": "director", "dest": "default_search_field"},
    {"source": "leading_actors", "dest": "default_search_field"}
  ]
}' http://localhost:8983/solr/bestFilms/schema

Solr 8.6及以上版本简化写法

如果你的Solr版本不低于8.6,只要修正director字段名的多余冒号即可,数组写法是被支持的:

curl -X POST -H 'Content-type:application/json' --data-binary '{
  "add-copy-field":{
     "source":["title","description","director","leading_actors"],
     "dest":"default_search_field"}
}' http://localhost:8983/solr/bestFilms/schema

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.09.30 10:54:00