Why do you re-match things time and again? So you generate a multitude of
paths that are duplicate.
You should also use labels + and index or constraint for :User(profileId)
so that your lookup of a is fast enough.
And you probably want to specify a relationship type and direction.

create index on :User(profileId);

MATCH (a:User)--(b)
WHERE a.profileId = '203'
OPTIONAL MATCH (b)--(c)--(d)
RETURN distinct a,b,c,d limit 500

Optional match is like an outer join



On Tue, Jul 29, 2014 at 11:53 PM, Yufan Wang <[email protected]> wrote:

> Dear All,
>
> We are using a Cypher Query to fetch data from Neo4j 2.1.2 database:
>
>                 MATCH (a)--(b)
>                 WHERE a.profileId = '203'
>                 OPTIONAL MATCH (a)--(b)--(c)
>                 WHERE a.profileId = '203'
>                 OPTIONAL MATCH (a)--(b)--(c)--(d)
>                 WHERE a.profileId = '203'
>                 RETURN distinct a,b,c,d limit 500
>
> And we getting the correct wanted data as below:
>
>    a b c d  {"profileId":"203"} {"profileId":"2490012091"}
> {"profileId":"243942106"} {"profileId":"700910299"}  {"profileId":"203"}
> {"profileId":"2490012091"} {"profileId":"243942106"}
> {"profileId":"19905698"}  {"profileId":"203"} {"profileId":"2490012091"}
> {"profileId":"243942106"} {"profileId":"283869724"}  {"profileId":"203"}
> {"profileId":"2490012091"} {"profileId":"243942106"}
> {"profileId":"344029409"}  {"profileId":"203"} {"profileId":"2490012091"}
> {"profileId":"243942106"} {"profileId":"53596339"}  {"profileId":"203"}
> {"profileId":"2490012091"} {"profileId":"243942106"}
> {"profileId":"395834378"}.....
>
> Actually (a)--(b) are having 5 edge-node pairs, but the 1 of 5 pair 203 -
> 2490012091, are having too much sub-links. This is because Neo4j using
> depth first searching by default.
>
> In this case, the rest 4 of 5 (a)--(b) link pairs are invisible when we
> limit returned result as 500.
>
> I did not find any algorithm settings in the REST API (Manual Chapter 6.1
> and 19.1)
>
> Is it possible to switch the algorithm in Cypher Query (By web service
> REST API)?
>
> Regards,
>
> Thank you
>
> Yufan
>
>  --
> 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 [email protected].
> 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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to