Solr 4.0: Partial documents update

本文深入探讨了Solr中Partial Documents Update的功能实现,包括使用SolrInputDocument和HashMap进行部分文档更新的方法,以及如何通过JSON和CURL命令执行此操作。详细解释了设置、添加和增量更新的机制,并提供了实际应用示例。

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}}]'

转载于:https://www.cnblogs.com/ukouryou/articles/2935619.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值