Solr 4.0: Partial documents update

http://solr.pl/en/2012/07/09/solr-4-0-partial-documents-update/

 

SolrInputDocument doc = new SolrInputDocument();
Map<String, String> partialUpdate = new HashMap<String, String>();
partialUpdate.put("set", "foo");
doc.addField("id", "test_123");
doc.addField("description", partialUpdate);

yields this document:
<doc boost="1.0">
    <field name="id">test_123</field>
    <field name="description" update="set">foo</field>
</doc>

The key of the hash map can be one of three values:
  • set - to set a field.
  • add - to add to a multi-valued field.
  • inc - to increment a field.

   There is an example of this code in the solrj unit tests, in a method called testUpdateField.

json curl 'localhost:8983/solr/update?commit=true' -H 'Content-type:application/json'-d '[{"id":"1","price":{"set":100}}]'

posted on 2013-02-27 18:15  ukouryou  阅读(423)  评论(0编辑  收藏  举报

导航