返回對象我有這樣一個複雜的查詢:如何從用戶定義的Neo4j功能
MATCH path = allShortestPaths(...)
WITH path, reduce(x={
specificStamp: "",
specificCount: 0,
...
},
r IN relationships(path) |
CASE WHEN ...
THEN {
specificStamp: some-expr(x),
specificCount: another-expr(x),
...
}
...
END
) AS pobj
ORDER BY pobj.specificStamp, pobj.specificCount
RETURN head(COLLECT(path)) AS path, pobj.specificStamp AS stamp, COUNT(*) AS cnt
ORDER BY length(path), stamp
在真正的代碼的邏輯是比較複雜的,包括嵌套CASE
和多用一些複製表達式THEN複雜。 ..
爲了簡化問題,最好將reduce邏輯放入單獨的函數中。但Neo4J用戶定義的函數只能返回一個值。
哪種返回值對應於此密碼錶達式:{specificStamp: "", specificCount: 0}
?可以是Object
?但根據documentationObject
意味着ANY
類型。
可能是Map
?但是,哪個地圖模板? Map<String,String>
衝突與Map<String,Integer>
你是什麼意思:「地圖或地圖」? – Kit
標記吃了三角括號,現在應該清楚了。 – InverseFalcon