guido
( Guido)
March 20, 2025, 12:14pm
1
In the following query:
MATCH (s:Source)
WITH [ "TITLE: " + s.title,
"SUBTITLE: " + s.subtitle,
"TYPE: " + s.type,
"DEGREE: " = s.degree,
"YEAR: " + s.year,
"LANGUAGE: " + s.language,
"APPEARED IN: " + s3.title,
"ISBN: " + s.ISBN,
"URL: " + s.url,
"Comment: " + s.comment,
"STCV: " + s.STCV,
"WikiData: " + s.wikidata,
"SourceID: " + s.sourceID
] as allData
WITH [i in allData where not i ends with ': '] as data
UNWIND data as INFORMATION
RETURN INFORMATION
s.STCV and s.URL should be returned as hyperlinks but they are returned as strings.
('''RETURN s.STCV, s.URL''' does yield hyperlinks)
How to fix this? Thanks for any suggestion!
Maybe if you return the value separately it will be interpreted as a hyperlink.
MATCH (s:Source)
WITH {
TITLE: s.title,
SUBTITLE: s.subtitle,
TYPE: s.type,
DEGREE: s.degree,
YEAR: s.year,
LANGUAGE: s.language,
APPEARED_IN: s.title,
ISBN: s.ISBN,
URL: s.url,
Comment:s.comment,
STCV: s.STCV,
WikiData: s.wikidata,
SourceID: s.sourceID
} as allData
UNWIND keys(allData) as key
WITH key, allData[key] as property
WHERE property IS NOT NULL
RETURN *
You can do the following if the node's property names are the same as the labels you want to return:
MATCH (s:Source)
UNWIND keys(s) as key
RETURN key, s[key] as property
guido
( Guido)
March 20, 2025, 3:16pm
3
Wirks perfectly, thanks (again)!
1 Like
guido
( Guido)
March 24, 2025, 3:45pm
4
One more question, though.
I want the fields to appear exactly in the order in which they are listed in the WITH clause:
TITLE: s.title,
SUBTITLE: s.subtitle,
TYPE: s.type,
DEGREE: s.degree,
YEAR: s.year,
LANGUAGE: s.language,
APPEARED_IN: s3.title,
ISBN: s.ISBN,
URL: s.url,
Comment:s.comment,
STCV: s.STCV,
WikiData: s.wikidata,
SourceID: s.sourceID
In your query, however, the order has been randomized:
The node's properties are stored in a hash map, which does not maintain any predicable ordering. You can define the sort order of the properties and use this list to drive the ordering of the output.
WITH ['title', 'subtitle', 'type', 'degree', 'year', 'null_property'] as keysByOrder
MATCH (s:Source)
UNWIND keysByOrder as key
WITH key, s
WHERE s[key] IS NOT NULL
RETURN toUpper(key), s[key] as property