While adding documents to an index in solr
, I've noticed there are two ways to add data one is to addField
another is to setField
. Can you tell me when to use which method?
SolrInputDocument doc = new SolrInputDocument();
doc.setField("field_name", data);
doc.addField("field_name_2", data2);
SolrInputDocument.addField()
- it will add another value to any existing values for the field.It works like an append
SolrInputDocument.setField()
- it will overwrite anything that is already there.Discard existing values and start with a fresh list of values.