Neo4j issue with enforcing indexes

前端 未结 1 1180
感情败类
感情败类 2021-01-20 12:23

I\'m running into an issue where I\'m enforcing the use of an index in a Cypher batch query,

UNWIND {rows} AS row
MATCH (s:Entity)
USING INDEX s:Entity(uuid)         


        
相关标签:
1条回答
  • 2021-01-20 12:27

    [UPDATED]

    Your second query also changed the WHERE clauses, which is why it worked.

    neo4j does not currently support using the USING INDEX clause for an index that will be used to compare property values to each other (as you do in your first query).

    Note: the latest versions of neo4j are actually able to use the index in that scenario, but if you try to specify the USING INDEX clause as a hint, neo4j will complain. This is probably a bug. I have submitted Issue 8463 for this.

    However, neo4j has no problems with the USING INDEX clause when the index is used to compare a property value to an identifier or a literal (as you do in your second query).

    Luckily, there is a simple workaround. You can just create identifiers for the property values and use those identifiers instead. For example, see how the WITH clause is used here:

    UNWIND {rows} AS row
    WITH row.source AS source, row.target AS target
    MATCH (s:Entity)
    USING INDEX s:Entity(uuid)
    WHERE s.uuid = source
    MATCH (t:Entity)
    USING INDEX t:Entity(uuid)
    WHERE t.uuid = target
    MATCH (s)-[r:CONSUMED]->(t)
    DELETE r
    
    0 讨论(0)
提交回复
热议问题