0
votes

I am new to Neo4j Cypher query. So basically i have written a query to fetch the relation count of a sourceType to a Destination type for one of my requirement. Query looks something like below.

    "MATCH (x:%s) <-[r]- (m:%s) "
    + "WHERE ((NOT (x)<-[:PREDECESSOR]-()) "
    + "AND (NOT (x)-[:PREDECESSOR {action:'DEL'}]->())) "
    + "AND (NOT (m)-[:PREDECESSOR {action:'DEL'}]->())) "
    + "RETURN COUNT(m) AS c";

where the first %s is sourceType and the second one is the destination where i am finding the reference. But i am getting some weird syntax issue with the below stacktrace.

ajp-nio-8009-exec-9: ERROR ExceptionHandlerAspect:57 - Un-managed Exception:JobExecution com.cisco.ngfw.onbox.backend.services.DefaultJobExecutionService.create(Class,JobExecution,ServiceParam) NGUI: 05-14 01:43:40 org.neo4j.ogm.exception.CypherException: Error executing Cypher; Code: Neo.ClientError.Statement.SyntaxError; Description: Invalid input ')': expected whitespace, '.', node labels, '[', "=~", IN, STARTS, ENDS, CONTAINS, IS, '^', '*', '/', '%', '+', '-', '=', "<>", "!=", '<', '>', "<=", ">=", AND, XOR, OR, LOAD CSV, START, MATCH, UNWIND, MERGE, CREATE, SET, DELETE, REMOVE, FOREACH, WITH, CALL, RETURN, UNION, ';' or end of input (line 1, column 210 (offset: 209)) NGUI: 05-14 01:43:40 "MATCH (x:Entity:TimeRangeObject:IdEntity:ConfigEntity) <-[r]- (m:AccessRule) WHERE ((NOT (x)<-[:PREDECESSOR]-()) AND (NOT (x)-[:PREDECESSOR {action:'DEL'}]->())) AND (NOT (m)-[:PREDECESSOR {action:'DEL'}]->())) RETURN COUNT(m) AS c"

Could anyone please help me to find the syntax issue in the above query.

1

1 Answers

1
votes

I think, you are using too many brackets; just remove them:

"MATCH (x:%s) <-[r]- (m:%s) "
    + "WHERE NOT (x)<-[:PREDECESSOR]-() "
    + "AND NOT (x)-[:PREDECESSOR {action:'DEL'}]->() "
    + "AND NOT (m)-[:PREDECESSOR {action:'DEL'}]->() "
    + "RETURN COUNT(m) AS c";