Graph DB get the next best recommended node in Neo4j cypher -


i have graph using neo4j , trying build simple recommendation system better text based search.

nodes created such as: album, people, type, chart

relationship created such as:

people - [:role] -> album roles are: artist, producer, songwriter

album-[:is_a_type_of]->type (type pop, rock, disco...)

people -[:popular_on]->chart (chart billboard might have been)

people -[:similar_to]->people (predetermined similarity connection)

i have written following cypher:

    match (a:album { id: { id } })-[:is_a_type_of]->(t)<-[:is_a_type_of]-(recommend)         recommend, t,     match (recommend)<-[:artist_of]-(p)     optional match (p)-[:popular_on]->()     return recommend, count(distinct t) type     order type desc     limit 25; 

it works however, repeats if has 1 type of music connected it, therefore has same neighbors.

is there suggested way say:

  • find me next best album has similar connected relationships starting album from.
  • any recommendation tie breaker scenario? right order type (so if album has more 1 type of music valued more if has same number, there no more significant)
  • -i made [:similar_to] link enforce priority consider relationship important, haven't had working cypher it
  • -same goes [:popular_on] (maybe drop relationship?)

you can use 4 configurations , order albums according higher value in order. keep configuration between 0 1 (ex. 0.6)

a. people popular on chart , people similar b. people popular on chart , people not similar c. people not popular on chart , people similar d. people not popular on chart , people not similar 

calculate , sum these 4 values each album. higher value, higher recommended album.

i have temporarily made config = 1, b =0.8, c=0.6, d = 0.4. , assumed relationship present suggests people likes album. if making logic based on chart use & b only.

match (me:people) id(me) = 123 match (a:album { id: 456 })-[:is_a_type_of]->(t:type)<-[:is_a_type_of]-(recommend)     optional match (recommend)<-[:artist_of]-(a:people)-[:popular_on]->(:chart) exists((me)-[:similar_to]->(a)) optional match (recommend)<-[:artist_of]-(b:people)-[:popular_on]->(:chart) not exists((me)-[:similar_to]->(b)) optional match (recommend)<-[:likes]-(c:people) exists((me)-[:similar_to]->(a)) optional match (recommend)<-[:likes]-(d:people) not exists((me)-[:similar_to]->(a)) return recommend, (count(a)*1 + count(b)*0.8 + count(c)* 0.6+count(d)*0.4) rec_order order rec_order desc limit 10; 

Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -