Hello Everyone! My name is Vidhi and I am new to neo4j. I was trying to achieve a requirement where I am trying to find most influential customers based on the FRIENDS relationship which I already have setup. Sample code for my different nodes in database is as follows:
CREATE (p1:Product {Category:'phones', Id:'11', productName: 'iPhone 11 Pro', productPrice: '1249.99', productImage: '11.png', productManufacturer: 'Apple', productCondition: 'New', productDiscount: '20', productonsale: 'no', inventory: '30'})
CREATE (c1:Customer {name:' Smith Rebecca', street: '993 Alsip Alora', city:'Chicago', state: 'IL', zip: '60803', credit_card:'1234-1234-2345-3456'})
CREATE (or1:Order {Order_ID:'409A0', orderName:'Sony Bravia', Order_Date:'2020-10-23'})
CREATE (c1)-[:PLACED_ORDER {status:'Approved', Order_Returned:'yes'}]->(or1)
CREATE (or1)-[:SOLD {Product_Name:'Sony Bravia'}]->(p37)
CREATE (c1)-[:WROTE_REVIEW {Review:'Awesome product'}]->(or1)
CREATE (or1)-[:REVIEWS {Product_Name:'Sony Bravia', rating:'5'}]->(p37)
CREATE (c1)-[:FRIENDS ]->(c2)
CREATE (c1)-[:SHARED]->(p1)- [:PRODUCT_WITH]->(c2)
I want to create a model and test influential reviewers and superconnectors using PageRank, ArticleRank, and Betweenees. I used the following MERGE operation for creating nodes and relationships:
// Node Labels
MERGE (c:Customer {name: "Customer"})
MERGE (ct:Category{name: "Category"})
MERGE (p:Product {name: "Product"})
MERGE (o:Order {name: "Order"})
MERGE (r:Review {name: "Review"})
// Relationship Types
MERGE (c)-[:FRIENDS]->(c)
MERGE (p)-[:IN_CATEGORY]->(ct)
MERGE (c)-[:WROTE_REVIEW]->(r)
MERGE (c)-[:PLACED_ORDER]->(o)
MERGE (o)-[:SOLD]->(p)
MERGE (r)-[:REVIEWS]->(p)
The table shows empty though. Where am I doing it wrong.
Also, for creating pagerank, I used the following query but it gives me error no node available:
CALL gds.pageRank.write({
nodeQuery: 'MATCH (c:Customer)-[:WROTE_REVIEW]->(r:Review), ((r:Review )-[:REVIEWS]->( o:Order)), ((o:Order )-[:SOLD]->( p:Product)), (p)-[:IN_CATEGORY]->(:Category {category: $category}) WITH c, count(*) AS reviews WHERE reviews >= $cutoff RETURN id(c) AS id',
relationshipQuery: 'MATCH (c1:Customer)-[:WROTE_REVIEW]->(r:Review), ((r:Review )-[:REVIEWS]->( o:Order)), ((o:Order )-[:SOLD]->( p:Product)), (p)-[:IN_CATEGORY]->(:Category {category: $category}) MATCH (c1)-[:FRIENDS]->(c2) RETURN id(c1) as source, id(c2) AS target',
writeProperty: "phonePagerank",
validateRelationships: false,
parameters: {category: "phones", cutoff: 0}
})
YIELD nodePropertiesWritten, createMillis, computeMillis, writeMillis, ranIterations
RETURN nodePropertiesWritten, createMillis, computeMillis, writeMillis, ranIterations
Can someone please help me for same.
Thanks