You would need to use optional match then.

Would it make sense to turn 'type' into a label too?

you could rewrite your query into:

MATCH (c:cc {type : 'type'})
UNWIND keys(c) as key
WHERE key IN ['facebook','email','phone',...]
RETURN c.type as personType, key as attribute, c[key] as measure , count(c)
as attributeCount

On Wed, Oct 5, 2016 at 9:45 AM, Stefaan Delanghe <stefaan.delan...@c4j.be>
wrote:

> I have a cypher which is build dynamically as opposed to call separate
> cyphers all the time. This is an optimization for performance.
>
> This is the cypher i run. the match union concatenation is dynamically.
> My issue is that i would like to retrieve those line that do not match
>
> MATCH (c:cc {type : 'type'}) WHERE c.email is not null RETURN c.type as
> personType, 'email' as attribute, c.email as measure , count(c) as
> attributeCount
> UNION
> MATCH (c:cc {type : 'type'}) WHERE c.address is not null RETURN c.type as
> personType, 'address' as attribute, c.address as measure , count(c) as
> attributeCount
> UNION
> MATCH (c:cc {type : 'type'}) WHERE c.phone is not null RETURN c.type as
> personType, 'phone' as attribute, c.phone as measure , count(c) as
> attributeCount
> UNION
> MATCH (c:cc {type : 'type'}) WHERE c.social is not null RETURN c.type as
> personType, 'social' as attribute, c.social as measure , count(c) as
> attributeCount
> UNION
> MATCH (c:cc {type : 'type'}) WHERE c.twitter is not null RETURN c.type as
> personType, 'twitter' as attribute, c.twitter as measure , count(c) as
> attributeCount
> UNION
> MATCH (c:cc {type : 'type'}) WHERE c.facebook is not null RETURN c.type as
> personType, 'facebook' as attribute, c.facebook as measure , count(c) as
> attributeCount
>
>
> This will give back something like this.
> "type" , 'email' , 1, 34
> "type" , 'phone' , 1, 21
>
> But i want that even when some are not found that a row is given back with
> 0. I would like a list like this
> "type" , 'email' , 1, 34
> "type" , 'phone' , 1, 21
> "type", "address", 0, 0
> "type", "social", 0, 0
>
> Many thanks for your possible advise
>
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Neo4j" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to neo4j+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Neo4j" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to neo4j+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to