I have an issue with LIMIT the number of results from a COLLECT when i have 
to combine two collections together or combining two matches together
i need to limit and skip for a search, so that the next set is unique from 
the last

for instance:
MATCH (X:Place)<-[]-(D:Person)-[*1..5]->( A:Friend) 
WHERE HAS(D.Club) AND D.Club='Club5'
OPTIONAL MATCH ( D:Artifact)-[*1..5]->( I:Site)
WHERE HAS(D.Club) AND D.Club='testClub'
RETURN DISTINCT D;

Expected results of return is 27 and it returns 5

and

MATCH (X:Place)<-[]-(D:Person)-[*1..5]->( A:Friend) 
WHERE HAS(D.Club) AND D.Club='Club5' AND HAS(X.Name) AND X.Name='London'
WITH D as SET
OPTIONAL MATCH ( V:Artifact)-[*1..5]->( I:Site)
WHERE HAS(V.Club) AND V.Club='testClub'
WITH V as SET, SET2
RETURN DISTINCT SET, SET2;
will bring back 27 together but i can't limit the total all together like 
this

MATCH (X:Place)<-[]-(D:Person)-[*1..5]->( A:Friend) 
WHERE HAS(D.Club) AND D.Club='Club5' AND HAS(X.Name) AND X.Name='London'
WITH DISTINCT D as SET
OPTIONAL MATCH ( V:Person)-[*1..5]->( I:Friend)
WHERE HAS(V.Club) AND V.Club='testClub'
WITH DISTINCT V as SET, SET2
RETURN DISTINCT SET, SET2 LIMIT 10;
This brings back 7 nodes and all the nodes in each group are not unique

So i tried to Collect them then merge them like this in one group

MATCH (X:Place)<-[]-(D:Person)-[*1..5]->( A:Friend) 
WHERE HAS(D.Club) AND D.Club='Club5' AND HAS(X.Name) AND X.Name='London'
WITH COLLECT(DISTINCT D) as SET
OPTIONAL MATCH ( V:Person)-[*1..5]->( I:Friend)
WHERE HAS(V.Club) AND V.Club='testClub'
WITH COLLECT(DISTINCT V) as SET2, SET
RETURN COLLECT(DISTINCT SET2 + SET) LIMIT 10;

then limit it but, the LIMIT outside of the COLLECT only limits the number 
of collections returned, instead of limiting the number of nodes inside the 
collection but if i add it inside the COLLECT i get an error. 

Invalid input 'l'


I don't want to return the entire collection and only take 10 from X number 
return which could be alot, slowing the query then it needs to

If i even add the two Queries together like this:

MATCH (X:Place)<-[]-(D:Person)-[*1..5]->( A:Friend), (D:Person)-[*1..5]->(V:
Friend)  
WHERE HAS(D.Club) AND D.Club='Club5' AND HAS(X.Name) AND X.Name='London' OR 
HAS(D.Club) AND D.Club='testClub'
RETURN D LIMIT 10
I get the results from the first MATCH, no results from the second MATCH to 
get the right amount

I hope someone has a solution,

   Thanks 














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