Thanks for replying sorry for the mess, I'm a little new to all of this The reason for the query is for search purposes and want to be able to combine two queries as an 'or' and return them as one set of unique nodes, or a collection of unique nodes while getting only set number of results back and get the next set when requested.
i have made a GraphGist with three queries related to the issue and revised based off your advice http://gist.neo4j.org/?9604566 i can't figure out how to add two groups together in one group that has all unique nodes so that i can 'skip and limit' a collection, i can't add a subscript to each of the groups since one group could have a lot more than the other meaning when one side is done, i'm only requesting half of what i was asking for since only one of the groups can return nodes return or have to re-query to change the subscript so that it only gets from the group that only has nodes now but when i subscript a combined group i get duplicates i hope i did better at explaining Thanks On Friday, March 14, 2014 8:55:14 PM UTC-4, Michael Hunger wrote: > > 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]<javascript:> > >: > > 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] <javascript:>. > 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.
