i'm in a scenario where i need to capture user profiles that have common likes in a specific user's preferences i tried using MATCH but i would like results to be returned even if one of the calls to MATCH fails i also tried OPTIONAL MATCH but when it doesn't I have an optional relation at the beginning of the query, nothing is returned, here is my example code:
MATCH (p:Profile)-->(pref:Preferences)
OPTIONAL MATCH (pref:Preferences)--(:Gender)<--(p2)
OPTIONAL MATCH (pref:Preferences)--(:AstrologicalSign)--(p2)
OPTIONAL MATCH (pref:Preferences)--(:MusicalStyle)--(p2)
OPTIONAL MATCH (pref:Preferences)--(:Religion)--(p2)
OPTIONAL MATCH (pref:Preferences)--(:Smoke)--(p2)
RETURN a
(ps: sorry if I wasn't clear, English is not my native language)
The return value of 'a' is not defined. Can you provide a data model and/or sample data? Can you explain what you are trying to achieve? What value(s) do you want returned?
In your data model, are all the p2 nodes in the query supposed to be the same node? If so, are the Gender, AstrologicalSign, MusicalStyle, Religion, and Smoke all the types of nodes the path can traverse through, or are there other types you don’t want the path to go through?
Yes, I would like to return the p2:Profile that has or does not match with:
Gender, AstrologicalSign, MusicalStyle, Religion and Smoke
but if I put optional match and there is no relation, p2 is null, I would like to avoid this
I'm working on a dating app, where Profiles can have Preferences, like Gender, MusicalStyle and others, it works great when all Preferences of Profile have matches, but a Profile can match Gender but not MusicalStyle, so I want to bring the result anyway.