I'm in a position in which I need to write a Solr DataImportHandler ScriptTransformer which will add an initial or additional value to a multivalued field.
Currently I'm attempting to use the row.put('fieldname', value)
method, but it appears that the last value added is overriding the existing value rather than appending a new value.
What method or syntax is needed to add new values to a multivalued field via a ScriptTransformer?
I overlooked an example on the Solr DataImportHandler ScriptTransformer section.
It looks like you need to treat the value of the multi-valued field as an instance of the java.util.ArrayList
type.
Here's the relevant portion of hte example, which I've tested and works great!
var arr = new java.util.ArrayList();
for (var i=0; i<pieces.length; i++) {
arr.add(pieces[i]);
}
row.put('categorypieces', arr);