Neo4j index not work in WHERE condition with exists

Server version 4.3.1

1. Local create index

CREATE INDEX Supply_id_index IF NOT EXISTS FOR (l:SupplyPlan) ON (;

2. execute explain

explain MATCH (shipment:`Shipment` {tenantId: '0804', type: 'Shipment'}) 
        MATCH (shipment:`Shipment`)
        -[:`Shipment_SupplyPlan_supplyPlan` {fieldName: 'supplyPlan'}]->(supplyPlan:`SupplyPlan`) 
        WHERE = '0804-01'
RETURN shipment;

We found


so it should hit the index we created

3. insert data of Shipment & Supply including node and edge

CREATE (shipment:Shipment {type: 'Shipment', tenantId: "0804", id:"0804-shipment-1"});
CREATE (supplyPlan:SupplyPlan {type: 'SupplyPlan', tenantId: "0804", id:"0804-01"});
MATCH (shipment:Shipment),(supplyPlan:SupplyPlan) 
WHERE = "0804-shipment-1" AND = "0804-01" 
CREATE (shipment)-[r:`Shipment_SupplyPlan_supplyPlan` {fieldName: 'supplyPlan'}]->(supplyPlan) 
RETURN type(r), r.fieldName;

4. re-execute the explain of query again
We found it shows the


It did not hit the index

5. not use exists in where condition and try a simple query
I think using exists in where condition may be a little different, so i try a simple query with match relation pattern:

explain MATCH (shipment:`Shipment` {tenantId: '0804', type: 'Shipment'})-[:`Shipment_SupplyPlan_supplyPlan` {fieldName: 'supplyPlan'}]->(supplyPlan:`SupplyPlan`) 
WHERE = '0804-01'
RETURN shipment; 

We found it showed the



Conclusion & Question:
After inserting data, why the query with exists in where condition, can not hit the index?
Thanks so much~

Hi @1033516561 !

Do you have a script to create a dump db of your use case?

It may help me in order to quickly test this.



I tried your queries in the same order, I always get the NodeIndexSeek execution.


Hi, @Bennu
Which server version did you try in the above test?
I tried again in totally new 4.3.3 neo4j, with the default config and followed the steps above. It always can not hit the index in the second EXPLAIN(the first explain can hit, but after inserting the data, EXPLAIN can not hit the index)