簡體   English   中英

如何在 Neo4j 中找到具有最相似間接連接的節點

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

我正在嘗試制作一個耳機推薦工具,它可以向您展示與特定耳機最相似的耳機。

我有:Headphone和許多不同的間接連接,例如:Brand:Price_Point

例如,我正在尋找與:Headphone稱為“HD600”類似的耳機,它由 Sennheiser 品牌制造,所以我想以相同的價格獲得具有最相似連接的耳機,例如也是由 Sennheiser 制造的范圍,在相同的聲音簽名等...

如果我例如運行

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

它只會返回給我五個耳機,它們也是耳罩式但在任何其他方面都不相似。 有什么方法可以讓我獲得具有最相似連接的節點?

您可以在兩個耳機之間嘗試這樣的事情(計算不同的 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

這是如何獲得具有相同品牌和價格范圍的其他耳機。

從您的耳機開始,名稱為:“HD600”和同品牌 Sennheiser 的相關耳機 (h2)。 然后尋找價格(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