Source:
public static BatchLog chunkBatchLogMessage(LoggingProtos.BatchLogMessage batchLogMessage) { final List<IndexTankClient.Document> documents = Lists.newArrayList(); String createdDateString = new DateTime(DateTimeZone.UTC).toString(DateTimeFormat.forPattern("yyyy-MM-dd")); for(final LoggingProtos.LogMessage log : batchLogMessage.getMessagesList()) { final Long millis = (log.getTs() == 0) ? batchLogMessage.getReceivedAt() : log.getTs() * 1000L; final String documentId = String.format("%s-%d", log.getDeviceId(), millis); final DateTime createdDateTime = new DateTime(millis, DateTimeZone.UTC); final String halfDateString = createdDateTime.toString(DateTimeFormat.forPattern("yyyyMMdda")); final String dateString = createdDateTime.toString(DateTimeFormat.forPattern("yyyyMMdd")); final Map<String, String> fields = Maps.newHashMap(); final Map<String, String> categories = Maps.newHashMap(); fields.put("device_id", log.getDeviceId()); fields.put("text", log.getMessage()); fields.put("ts", String.valueOf(log.getTs())); fields.put("half_date", halfDateString); fields.put("date", dateString); fields.put("all", "1"); for (final String tag : tagToField.keySet()) { fields.put(tagToField.get(tag), String.valueOf(log.getMessage().contains(tag))); } fields.put("alarm_ringing", String.valueOf(log.getMessage().contains("ALARM RINGING"))); createdDateString = createdDateTime.toString(DateTimeFormat.forPattern("yyyy-MM-dd")); final Map<Integer, Float> variables = new HashMap<>(); variables.put(0, new Float(millis / 1000)); variables.put(1, new Float(millis)); categories.put("device_id", log.getDeviceId()); categories.put("origin", log.getOrigin()); categories.put("half_date", halfDateString); categories.put("date", dateString); documents.add(new IndexTankClient.Document(documentId, fields, variables, categories)); } return new BatchLog(documents, createdDateString); }

Target:
public static BatchLog chunkBatchLogMessage(LoggingProtos.BatchLogMessage batchLogMessage) { final List<IndexTankClient.Document> documents = Lists.newArrayList(); String createdDateString = new DateTime(DateTimeZone.UTC).toString(DateTimeFormat.forPattern("yyyy-MM-dd")); for(final LoggingProtos.LogMessage log : batchLogMessage.getMessagesList()) { final Long millis = (log.getTs() == 0) ? batchLogMessage.getReceivedAt() : log.getTs() * 1000L; final String documentId = String.format("%s-%d", log.getDeviceId(), millis); final DateTime createdDateTime = new DateTime(millis, DateTimeZone.UTC); final String halfDateString = createdDateTime.toString(DateTimeFormat.forPattern("yyyyMMdda")); final String dateString = createdDateTime.toString(DateTimeFormat.forPattern("yyyyMMdd")); final Map<String, String> fields = Maps.newHashMap(); final Map<String, String> categories = Maps.newHashMap(); fields.put("device_id", log.getDeviceId()); fields.put("text", log.getMessage()); fields.put("ts", String.valueOf(log.getTs())); fields.put("half_date", halfDateString); fields.put("date", dateString); fields.put("all", "1"); for (final String tag : tagToField.keySet()) { fields.put(tagToField.get(tag).value, String.valueOf(log.getMessage().contains(tag))); } createdDateString = createdDateTime.toString(DateTimeFormat.forPattern("yyyy-MM-dd")); final Map<Integer, Float> variables = new HashMap<>(); variables.put(0, new Float(millis / 1000)); variables.put(1, new Float(millis)); categories.put("device_id", log.getDeviceId()); categories.put("origin", log.getOrigin()); categories.put("half_date", halfDateString); categories.put("date", dateString); documents.add(new IndexTankClient.Document(documentId, fields, variables, categories)); } return new BatchLog(documents, createdDateString); }