0

I'm new programming with Neo4j, so I don't know enough from it's cypher language yet to solve without help an annoying bug from legacy and undocumented code.

My main problem is that I can't guess the purpose of the following query... :s .

That's the problematic query:

START
  n=node({self})
MATCH
  n-[:RECOMMENDATION]->(m)
WHERE
  m.concept_type='unifying_theme' AND
  not( ()-[:REQUIRED]->m ) RETURN m

The query itself is written with only one line, I've formatted it to make more readable. The error message is the following (reformatted to be easier to read):

PatternException: Some identifiers are used as both relationships and nodes:
  UNNAMED1 Query:
    START n=node({self})
    MATCH n-[:RECOMMENDATION]->(m)
    WHERE m.concept_type='unifying_theme' AND not( ()-[:REQUIRED]->m )
    RETURN m
  Params: {'self': 423}
  Trace:
    org.neo4j.cypher.internal.pipes.matching.PatternGraph.validatePattern(PatternGraph.scala:98)
    org.neo4j.cypher.internal.pipes.matching.PatternGraph.<init>(PatternGraph.scala:36)
    org.neo4j.cypher.internal.executionplan.builders.PatternGraphBuilder$cla...

The query is embedded inside a NeoModel's python library "StructuredNode" instance. I guess the {self} refers to the node represented by the StructuredNode instance, and that the error if this query is related with the m variable...

I suppose maybe I should use more variable names to avoid conflicts, but I'm suspicious. I think there are more errors on this query because I've seen more ugly and buggy code of this disastrous programmer.

I don't know what was trying to do with the not( ()-[:REQUIRED]->m ) block, Is that a legal Cypher "subsentence" if m represents a node?

P.D.: I'm using Neo4j 1.9.7 .

Thank you in advance.

cybersam
  • 63,203
  • 6
  • 53
  • 76
castarco
  • 1,368
  • 2
  • 17
  • 33
  • the not( ()-[:REQUIRED]-m ) block is legal. The empty parens () just mean "any node", so that clause means that you're only looking for certain m's where m does *NOT* have an inbound relationship of type "REQUIRED". I'm not sure about the identifier problem though -- I would investigate {self} some more. The issue is you're not binding anything to a relationship, so the error doesn't make much sense on first blush, but I'm using the 2.0 series and some things have changed since 1.9. – FrobberOfBits May 02 '14 at 13:39
  • I have done many experiments. I've wrapped the first `n` of the MATCH block with parenthesis, i've uppercased the `not` keyword and added an space between the NOT keyword and the parenthesis... I don't know yet the results, i'll tell here soon. – castarco May 02 '14 at 13:58
  • @castarco I don't know what is causing the error, but work around might be explicitly assigning unique variable names to the relationships in the query. For example, [r1:RECOMMENDATION], and [r2:REQUIRED]. – cybersam May 02 '14 at 16:25

0 Answers0