Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
03-16-2021 11:01 AM
I'm trying to find the maximum possible value a property can have excluding one property.
In generic syntax:
MATCH (n:Node) WHERE not n.property='unknown'
RETURN max(n.property)
I tried the cypher query:
MATCH (f:FlavinAtom) WHERE not f.SASA_atom='unknown'
RETURN max(f.SASA_atom)
Which returns "9.99.." but I know, based on the CSV value that I imported it should be "52.54..." Also, I can find the node I'm looking for and the value I expect when I look it up by it's ID, see screenshot:
Also, I can find the value in the list when I use the following cypher query and export to CSV:
MATCH (p:FlavinAtom) WHERE exists(p.SASA_atom)
RETURN p.AtomID, id(p), p.SASA_atom ORDER BY p.SASA_atom DESC LIMIT 5000
Why doesn't the simple query below return the expected result?
MATCH (f:FlavinAtom) WHERE not f.SASA_atom='unknown'
RETURN max(f.SASA_atom)
Thanks!
Solved! Go to Solution.
03-17-2021 10:21 AM
MATCH (f:FlavinAtom) WHERE not f.SASA_atom='unknown'
SET f.SASA_atom = toFloat(f.SASA_atom)
RETURN max(f.SASA_atom)
It works, thank you!
03-16-2021 11:05 AM
Update:
These versions of the query:
MATCH (f:FlavinAtom) WHERE not f.SASA_atom='unknown'
WITH max(f.SASA_atom) as highestSASA
MATCH (f2:FlavinAtom)
where f2.SASA_atom = highestSASA
return f2;
MATCH (f:FlavinAtom) WHERE not f.SASA_atom='unknown'
RETURN f
ORDER BY f.SASA_atom DESC
LIMIT 1
Which I found here: Find node with maximal (minimal) values of property in Neo4j - Stack Overflow
Also don't work.
03-17-2021 01:15 AM
Hello @emroberts95
I think there is a problem of type, you should make sure all your nodes with a float property are floats.
Regards,
Cobra
03-17-2021 10:21 AM
MATCH (f:FlavinAtom) WHERE not f.SASA_atom='unknown'
SET f.SASA_atom = toFloat(f.SASA_atom)
RETURN max(f.SASA_atom)
It works, thank you!
All the sessions of the conference are now available online