Zac
Zac

Reputation: 2250

How to update to NULL a field in solr using XML?

In solr 4 is possible to make partial document updates. For example:

<add>
 <doc>
  <field name="id">1</field>
  <field update="set" name="myfield">newvalue</field>
 </doc>
</add>

updates myfield to "newvalue" in record 1 without affecting other fields. But how can I update myfield to NULL?

I tried with

<field update="set" name="myfield"></field>

but obviously it sets an empty string (not NULL) and for date fields raises an error.

Is there a way to do this without updating whole document?

Upvotes: 2

Views: 2346

Answers (1)

Paige Cook
Paige Cook

Reputation: 22555

According to the Atomic Update documentation for the set command, you need to set the null="true" attribute on the field.

<add>
 <doc>
  <field name="id">1</field>
  <field update="set" name="myfield" null="true" />
 </doc>
</add>

Upvotes: 4

Related Questions