lulu88
lulu88

Reputation: 1714

neo4j Cypher query with graphId match returns nothing

I am using the Play! Framework 2.3 app with neo4j plugin for play - found: here

I have this model class (code snippet):

  @NodeEntity
  @TypeAlias("_Request")
  public class Request {

    @GraphId
    @Indexed
    public Long id;

    @Indexed
    public String requestType;

    @Indexed
    public String requestStatus;
  }

When I do this cypher query:

  MATCH (n:_Request) RETURN n;

It return the Request node and the node id (The assigned graphId value = 138)

Now I run this:

  MATCH (n:_Request) WHERE n.id = 138 RETURN n;

It returns nothing. Why is this? Can I not make a query on the graphId annotation? Help please

Upvotes: 1

Views: 468

Answers (1)

stephenmuss
stephenmuss

Reputation: 2445

The problem here is that id in n is being interpreted as a property of n and not of the underlying graph id.

In order to match the node you are looking for you will need to modify your query a little to let Neo4j you are attempting to get the node through its underlying graph id rather than a property named id.

START n=node(138) RETURN n

With that small change you should get the result you are expecting.

Upvotes: 4

Related Questions