简体   繁体   中英

find similar weighted nodes in neo4j

  • Nike Sells(weight .9) Shoes
  • Nike Sells(weight .5) Apparel
  • Reebok Sells(weight .9) Shoes ...

We are talking about 10k brands and around 100k relations.

Now given a Brand like Puma I need to find brands which are similar to Puma based on what they sell.

I read about general similarity search, but didn't get how we can include weights in the query.

MATCH (b:Brand {name: 'Puma'})
WITH b
MATCH x = (b) - [:SELLS] -> (:Item) <- [:SELLS] - (ob:Brand)
RETURN b, ob, ABS(SUM(RELATIONSHIPS(x)[0]['weight'] - RELATIONSHIPS(x)[1]['weight']))

You can change how the difference in weights is scored, but that's how you can at least collect all of the paths to other brands to get the weights to compare.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM