我正在使用 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>
Run Code Online (Sandbox Code Playgroud)
有谁知道如何从 SolrJ 做到这一点?
谢谢!
好的。所以显然这是这样做的方式 -
SolrInputDocument inputDoc = new SolrInputDocument();
Map<String, String> partialUpdateNull = new HashMap<String, String>();
partialUpdateNull.put("set", null);
inputDoc.setField("FIELD_YOU_WANT_TO_DELETE", partialUpdateNull);
Run Code Online (Sandbox Code Playgroud)
不管怎么说,多谢拉!