1

Here is my Cypher:

    MATCH (i1:Identity)-[ie1:IS_LINKED_TO]->(e1:Event)-[ee1:HAS_FLIGHT]->(f:Flight)<-[ee2:HAS_FLIGHT]-
(e2:Event)<-[ie2:IS_LINKED_TO]-(i2:Identity) 
    WHERE i1.identityId >= i2.identityId
    WITH i1, i2, collect({ e1:e1, e2:e2, ee1:ee1,f:f,ee2:ee2}) AS x
    WHERE size (x) > 2
    WITH i1, i2, x
    RETURN i1,i2,x

I'm using the session.query(...) API and I'm getting i1 and i2 as first class domain objects (Identity). What's the best way to extract x? It's being presented as a Map with the aliases.

Finally I want the entire Identity object with everything filled in. I see that the values of node aliases (eg: e1) in the map is of type InternalNode. What's the best way to convert these nodes to actual domain objects?

EDIT

I've tried using the @QueryResult feature and here is how my result object looks like.

@QueryResult
public class FlightRelationshipAnalysis {
    private Identity i1;
    private Identity i2;
    private List<Map<String, Object>> x;
}

The value of the map is an InternalNode (for nodes). Not sure is this is the right way to model a @QueryResult.

user1189332
  • 1,773
  • 4
  • 26
  • 46
  • I have a similar [problem](https://stackoverflow.com/questions/59481997). I wonder why it is not mapped by OGM. You could try to return edges and nodes directly without a list. Maybe that helps. – Steffen Harbich Dec 26 '19 at 08:20
  • Also, in my understanding, the `size(x) > 2` should always be fulfilled? The match clause implies that whole path is existing when first `WITH` is evaluated. Only an `OPTIONAL MATCH` would allow null values as far as I know. – Steffen Harbich Dec 26 '19 at 08:34

0 Answers0