elasticsearch根据id更新某一个字段

Client client = pool.get();
try {
    JSONObject jsonObject = null;
    for (String id : map.keySet()) {
        jsonObject = new JSONObject();
        jsonObject.put(field,map.get(id));
        UpdateRequest updateRequest = new UpdateRequest();
        updateRequest.index(index);
        updateRequest.type(type);
        updateRequest.id(id);
        updateRequest.doc(jsonObject);
        client.update(updateRequest).get();
    }
} catch (Exception e) {
    e.printStackTrace();
}

你可能感兴趣的:(技术)