Relation is not returning while defining self-referential nodes in SDN (Spring Data Neo4J)

77 Views Asked by At

We are generating 48 hour projection data using 6 months historical network traffic data. The final projection data is loaded into Neo4J to support a front end web application where users can search a server and see its future communication/data transfers with other servers within the organization. We defined a Host node and relations 1 to 48 hrs (1H, 2H, 3H....48H). The following regular cypher query works fine and returns data with relation information.

MATCH p=(parent:HOST)-[r]->(child:HOST)
WHERE parent.HOST_NAME = " "
RETURN p, type(r)

But, the SDN (Spring Data Neo4j) setup is not returning relation info. The node entity is defined as follows.

@NodeEntity
public class Host {
  @GraphId
  private Long id;
  private String Host_Name;

  @Relationship(type="")
  private List<Host> hosts;

  public List<Host> getHosts() {
    return hosts;
  }

  public Long getId() {
    return id;
  }

  public String getName() {
    return Host_Name;
  }
}

And repository defined as

public interface HostRepository extends Neo4jRepository<Host, Long> {
   @Query("MATCH p=(parent:Host)<-[r:`28H`]-(child:Host) WHERE parent.Host_Name = \"pserver_01\" RETURN p, type(r)")
   Collection<Host> getAllHosts();
}

The hourly relation info (type(r)) is not returning from the spring data neo4j repository.

Are node and relation definitions correct? Am I missing something here?

Any help would be appreciated...

1

There are 1 best solutions below

0
On

Those empty strings you use are really odd. I don't think empty relationship-types work.

By default the direction is OUTGOING, if you want to see both you have to specify direction=BOTH in the annotation.

In your repository example you need to use a projection or @QueryResult to see the type(r) AS type column.