I tried to create a copyField in Apache Solr schema, with several fields being a source using Schema API this way (through bash script).

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

It produced following error:

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

How to use multiple source fields for a copyField through Schema API?

1

There are 1 best solutions below

0
Gishas On

Turns out you can have multiple fields specified in destination field, like in tutorial

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

but not in source field. So for source field I had to specify, in my .sh script, four different requests:

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

That worked as expected.

P.S. A bonus - schema API reference at https://solr.apache.org/guide/8_9/schema-api.html states that you can have multiple commands in single POST, which I didn't know at the time given, so I suggest that approach instead of having separate CURL request for every field.