Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
02-25-2020 03:57 AM
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??
02-25-2020 10:37 AM
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 *
02-25-2020 11:13 AM
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
All the sessions of the conference are now available online