Solrj atomic update - how to set null field?

I am using atomic update with Solrj. It works fine, but I don't know how to remove a field in an existing document.

In the Solr tutorial ( http://wiki.apache.org/solr/UpdateXmlMessages ) they explain how to do this using xml:

<add>
  <doc>
    <field name="employeeId">05991</field>
    <field name="skills" update="set" null="true" />
  </doc>
</add>

Does anyone know how to do this from SolrJ?

Thanks!

+4
source share
1 answer

Ok So obviously this is the way to do it -

  SolrInputDocument inputDoc = new SolrInputDocument();

  Map<String, String> partialUpdateNull = new HashMap<String, String>();
  partialUpdateNull.put("set", null);

  inputDoc.setField("FIELD_YOU_WANT_TO_DELETE", partialUpdateNull);

Thank you anyway!

+4
source

All Articles