Hi,

Thanks for the tips, will see if I can change the client to use the new format. 
Indeed, let me try isolate the problems with more simpler queries. I have built 
a test case below, forgive me if I made it to complex.

Friend => HasPet => Pet => HasCareTaker => CareTaker
Friend => HasPet => Pet => HasCareTaker => CareTaker
Friend

Test Case Script Setup
props = [:];rootNode= g.addVertex(props);props["Name"] = "John";friendNode1 = 
g.addVertex(props);myRelation = g.addEdge(rootNode, friendNode1, 
'AllFriends');props["Name"] = "Jack";friendNode2 = 
g.addVertex(props);myRelation = g.addEdge(rootNode, friendNode2, 
'AllFriends');props["Name"] = "Jill";friendNode3 = 
g.addVertex(props);myRelation = g.addEdge(rootNode, friendNode3, 
'AllFriends');props["Name"] = "ScoobieDoo";petNode1 = 
g.addVertex(props);myRelation = g.addEdge(friendNode1, 
petNode1,'HasPet');props["Name"] = "Garfield";petNode2 = 
g.addVertex(props);myRelation = g.addEdge(friendNode2, 
petNode2,'HasPet');props["Name"] = "Bob";careTakerNode1 = 
g.addVertex(props);myRelation = g.addEdge(petNode1, 
careTakerNode1,'HasCareTaker');props["Name"] = "Harry";careTakerNode2 = 
g.addVertex(props);myRelation = g.addEdge(petNode2, 
careTakerNode2,'HasCareTaker')

Query - Works, but does not have Jill in the table.
rootNode.out('AllFriends').as('Friend').ifThenElse{it.out('HasPet').hasNext()}{it.out('HasPet')}{it}.as('Pet').out('HasCareTaker').as('CareTaker').table(new
 Table()){it['Name']}{it['Name']}{it['Name']}.cap

Output
[[Friend:Jack, Pet:Garfield, CareTaker:Harry], [Friend:John, Pet:ScoobieDoo, 
CareTaker:Bob]]

Attempted Query - Does not work - trying to get Jill (Notice I am trying to use 
println)
rootNode.out('AllFriends').as('Friend').ifThenElse{it.out('HasPet').hasNext()}{it.out('HasPet')}{println
 "${it} Unknown"}.as('Pet').out('HasCareTaker').as('CareTaker').table(new 
Table()){it['Name']}{it['Name']}{it['Name']}.cap

Desired Output
[[Friend:Jack, Pet:Garfield, CareTaker:Harry], [Friend:John, Pet:ScoobieDoo, 
CareTaker:Bob], [Friend:Jill, Pet:unknown, CareTaker:unknown]]]

If I can get this working, it means we can have allot more performance from 
queries without doing separate queries if we have a powerful table projection 
model, since I rely on the REST API, I feel the table projections is going to 
be our core method of joining results in one call, so the idea of left/right 
joins etc.

-----Original Message-----
From: user-boun...@lists.neo4j.org [mailto:user-boun...@lists.neo4j.org] On 
Behalf Of Marko Rodriguez
Sent: Wednesday, 7 December 2011 7:07 PM
To: Neo4j user discussions
Cc: ne...@googlegroups.com
Subject: Re: [Neo4j] println and Table Projections

Hi,

Peter brings up a good point. Its hard for us to parse complex queries and see 
where Exceptions are happening. If you can isolate the problem via a simpler 
traversal, that would be best for us -- and our little baby brains.

Also, note the following syntax optimizations for your traversal:
        1. outE[[label:'HOSTS']].inV ---> out('HOSTS')
        2. Similarly, inE[[label:'X']].outV -> in('X')

Using out() and in() is much more efficient (faster) and more concise. Unless 
you plan to reason on the properties of an edge, then there is no reason to use 
outE.inV style syntax as out will do the full vertex-to-vertex jump for you.

HTH,
Marko.

http://markorodriguez.com

On Dec 7, 2011, at 1:00 AM, Peter Neubauer wrote:

> Mmh,
> I was thinking on how to return the contents of the output stream, I 
> am not quite sure how to return that. What woudl be a good format for 
> you?
> 
> Also could you reduce this into a small testcase that I can work on?
> 
> Cheers,
> 
> /peter neubauer
> 
> GTalk:      neubauer.peter
> Skype       peter.neubauer
> Phone       +46 704 106975
> LinkedIn   http://www.linkedin.com/in/neubauer
> Twitter      http://twitter.com/peterneubauer
> 
> brew install neo4j && neo4j start
> heroku addons:add neo4j
> 
> 
> 
> On Wed, Dec 7, 2011 at 8:10 AM, Romiko Derbynew 
> <romiko.derby...@readify.net> wrote:
>> Hi,
>> 
>> I have this statement.
>> g.v('0').outE[[label:'HOSTS']].inV.filter{ 
>> it['Key'].equalsIgnoreCase('romikoagency') 
>> }.inE[[label:'USER_BELONGS_TO']].outV.filter{ 
>> it['Username'].equalsIgnoreCase('romiko.derbynew') 
>> }.ifThenElse{it.outE[[label:'USER_LINKED_TO_CENTRE']].inV.hasNext()}{
>> it.outE[[label:'USER_LINKED_TO_CENTRE']].inV.Name}{println ${it} 
>> "Unknown"}.as('Centre')
>> 
>> I then take this query and do a table projection, however I get the 
>> following error.
>> println java.lang.String cannot be cast to 
>> com.tinkerpop.blueprints.pgm.Vertex
>> 
>> Is there a better way to do this then? I want to reduce our calls to the DB 
>> for performance and finding it a bit tough wrapping everything into one  
>> query. Currently the above query is split into two different queries.
>> 
>> Much appreciated.
>> _______________________________________________
>> Neo4j mailing list
>> User@lists.neo4j.org
>> https://lists.neo4j.org/mailman/listinfo/user
> _______________________________________________
> Neo4j mailing list
> User@lists.neo4j.org
> https://lists.neo4j.org/mailman/listinfo/user

_______________________________________________
Neo4j mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user


_______________________________________________
NOTICE: THIS MAILING LIST IS BEING SWITCHED TO GOOGLE GROUPS, please register 
and consider posting at https://groups.google.com/forum/#!forum/neo4j

Neo4j mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user

Reply via email to