Solr API create copyField: "copyField source :'[title, director...description]' 不是 glob,并且与任何显式字段或



我尝试在Apache Solr模式中创建copyField,其中几个字段是使用这种方式(通过bash脚本)的模式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.

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

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

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

但不在source字段中。因此,对于source字段,我必须在。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

效果如预期。

注:在https://solr.apache.org/guide/8_9/schema-api.html上的一个额外的模式API参考说明,您可以在一个POST中包含多个命令,当时我不知道这一点,所以我建议使用这种方法,而不是为每个字段单独设置CURL请求。

最新更新