Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
06-21-2022 05:53 AM - last edited on 07-25-2022 09:14 AM by TrevorS
hello.
in my graph we have users that have 2 relation called "favorite" and "seen" with products and product have relation called has with some specification as colors(red blue...) , types(jeans....) and sizes (30...)
so i make some query that when i wanna create favorite or seen relation , it makes a relation with that specific user and the specification of that product calling "weight" and set property for that called "score" and i wanna increase this score every time user that set product to favorite or just seeing that product for example when a user see the product score change to +10 and for favorite change to +20 and then we recommend products with specifications that have most score
my query is
Solved! Go to Solution.
06-21-2022 01:32 PM
Something like the following:
match (user:Users{m_id:""})
match (m:Products{m_id:""})-[:HAS]->(a:Specifications)
merge (user) -[f:FAVORITE]-> (m)
on create set f.score = 0
on match set f.score = f.score + 10
merge (user)-[w:WEIGHT]->(a)
on create set w.score = 0
on match set w.score = w.score + 20
06-21-2022 08:54 AM
You can use ‘on create’ clause with each merge to initialize each weight and use ‘on match’ to update each weight.
06-21-2022 12:04 PM
hi again and tnx for helping.
do you mean something like this ?
06-21-2022 01:32 PM
Something like the following:
match (user:Users{m_id:""})
match (m:Products{m_id:""})-[:HAS]->(a:Specifications)
merge (user) -[f:FAVORITE]-> (m)
on create set f.score = 0
on match set f.score = f.score + 10
merge (user)-[w:WEIGHT]->(a)
on create set w.score = 0
on match set w.score = w.score + 20
06-21-2022 09:45 PM
really help full tnx sir really appreciate
06-22-2022 01:38 AM
hello again i have one more problem😅
im adding a property for specifications that name of them is "color" "type" "size" and its called "ratio" the reason is i want to give them some coefficient to give recommend most based on types then colors and so on
so now i wanna get that ratio and multiply with weight that has relation with that sub specification
this is what i write for give recommend but couldnt save ratio in other variable and then multiply with weight
06-21-2022 12:16 PM
and one more thing how to update weight with that specific attribute
is it even possible to have some weight relation and 1 property that the property has different value ?
and if its not possible what do you think we can do
tnx for your time
All the sessions of the conference are now available online