I'm using neo4j 2.1.4. I have nodes - POINT and relationships - ROAD I have index on ROAD property - OBJ_COD
:schema ls -l :ROAD
Indexes
ON :ROAD(OBJ_COD) ONLINE
ON :ROAD(ID) ONLINE
No constraints
I want to search ROAD by OBJ_COD value, but cypher don'use index to lookup relationship.
neo4j-sh (?)$ profile MATCH (a)-[r:`ROAD` {ID:333275}]-(b:`POINT`) RETURN r LIMIT 1;
ColumnFilter
|
+TraversalMatcher
+------------------+------+---------+-------------+----------------+
| Operator | Rows | DbHits | Identifiers | Other |
+------------------+------+---------+-------------+----------------+
| ColumnFilter | 2 | 0 | | keep columns r |
| TraversalMatcher | 2 | 2265843 | | a, r, a |
+------------------+------+---------+-------------+----------------+
How can I force cypher to use existing index to search single relationship?
Schema index are only available on nodes. The need for having indexes on relationships almost always unveils an issue in your graph data modelling. Typically you use indexes to look up start points for graph traversals. Good modelling practice is that anything in your domain being a thing
or entity
should be a node and the relationship put your things
into a semantic context. If you follow this and your queries start at something
there will be no need for indexing relationships.
However there are some rare case where relationship indexing might be a valid choice. In this case you need to fall back to use legacy indexes for relationships. Review the fine documentation for this to understand how they work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With