class ESManager implements Constants {

    public static Map<String, Object> uploadData(String index, String type, List<Map<String, Object>> docs, String loaddate) {

        Map<String, Object> status = new LinkedHashMap<>();
        List<String> errors = new ArrayList<>();
        String actionTemplate = "{ \"index\" : { \"_index\" : \"%s\", \"_type\" : \"%s\", \"_id\" : \"%s\" } }%n";

        LOGGER.info("*********UPLOADING*** {}" ,type);

        String keys = ConfigManager.getKeyForType(index, type);
        String[] _keys = keys.split(",");
        if (null != docs && !docs.isEmpty()) {
            LOGGER.info("*********# of docs *** {}" , docs.size());
            StringBuilder bulkRequest = new StringBuilder();
            int i = 0;
            for (Map<String, Object> doc : docs) {

                String id = Util.concatenate(doc, _keys, "_");
                StringBuilder _doc = new StringBuilder(createESDoc(doc));
                _doc.deleteCharAt(_doc.length() - 1); 
                _doc.append(",\"latest\":true,\"_loaddate\":\"" + loaddate + "\" }");
                bulkRequest.append(String.format(actionTemplate, index, type, id));
                bulkRequest.append(_doc + "\n");
                i++;
                if (i % 1000 == 0 || bulkRequest.toString().getBytes().length / (1024 * 1024) > 5) {
                    bulkUpload(errors, bulkRequest);
                    bulkRequest = new StringBuilder();
                }
            }
            if (bulkRequest.length() > 0) {
                bulkUpload(errors, bulkRequest);
            }
            LOGGER.info("Updating status");
            refresh(index);
            updateLatestStatus(index, type, loaddate);
            status.put("uploaded_docs", i);
            if (!errors.isEmpty())
                status.put("errors", errors);
        }
        return status;

    }

}