Solr API创建copyField:“copyField source:'[title,director... description]'不是glob,且不符合任何明确字段或dynamicField

z9ju0rcb  于 2022-11-05  发布在  Solr
关注(0)|答案(1)|浏览(170)

我尝试在ApacheSolr模式中创建一个copyField,其中有几个字段是以这种方式(通过bash脚本)使用Schema API的源。

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

它产生了以下错误:

"copyField source :'[title, director, leading_actors, description]' is not a glob and doesn't match any explicit field or dynamicField.

如何通过Schema API为一个copyField使用多个源字段?

jfewjypa

jfewjypa1#

原来您可以在目标字段中指定多个字段,就像教程中一样

curl -X POST -H 'Content-type:application/json' --data-binary '{
  "add-copy-field":{
     "source":"shelf",
     "dest":[ "location", "catchall" ]}
}' http://localhost:8983/solr/gettingstarted/schema

但在源字段中没有。因此,对于源字段,我必须在我的.sh脚本中指定四个不同的请求:

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

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

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

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

果然奏效了。
P.S. https://solr.apache.org/guide/8_9/schema-api.html上的一个额外的模式API参考指出,您可以在一个POST中使用多个命令,这在当时我并不知道,因此我建议使用这种方法,而不是为每个字段使用单独的CURL请求。

相关问题