streams-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sblack...@apache.org
Subject git commit: writer should work without metadata
Date Thu, 11 Sep 2014 16:32:56 GMT
Repository: incubator-streams
Updated Branches:
  refs/heads/STREAMS-164 3ee517573 -> df00e4a06


writer should work without metadata


Project: http://git-wip-us.apache.org/repos/asf/incubator-streams/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-streams/commit/df00e4a0
Tree: http://git-wip-us.apache.org/repos/asf/incubator-streams/tree/df00e4a0
Diff: http://git-wip-us.apache.org/repos/asf/incubator-streams/diff/df00e4a0

Branch: refs/heads/STREAMS-164
Commit: df00e4a06376bacda755618595922cd3382d121a
Parents: 3ee5175
Author: Steve Blackmon <sblackmon@w2odigital.com>
Authored: Thu Sep 11 11:32:53 2014 -0500
Committer: Steve Blackmon <sblackmon@w2odigital.com>
Committed: Thu Sep 11 11:32:53 2014 -0500

----------------------------------------------------------------------
 .../elasticsearch/ElasticsearchPersistWriter.java    | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/df00e4a0/streams-contrib/streams-persist-elasticsearch/src/main/java/org/apache/streams/elasticsearch/ElasticsearchPersistWriter.java
----------------------------------------------------------------------
diff --git a/streams-contrib/streams-persist-elasticsearch/src/main/java/org/apache/streams/elasticsearch/ElasticsearchPersistWriter.java
b/streams-contrib/streams-persist-elasticsearch/src/main/java/org/apache/streams/elasticsearch/ElasticsearchPersistWriter.java
index 664dd24..bfb21f5 100644
--- a/streams-contrib/streams-persist-elasticsearch/src/main/java/org/apache/streams/elasticsearch/ElasticsearchPersistWriter.java
+++ b/streams-contrib/streams-persist-elasticsearch/src/main/java/org/apache/streams/elasticsearch/ElasticsearchPersistWriter.java
@@ -144,9 +144,18 @@ public class ElasticsearchPersistWriter implements StreamsPersistWriter,
DatumSt
 
         checkForBackOff();
 
-        String index = (String) streamsDatum.getMetadata().get("index");
-        String type = (String) streamsDatum.getMetadata().get("type");
-        String id = setId(streamsDatum);
+        Map<String, Object> metadata = streamsDatum.getMetadata();
+
+        String index = null;
+        String type = null;
+        String id = streamsDatum.getId();
+
+        if( metadata != null && metadata.containsKey("index"))
+            index = (String) streamsDatum.getMetadata().get("index");
+        if( metadata != null && metadata.containsKey("type"))
+            type = (String) streamsDatum.getMetadata().get("type");
+        if( id == null && metadata != null && metadata.containsKey("id"))
+            id = (String) streamsDatum.getMetadata().get("id");
 
         if(index == null || (config.getForceUseConfig() != null && config.getForceUseConfig()))
{
             index = config.getIndex();


Mime
View raw message