1128XF

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

    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

posted on 2017-02-26 17:26  1128XF  阅读(279)  评论(0编辑  收藏  举报

导航