2013-11-27 35 views
4

我在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辦呢?

謝謝!

+0

檢查http://stackoverflow.com/questions/16234045/solr-how-to-use-the-new-field-update-modes-atomic-updates-with-solrj,這可能會有所幫助。 – Nikolay

回答

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); 

謝謝反正!

相關問題