Romain Gauthier created UNOMI-1017:
--------------------------------------
Summary: Profile merge replaces properties.interests instead of
summing the points by key
Key: UNOMI-1017
URL: https://issues.apache.org/jira/browse/UNOMI-1017
Project: Apache Unomi
Issue Type: Bug
Components: unomi(-core)
Affects Versions: unomi-3.0.1, unomi-2.7.0
Reporter: Romain Gauthier
When profiles merge, the master profile loses its {{properties.interests}}
list. The list of the last merged profile replaces it, and the interest points
are not added.
*Cause:* no profile property type declares {{interests}}, so {{mergeProfiles}}
uses {{defaultMergeStrategy}}
([ProfileServiceImpl.java#L773|https://github.com/apache/unomi/blob/b795eaa693df0b398c683dad5d0aedb026c529af/services/src/main/java/org/apache/unomi/services/impl/profiles/ProfileServiceImpl.java#L773]).
That executor sets each non-empty value with {{alwaysSet}}, so the last
profile wins
([DefaultPropertyMergeStrategyExecutor.java#L28-L37|https://github.com/apache/unomi/blob/b795eaa693df0b398c683dad5d0aedb026c529af/services/src/main/java/org/apache/unomi/services/mergers/DefaultPropertyMergeStrategyExecutor.java#L28-L37]).
*Proposed fix:* declare an {{interests}} profile property type with a new merge
strategy that sums {{value}} by {{key}}. The mapping already declares the field
([profile.json#L50|https://github.com/apache/unomi/blob/b795eaa693df0b398c683dad5d0aedb026c529af/persistence-elasticsearch/core/src/main/resources/META-INF/cxs/mappings/profile.json#L50]).
The existing {{addMergeStrategy}} does not fit, because it throws on a list
([AddPropertyMergeStrategyExecutor.java#L65|https://github.com/apache/unomi/blob/b795eaa693df0b398c683dad5d0aedb026c529af/services/src/main/java/org/apache/unomi/services/mergers/AddPropertyMergeStrategyExecutor.java#L65]).
*Example:* the master has {{funds}} 30, and the merged profile has {{funds}} 5
and {{pension}} 7.
{code:json}
// master after the merge, today
[{"key": "funds", "value": 5}, {"key": "pension", "value": 7}]
// expected
[{"key": "funds", "value": 35}, {"key": "pension", "value": 7}]
{code}
*Verified:* code reading on master {{b795eaa69}}, on {{unomi-root-3.0.1}} and
on {{unomi-root-2.7.0}}, where the merge code is the same. No test run.
Related: UNOMI-441 asks for a strategy that appends lists. An append keeps two
{{funds}} entries and does not sum them.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)