简体   繁体   English

如何在 Neo4j 中找到具有最相似间接连接的节点

[英]How to find nodes with most similar indirect connections in Neo4j

I am trying to make a headphone recommendation tool where it shows you the most similar headphones to a specific set.我正在尝试制作一个耳机推荐工具,它可以向您展示与特定耳机最相似的耳机。

I have :Headphone and a lot of different indirect connections, for example :Brand or :Price_Point .我有:Headphone和许多不同的间接连接,例如:Brand:Price_Point

For example, I'm looking for similar headphones to :Headphone called "HD600" and it's made by the brand Sennheiser so I want to get the headphones that have the most similar connections, for example being also made by Sennheiser, in the same Price range, in the same Sound Signature, etc...例如,我正在寻找与:Headphone称为“HD600”类似的耳机,它由 Sennheiser 品牌制造,所以我想以相同的价格获得具有最相似连接的耳机,例如也是由 Sennheiser 制造的范围,在相同的声音签名等...

If I for example run如果我例如运行

MATCH (q:Headphone {name: 'HD600'})-[ind_connector1]-(ind_connection)-[ind_connector_2]-(other_headphone: Headphone)
RETURN q, ind_connection, other_headphone LIMIT 5

it will just return me five headphones that are also over-ear but not similar in any other way.它只会返回给我五个耳机,它们也是耳罩式但在任何其他方面都不相似。 Is there any way I can get the Nodes with the most similar connections?有什么方法可以让我获得具有最相似连接的节点?

You can try something like this (counting the distinct ind_connections) between two headphones.您可以在两个耳机之间尝试这样的事情(计算不同的 ind_connections)。

MATCH (q:Headphone {name: 'HD600'})-[ind_connector1]-(ic:ind_connection)-[ind_connector_2]-(other_headphone: Headphone)

RETURN q, other_headphone, COUNT( DISTINCT ic) AS ics
ORDER BY ics DESC
LIMIT 5

This is how to get other headphones with the same brand and price range.这是如何获得具有相同品牌和价格范围的其他耳机。

Start with your headphone with name: 'HD600' and related headphone (h2) of the same brand Sennheiser.从您的耳机开始,名称为:“HD600”和同品牌 Sennheiser 的相关耳机 (h2)。 Then look for the Price (p) and find related headphones with the same price (p)然后寻找价格(p),找到相同价格(p)的相关耳机

//find headphones (h2) with the same brand 
MATCH (h1:Headphone {name: 'HD600'}) -- (b:Brand) -- (h2:Headphone) , (h1) -- (p:Price_Point)
//find related headphones (h2) with the same price
MATCH (h2) -- (p)
RETURN h1, h2, b, p LIMIT 5

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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