Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
06-13-2022 02:34 PM
Hi,
Scenario:
I have 3 basic node labels: Document, Classification, and Word and I am running some similarity algorithms against them. Basically I am finding documents that share similar classification connections and separately I am finding documents that share similar words (in abstract). I have used nodeSimilarity and it does seem to produce the desired result with one exception between nodes I have multiple relationships each with a score for the node similarity.
For a given pair there are four relationships (in this case) all labeled Similar since that is the term I used as the write property and each relationship contains one score value.
What I would like is 1 pair of relationships with the different scores as properties of that relationship.
Have
A - Similar - B classScore 0.98
A - Similar - B wordScore 0.95
...
I would like a singular relationship akin to to a merge statement that would contain the score values.
Is there a simple way to force GDS.algorithm.write to execute the equivalent of a merge statement and just append a new score or change an existing one?
Andy
Solved! Go to Solution.
06-15-2022 12:59 AM - edited 06-15-2022 01:27 AM
Hello @andy_hegedus 😊
MATCH (a)-[r:SIMILAR]-(b)
WITH a, b, collect(r) AS relations
CALL apoc.refactor.mergeRelationships(relations, {properties: "combine"})
YIELD rel
RETURN count(*)
Regards,
Cobra
06-15-2022 12:59 AM - edited 06-15-2022 01:27 AM
Hello @andy_hegedus 😊
MATCH (a)-[r:SIMILAR]-(b)
WITH a, b, collect(r) AS relations
CALL apoc.refactor.mergeRelationships(relations, {properties: "combine"})
YIELD rel
RETURN count(*)
Regards,
Cobra
06-18-2022 08:40 AM
I think you can raise it as a feature request on the repository to merge the results instead of just adding new relationships.
06-18-2022 10:55 AM
I have added a feature request.
Andy
All the sessions of the conference are now available online