cancel
Showing results for 
Search instead for 
Did you mean: 

Checking the value of the key and getting its value

busymo16
Ninja
Ninja

I have some nodes and the keys in the nodes are as following:

query = ''' MATCH (p:Product)
RETURN keys(p)'''

["formula_Default", "Product URL", "Data Location", "Disc technology", "Provider HQ", "GHz", "Memory", "Price monthly", "vCore", "SLA", "Support", "Backup", "DDOS", "Apps", "IP", "IPv6", "Virtualization Type", "Disc Space GB", "Operating System", "Network Speed MBit", "Traffic GBytes", "companySize", "branch", "location", "name"]

I want to check, possibly with regex if a the key matches with a string then to get the value of that key: eg.,

MATCH (p:Product)
WHERE toLower(keys(p)) CONTAINS 'formula' OR keys(p) =~ '(?i)formula(?i).*'
RETURN value(p) (Of course this does not work but this is the idea)

Can somebody give me some help here? How can I possibly do something like that??

2 REPLIES 2

shan
Graph Buddy

You can do this:

MATCH (p:Product)
WITH p, [x in keys(p) WHERE x CONTAINS 'formula' OR x =~ '(?i)formula(?i).*' | p[x]] as props
RETURN *

If you don't want to see rows where props is empty, you can add WHERE size(props) > 0 before RETURN *

intouch_vivek
Graph Steward

You can try this
match(n:Product) unwind keys(n) as prop with n as n, prop as prop, prop=~'P.*' as val where val=true return prop,n[prop] as value