nickwallen commented on a change in pull request #1269: METRON-1879 Allow
Elasticsearch to Auto-Generate the Document ID
URL: https://github.com/apache/metron/pull/1269#discussion_r240813000
##########
File path:
metron-platform/metron-indexing/src/main/java/org/apache/metron/indexing/dao/update/UpdateDao.java
##########
@@ -73,23 +74,28 @@ default Document patch(RetrieveLatestDao
retrieveLatestDao, PatchRequest request
}
default Document getPatchedDocument(RetrieveLatestDao retrieveLatestDao,
PatchRequest request,
- Optional<Long> timestamp
+ Optional<Long> optionalTimestamp
) throws OriginalNotFoundException, IOException {
- Map<String, Object> latest = request.getSource();
- if (latest == null) {
- Document latestDoc = retrieveLatestDao.getLatest(request.getGuid(),
request.getSensorType());
- if (latestDoc != null && latestDoc.getDocument() != null) {
- latest = latestDoc.getDocument();
+ String guid = request.getGuid();
+ String sensorType = request.getSensorType();
+ String documentID = null;
+ Long timestamp = optionalTimestamp.orElse(System.currentTimeMillis());
+
+ Map<String, Object> originalSource = request.getSource();
+ if (originalSource == null) {
+ // no document source provided, lookup the latest
+ Document toPatch = retrieveLatestDao.getLatest(guid, sensorType);
+ if(toPatch != null && toPatch.getDocument() != null) {
+ originalSource = toPatch.getDocument();
+ documentID = toPatch.getDocumentID().orElse(null);
Review comment:
We need to set the doc ID when patching an already indexed document.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services