How to use relationship index in Cypher

I am using neo4j 2.1.4. I have nodes - POINT and relationships - ROAD I have an index for the ROAD property - OBJ_COD

:schema ls -l :ROAD Indexes ON :ROAD(OBJ_COD) ONLINE ON :ROAD(ID) ONLINE No constraints 

I want to find 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 to get cypher to use an existing index to search for single relationships?

+5
source share
1 answer

The schema index is available only on nodes. The need for relationship indexes almost always reveals a problem in your graphical data modeling. Usually you use indexes to find starting points for traversing the chart. Good modeling practice is that everything that is in your thing or entity domain must be a node, and the relationship puts your things in a semantic context. If you do this and your queries start with something , there will be no need to index the relationship.

However, there are some rare cases where indexing relationships can be the right choice. In this case, you need to fall back to use legacy indexes for relationships. Check out the excellent documentation to understand how they work.

+4
source

Source: https://habr.com/ru/post/1202689/


All Articles