通过Solrj实现对索引库中数据的局部更新操作

时间:2022-06-03 11:27:44
    for (UpdateIndexDTO updateIndexDTO : data) {

                // 局部更新
SolrInputDocument doc = new SolrInputDocument();
bibGid = updateIndexDTO.getBibGid();
doc.addField("gid", bibGid);
String bookSummary = updateIndexDTO.getBookSummary();
String bookContents = updateIndexDTO.getBookContents();
// System.out.println(bookContents.getBytes().length);
Map<String, String> bookSummaryMap = new HashMap<String, String>();
Map<String, String> bookContentsMap = new HashMap<String, String>();
bookSummaryMap.put("set", bookSummary);
bookContentsMap.put("set", bookContents); doc.addField("bookSummary", bookSummaryMap);
doc.addField("bookContents", bookContentsMap); docs.add(doc);
} try {
if(docs.size()>0){
UpdateResponse updateResponse = solrServer.add(docs);
System.out.println("updateResponse=" + updateResponse);
}

百度云盘链接:http://pan.baidu.com/s/1nvDIeXN