It's a little hard to figure just what cypher is able to do- it seems like
something like this should work. My best attempt so far is two MATCH
clauses:
MATCH n-[r1?]->()
MATCH n-[r2?]->()
RETURN count(type(r1)), count(type(r2))
Is there a better way to do this?
On a side note- how does having the two match statements affect the
performance of the cypher query? Does it loop over all relationships of
each node twice? This could be costly when I have a dense graph.
> It's a little hard to figure just what cypher is able to do- it seems like
> something like this should work. My best attempt so far is two MATCH
> clauses:
> MATCH n-[r1?]->()
> MATCH n-[r2?]->()
> RETURN count(type(r1)), count(type(r2))
> Is there a better way to do this?
> On a side note- how does having the two match statements affect the
> performance of the cypher query? Does it loop over all relationships of each
> node twice? This could be costly when I have a dense graph.
> > It's a little hard to figure just what cypher is able to do- it seems
> like
> > something like this should work. My best attempt so far is two MATCH
> > clauses:
> > MATCH n-[r1?]->()
> > MATCH n-[r2?]->()
> > RETURN count(type(r1)), count(type(r2))
> > Is there a better way to do this?
> > On a side note- how does having the two match statements affect the
> > performance of the cypher query? Does it loop over all relationships of
> each
> > node twice? This could be costly when I have a dense graph.
> > It's a little hard to figure just what cypher is able to do- it seems like
> > something like this should work. My best attempt so far is two MATCH
> > clauses:
> > MATCH n-[r1?]->()
> > MATCH n-[r2?]->()
> > RETURN count(type(r1)), count(type(r2))
> > Is there a better way to do this?
> > On a side note- how does having the two match statements affect the
> > performance of the cypher query? Does it loop over all relationships of each
> > node twice? This could be costly when I have a dense graph.
<michael.hun...@neotechnology.com> wrote:
> ....
> with collect(r) as rels
> return length(filter(r in rels : type(r) == 'REL1')) as REL1,
> length(filter(r in rels : type(r) == 'REL2')) as REL2
> Cheers
> Michael
> Am 02.10.2012 um 21:55 schrieb tcb:
> thanks, but that returns the total count of either REL1 or REL2. What I
> would like to do is return the separate counts, rather than the aggregate:
> return count(REL1), count(REL2)
> Is there a way to do this?
> thanks,
> On Tue, Oct 2, 2012 at 8:36 PM, Peter Neubauer
> <peter.neuba...@neotechnology.com> wrote:
>> Hi there, you can do
>> START n=node(1)
>> MATCH n-[r?:REL1|REL2]->()
>> RETURN type(r), count(*)
>> > It's a little hard to figure just what cypher is able to do- it seems
>> > like
>> > something like this should work. My best attempt so far is two MATCH
>> > clauses:
>> > MATCH n-[r1?]->()
>> > MATCH n-[r2?]->()
>> > RETURN count(type(r1)), count(type(r2))
>> > Is there a better way to do this?
>> > On a side note- how does having the two match statements affect the
>> > performance of the cypher query? Does it loop over all relationships of
>> > each
>> > node twice? This could be costly when I have a dense graph.
> On Tue, Oct 2, 2012 at 10:21 PM, Michael Hunger
> <michael.hun...@neotechnology.com> wrote:
>> ....
>> with collect(r) as rels
>> return length(filter(r in rels : type(r) == 'REL1')) as REL1,
>> length(filter(r in rels : type(r) == 'REL2')) as REL2
>> Cheers
>> Michael
>> Am 02.10.2012 um 21:55 schrieb tcb:
>> thanks, but that returns the total count of either REL1 or REL2. What I
>> would like to do is return the separate counts, rather than the aggregate:
>> return count(REL1), count(REL2)
>> Is there a way to do this?
>> thanks,
>> On Tue, Oct 2, 2012 at 8:36 PM, Peter Neubauer
>> <peter.neuba...@neotechnology.com> wrote:
>>> Hi there, you can do
>>> START n=node(1)
>>> MATCH n-[r?:REL1|REL2]->()
>>> RETURN type(r), count(*)
>>>> It's a little hard to figure just what cypher is able to do- it seems
>>>> like
>>>> something like this should work. My best attempt so far is two MATCH
>>>> clauses:
>>>> MATCH n-[r1?]->()
>>>> MATCH n-[r2?]->()
>>>> RETURN count(type(r1)), count(type(r2))
>>>> Is there a better way to do this?
>>>> On a side note- how does having the two match statements affect the
>>>> performance of the cypher query? Does it loop over all relationships of
>>>> each
>>>> node twice? This could be costly when I have a dense graph.
I've noticed there are stats for cypher queries on the scala side- is there
any progress on exposing them to java-side? It would be a great help to
improve our cypher queries...
https://github.com/neo4j/community/issues/730
michael.hun...@neotechnology.com> wrote:
> ....
> with collect(r) as rels
> return length(filter(r in rels : type(r) == 'REL1')) as REL1,
> length(filter(r in rels : type(r) == 'REL2')) as REL2
> Cheers
> Michael
> Am 02.10.2012 um 21:55 schrieb tcb:
> thanks, but that returns the total count of either REL1 or REL2. What I
> would like to do is return the separate counts, rather than the aggregate:
> return count(REL1), count(REL2)
> Is there a way to do this?
> thanks,
> On Tue, Oct 2, 2012 at 8:36 PM, Peter Neubauer <
> peter.neuba...@neotechnology.com> wrote:
>> Hi there, you can do
>> START n=node(1)
>> MATCH n-[r?:REL1|REL2]->()
>> RETURN type(r), count(*)
>> > It's a little hard to figure just what cypher is able to do- it seems
>> like
>> > something like this should work. My best attempt so far is two MATCH
>> > clauses:
>> > MATCH n-[r1?]->()
>> > MATCH n-[r2?]->()
>> > RETURN count(type(r1)), count(type(r2))
>> > Is there a better way to do this?
>> > On a side note- how does having the two match statements affect the
>> > performance of the cypher query? Does it loop over all relationships of
>> each
>> > node twice? This could be costly when I have a dense graph.
> I've noticed there are stats for cypher queries on the scala side- is there
> any progress on exposing them to java-side? It would be a great help to
> improve our cypher queries...
> https://github.com/neo4j/community/issues/730
> thanks,
> On Tue, Oct 2, 2012 at 9:21 PM, Michael Hunger
> <michael.hun...@neotechnology.com> wrote:
>> ....
>> with collect(r) as rels
>> return length(filter(r in rels : type(r) == 'REL1')) as REL1,
>> length(filter(r in rels : type(r) == 'REL2')) as REL2
>> Cheers
>> Michael
>> Am 02.10.2012 um 21:55 schrieb tcb:
>> thanks, but that returns the total count of either REL1 or REL2. What I
>> would like to do is return the separate counts, rather than the aggregate:
>> return count(REL1), count(REL2)
>> Is there a way to do this?
>> thanks,
>> On Tue, Oct 2, 2012 at 8:36 PM, Peter Neubauer
>> <peter.neuba...@neotechnology.com> wrote:
>>> Hi there, you can do
>>> START n=node(1)
>>> MATCH n-[r?:REL1|REL2]->()
>>> RETURN type(r), count(*)
>>> > It's a little hard to figure just what cypher is able to do- it seems
>>> > like
>>> > something like this should work. My best attempt so far is two MATCH
>>> > clauses:
>>> > MATCH n-[r1?]->()
>>> > MATCH n-[r2?]->()
>>> > RETURN count(type(r1)), count(type(r2))
>>> > Is there a better way to do this?
>>> > On a side note- how does having the two match statements affect the
>>> > performance of the cypher query? Does it loop over all relationships of
>>> > each
>>> > node twice? This could be costly when I have a dense graph.