Display of dynamically created node property

13 views
Skip to first unread message

Samwillie

unread,
May 22, 2012, 8:34:10 AM5/22/12
to Neo4j
Hello all,

I use neo4j 1.8.M02 in my java web application. I have the following
issue, and would appreciate any help...

An example that reflects my issue is described below for better
understanding.

Movie - ACTS_IN - Actor

where Movie is a node, ACTS_IN is a relationship type and Actor is a
node.

Apart from this, the ACTS_IN relationship type has a role property,
say ROLE.

Lets say I have 10 Movie nodes and each "Movie" node has a
relationship to 5 actor nodes, each having a "Role" relationship
property.

start n = node({nodeId}) match (n)<-[r:ACTS_IN]-(x) return x, r.role

would give me all actor nodes and the specific role that the actor
plays in the movie.

Now from the obtained Cypher Query Result, I want to add the obtained
role value for each actor as a property in the Actor node and then
return the Actor node (just for display purposes, which means this
action must not actually add a new property in the database). Is this
possible?

The display is XML and I serialize the node to XML later so I need an
element that also has the role property within the actor node.

Thanks,





Samwillie

unread,
May 22, 2012, 10:00:46 AM5/22/12
to Neo4j
Hi,

Answering my own question - I do not know if this is the most
efficient way, but in the cypher query, we could get each property
instead of a node and map the result to an object, This way we could
get the serialized object as output.

Thanks,

Peter Neubauer

unread,
May 22, 2012, 10:26:22 AM5/22/12
to ne...@googlegroups.com

Thanks for letting us know. What does the query look like?

Send from mobile.

Samwillie

unread,
May 22, 2012, 10:38:10 AM5/22/12
to Neo4j
Hi Peter,

I used this query to get the required properties of a node and then
mapped it to a pojo which can then be serialized...

start n = node({nodeId}) match (n)<-[r:ACTS_IN]-(x) return x.name as
name, r.role as character, x.year as year

Thanks,

On 22 Mai, 16:26, Peter Neubauer <neubauer.pe...@gmail.com> wrote:
> Thanks for letting us know. What does the query look like?
>
> Send from mobile.

Peter Neubauer

unread,
May 22, 2012, 12:41:12 PM5/22/12
to ne...@googlegroups.com

Ahh,
Cool thanks! I actually would like something that returns all properties of a node or relationship also...

Send from mobile.

Reply all
Reply to author
Forward
0 new messages