Hi,

your queries quite hard to read, could you stick with lowercase identifiers for 
nodes and rels and lower-camel-case for Properties?

Also you don't have to do:  HAS(D.Club) AND D.Club='Club5'
this is enough:  D.Club='Club5'

And please use relationship-types in your queries!


What is it you actually want to do? Please explain your model and use-cases 
with a picture and some description, best create a GraphGist 
(http://gist.neo4j.org) for it. 
Then you have example data and can run your use-case queries.

Michael

Am 14.03.2014 um 20:26 schrieb Graham Berry <[email protected]>:

> 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

I think the issue here is that you reuse "D" which adds and additional check 
for the :Artifact label to D and also tests two different D.Club conditions. So 
your optional matches are probably all filtered out

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

SET is not a good name for an identifier

This should not work at all, where is SET2 coming from?
And you shadow your original SET too.


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

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