You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@unomi.apache.org by dr...@apache.org on 2016/07/11 12:35:33 UTC

incubator-unomi git commit: UNOMI-40 : initialize score map when needed

Repository: incubator-unomi
Updated Branches:
  refs/heads/master afd7a6832 -> d4d6306b2


UNOMI-40 : initialize score map when needed


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

Branch: refs/heads/master
Commit: d4d6306b2e2992a12029f74ea944b0617b6d6157
Parents: afd7a68
Author: Thomas Draier <dr...@apache.org>
Authored: Mon Jul 11 14:35:18 2016 +0200
Committer: Thomas Draier <dr...@apache.org>
Committed: Mon Jul 11 14:35:30 2016 +0200

----------------------------------------------------------------------
 .../org/apache/unomi/services/services/SegmentServiceImpl.java     | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/d4d6306b/services/src/main/java/org/apache/unomi/services/services/SegmentServiceImpl.java
----------------------------------------------------------------------
diff --git a/services/src/main/java/org/apache/unomi/services/services/SegmentServiceImpl.java b/services/src/main/java/org/apache/unomi/services/services/SegmentServiceImpl.java
index 4efbec4..b000c94 100644
--- a/services/src/main/java/org/apache/unomi/services/services/SegmentServiceImpl.java
+++ b/services/src/main/java/org/apache/unomi/services/services/SegmentServiceImpl.java
@@ -659,7 +659,7 @@ public class SegmentServiceImpl implements SegmentService, SynchronousBundleList
             persistenceService.updateWithScript(profileToRemove.getItemId(), null, Profile.class, "ctx._source.scores.remove(scoringId)", scriptParams);
         }
         if(scoring.getMetadata().isEnabled()) {
-            String script = "if (ctx._source.scores.containsKey(scoringId)) { ctx._source.scores[scoringId] += scoringValue } else { ctx._source.scores[scoringId] = scoringValue }";
+            String script = "if (ctx._source.scores == null) { ctx._source.scores=[:] } ; if (ctx._source.scores.containsKey(scoringId)) { ctx._source.scores[scoringId] += scoringValue } else { ctx._source.scores[scoringId] = scoringValue }";
             for (ScoringElement element : scoring.getElements()) {
                 scriptParams.put("scoringValue", element.getValue());
                 for (Profile p : persistenceService.query(element.getCondition(), null, Profile.class)) {