我有此查询用于返回hashTag name
,hashTag count
,如果它具有Featured
标签,则返回true
。 HashTag
节点只有一个tag
属性`。工作正常:
MATCH (:RateableEntity)<-[:TAG]-(hashtag:HashTag:Featured)
WITH hashtag,
(CASE WHEN 'Featured' IN LABELS(hashtag) THEN true ELSE false END) AS HASHTAG_FEATURED_LABEL
RETURN hashtag.tag As HASHTAG_NAME,
COUNT(hashtag) as HASHTAG_FREQUENTLY,
HASHTAG_FEATURED_LABEL
ORDER BY HASHTAG_NAME ASC
SKIP 0
LIMIT 20
但是我正在寻找一种没有Case
的更好的方法。
有人有什么主意吗?
谢谢
答案 0 :(得分:0)
您可以只返回表达式,而无需此处的CASE:
MATCH (:RateableEntity)<-[:TAG]-(hashtag:HashTag:Featured)
WITH hashtag,
'Featured' IN LABELS(hashtag) AS HASHTAG_FEATURED_LABEL
RETURN hashtag.tag As HASHTAG_NAME,
COUNT(hashtag) as HASHTAG_FREQUENTLY,
HASHTAG_FEATURED_LABEL
ORDER BY HASHTAG_NAME ASC
SKIP 0
LIMIT 20