Repository: incubator-unomi Updated Branches: refs/heads/master bb96940da -> efc4a9ce3
UNOMI-87 fix issue when removing scoring plan Project: http://git-wip-us.apache.org/repos/asf/incubator-unomi/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-unomi/commit/efc4a9ce Tree: http://git-wip-us.apache.org/repos/asf/incubator-unomi/tree/efc4a9ce Diff: http://git-wip-us.apache.org/repos/asf/incubator-unomi/diff/efc4a9ce Branch: refs/heads/master Commit: efc4a9ce310a129644f744199f97d00d5cd06aac Parents: bb96940 Author: dgaillard <dgaill...@jahia.com> Authored: Fri Jul 7 16:31:04 2017 +0200 Committer: dgaillard <dgaill...@jahia.com> Committed: Fri Jul 7 16:31:04 2017 +0200 ---------------------------------------------------------------------- .../ElasticSearchPersistenceServiceImpl.java | 3 +-- .../unomi/services/services/SegmentServiceImpl.java | 16 ++++++++++------ 2 files changed, 11 insertions(+), 8 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/efc4a9ce/persistence-elasticsearch/core/src/main/java/org/apache/unomi/persistence/elasticsearch/ElasticSearchPersistenceServiceImpl.java ---------------------------------------------------------------------- diff --git a/persistence-elasticsearch/core/src/main/java/org/apache/unomi/persistence/elasticsearch/ElasticSearchPersistenceServiceImpl.java b/persistence-elasticsearch/core/src/main/java/org/apache/unomi/persistence/elasticsearch/ElasticSearchPersistenceServiceImpl.java index 8bf6024..1e601a8 100644 --- a/persistence-elasticsearch/core/src/main/java/org/apache/unomi/persistence/elasticsearch/ElasticSearchPersistenceServiceImpl.java +++ b/persistence-elasticsearch/core/src/main/java/org/apache/unomi/persistence/elasticsearch/ElasticSearchPersistenceServiceImpl.java @@ -842,8 +842,7 @@ public class ElasticSearchPersistenceServiceImpl implements PersistenceService, .execute() .actionGet(); } else { - UpdateRequest updateRequest = client.prepareUpdate(index, itemType, itemId).setScript(actualScript). - setRefreshPolicy(WriteRequest.RefreshPolicy.WAIT_UNTIL).request(); + UpdateRequest updateRequest = client.prepareUpdate(index, itemType, itemId).setScript(actualScript).request(); bulkProcessor.add(updateRequest); } return true; http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/efc4a9ce/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 979c3cb..47eda18 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 @@ -936,14 +936,18 @@ public class SegmentServiceImpl extends AbstractServiceImpl implements SegmentSe scoringCondition.setConditionType(definitionsService.getConditionType("profilePropertyCondition")); scoringCondition.setParameter("propertyName", "scores." + scoringId); scoringCondition.setParameter("comparisonOperator", "exists"); - List<Profile> previousProfiles = persistenceService.query(scoringCondition, null, Profile.class); + Condition[] conditions = new Condition[1]; + conditions[0] = scoringCondition; - HashMap<String, Object> scriptParams = new HashMap<>(); - scriptParams.put("scoringId", scoringId); + HashMap<String, Object>[] scriptParams = new HashMap[1]; + scriptParams[0] = new HashMap<String, Object>(); + scriptParams[0].put("scoringId", scoringId); + + String[] script = new String[1]; + script[0] = "ctx._source.scores.remove(params.scoringId)"; + + persistenceService.updateWithQueryAndScript(null, Profile.class, script, scriptParams, conditions); - for (Profile profileToRemove : previousProfiles) { - persistenceService.updateWithScript(profileToRemove.getItemId(), null, Profile.class, "ctx._source.scores.remove(scoringId)", scriptParams); - } logger.info("Profiles updated in {}ms", System.currentTimeMillis() - t); }