user3043401
user3043401

Reputation: 101

solrj atomic update - how to set field to null?

I'm using atomic update with Solrj. It works perfectly, but I don’t know how to delete a field within an existing document.

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

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

Does anyone knows how to do it from SolrJ?

Thanks!

Upvotes: 4

Views: 2526

Answers (1)

user3043401
user3043401

Reputation: 101

Ok. So apparently this is the way to do so -

  SolrInputDocument inputDoc = new SolrInputDocument();

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

  inputDoc.setField("FIELD_YOU_WANT_TO_DELETE", partialUpdateNull);

Thanks anyways!

Upvotes: 6

Related Questions