Announcement Announcement Module
Collapse
No announcement yet.
Cypher Query with Regex and Parentheses Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Cypher Query with Regex and Parentheses

    Hello Graphistas,

    I'm experimenting with cypher queries and I'm very enthusiastic about the features - especially regular expressions come in very handy for our use case! I'm trying to write some queries that select some nodes depending on the values of their connected nodes. The data model looks like:

    Code:
    SomeEntityNode ---> PropertyValueNode ---> PropertyDefinitionNode

    Executing the following query works:
    Code:
     start subRefNode=node(7)
                 MATCH (subRefNode)-[:DEVICE]->(entityNode)-[:HAS_PROPERTY_VALUE]->(propValueNode)-[:IS_OF_TYPE]->(propDefNode)
                 WHERE (propDefNode.name='entity.name' and propValueNode.value=~/[AX].*/) or
                       (propDefNode.name = 'device.address' and propValueNode.value='123') return entityNode.uuid
    
    +--------------------------------------+
    | entityNode.uuid                      |
    +--------------------------------------+
    | 2e3c5dc9-1b58-4bbf-920d-b306519c7fa5 |
    | 576f954d-3b4e-4220-9fbe-3383d022025e |
    | 95be04d3-b13d-4dff-b22b-1e8cf8adb31d |
    | 71dbc28e-247e-4cac-8d9f-978e05b0e282 |
    +--------------------------------------+
    4 rows, 14 ms
    But using a regex in the second boolean expression yields an error:
    Code:
     start subRefNode=node(7)
                 MATCH (subRefNode)-[:DEVICE]->(entityNode)-[:HAS_PROPERTY_VALUE]->(propValueNode)-[:IS_OF_TYPE]->(propDefNode)
                 WHERE (propDefNode.name='entity.name' and propValueNode.value=~/[AX].*/) or
                       (propDefNode.name = 'device.address' and propValueNode.value=~/.*/) return entityNode.uuid
    
    Unmatched closing ')' near index 6
    [AX].*/) or (propDefNode.name = 'device.address' and propValueNode.value=~/.*
          ^
    Any ideas on what's going wrong?

    Regards,
    Andi Büchler

  • #2
    Andi,

    what version of SDN / Neo4j are you running? I just tried your query with 1.6. and it didn't report any issue

    Comment


    • #3
      Hello Michael,

      thanks for trying to reproduce! We're using 1.5.0.

      Regards,
      Andi

      Comment


      • #4
        ... together with SDN 2.0.1.

        Regards,
        Andi

        Comment


        • #5
          Oh, then you ran into a cypher issue that was fixed in Neo4j 1.6

          Sorry for that, would it be possible for you to upgrade to 1.6.1 ?

          Michael

          Comment

          Working...
          X