1. 程式人生 > >solrj修改一條記錄中的某個field欄位的值

solrj修改一條記錄中的某個field欄位的值

public static void update(String id, Object fieldValue) throws IOException, SolrServerException {
    HashMap<String, Object> oper = new HashMap<String, Object>();
    oper.put("set", fieldValue);

    SolrInputDocument doc = new SolrInputDocument();
    doc.addField("id", id);
    doc.addField

("fieldName", oper);
   
    HttpSolrClient client = new HttpSolrClient(baseURL);
    client.add(doc);
    client.commit();
}

轉載地址:http://blog.chinaunix.net/uid-79084-id-5098001.html