简体   繁体   中英

Boolean value return from Neo4j cypher query

I have this query for returning the hashTag name , hashTag count and if it has the Featured label return true . HashTag node just has a tag property`. It's working :

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

But I'm searching for a better way without Case . Does anyone have any idea? Thanks

You can just return the expression, no need for the CASE here :

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM