Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
11-30-2018 06:47 AM
Hello.
I need to convert a field in my Cypher query, from boolean to string.
Now, I execute this query:
MATCH (pref:XmlTag)
WHERE pref._name="orm_PreferredIdentifierFor"
RETURN DISTINCT COUNT(pref.ref) >0 AS isPreferred
Pref.ref has a value like a bunch of letters, or it's null. I'm just interested in priting "true" where pref.ref is set with a value no matter what, or "false" when is null.
I already solved this with the above query, but
with this workaround I obtain a java boolean type, but I need string. So, "true" or "false" in my result must be strings instead of boolean type.
Is there a way to do this?
Thanks in advance.
11-30-2018 08:10 AM
Could you use a CASE statement?
https://neo4j.com/docs/cypher-manual/current/syntax/expressions/#query-syntax-case
11-30-2018 12:27 PM
oleg_neo4j is correct, CASE would work here, but for this case it will be faster to just use toString()
:
MATCH (pref:XmlTag)
WHERE pref._name="orm_PreferredIdentifierFor"
WITH DISTINCT COUNT(pref.ref) > 0 AS isPreferred
RETURN toString(isPreferred) as isPreferred
All the sessions of the conference are now available online