Neo4j密码查询返回的布尔值

时间:2019-01-25 00:23:06

标签: neo4j cypher

我有此查询用于返回hashTag namehashTag count,如果它具有Featured标签,则返回trueHashTag节点只有一个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的更好的方法。 有人有什么主意吗? 谢谢

1 个答案:

答案 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