solrj atomic update - 如何将字段设置为null?

时间:2013-11-27 20:30:17

标签: solr solrj

我正在使用Solrj进行原子更新。它工作得很好,但我不知道如何删除现有文档中的字段。

在Solr教程(http://wiki.apache.org/solr/UpdateXmlMessages)中,他们解释了如何使用xml:

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

有谁知道如何从SolrJ做到这一点?

谢谢!

1 个答案:

答案 0 :(得分:4)

确定。显然这是这样做的方式 -

  SolrInputDocument inputDoc = new SolrInputDocument();

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

  inputDoc.setField("FIELD_YOU_WANT_TO_DELETE", partialUpdateNull);

非常感谢!

相关问题