: i am facing an issue while trying to update a document.
: I am using SolrJ to add/update documents of my collection. The SolrJ

: I am aware that in multivalue fields i can only add an element but not
: remove, in fact for those fields I am overriding all the values every time.
: Everything worked great until I found a corner case: empty out a multivalue
: field.
: In this case values stay there and the field is not emptied.

        ...

: This is the code snippet:
: 
:  Map<String, Object> element = new HashMap<String, Object>(1);
:  element.put("set", null);
:  this.addField("fieldname", element);

just to be clear:

1) is "this" in your above code a SolrInputDocument object?  are you 
subclassing SolrInputDocument for some reason? can you explain why?

2) IIUC, you are using solrj to fecth a document from solr, and you then 
want to use Atomic updates to modify that document, and one of hte 
modifications you are attempting is to empty out this multivalued field -- 
correct?   But if the field currently has values, then "addField" is going 
to add your 1 element map to that existing list of values.  Have you tried 
using SolrInputDocument.setField("fieldname", element); to *replace* all 
of the existing values with the instruction to set the (on the server 
side) to null?

If i'm missunderstanding any part of your question, please post a more 
complete (ideally: runnably) code example showing everything you are 
doing.


-Hoss

Reply via email to