3
votes

I am very new to neo4j. I am running the shell under Windows. I have created a node called: user and I have got index on id. User has got id and name properties.

I have created a relationship called friends. (user1, user2)

neo4j.properties is set to:

# Enable auto-indexing for nodes, default is false
node_auto_indexing=true

# The node property keys to be auto-indexed, if enabled
node_keys_indexable=id

# Enable auto-indexing for relationships, default is false
relationship_auto_indexing=true

# The relationship property keys to be auto-indexed, if enabled
relationship_keys_indexable=user1,user2

My questions are:

1- When i type: :schema ls, it shows:

Indexes
  ON :User(id) ONLINE  

No constraints

Why does it not show the index on the relationship?

2- How can i manually create an index on the relationship using shell?

1

1 Answers

2
votes

When you type :schema, the indexes that you see are the new-style indexes in Neo4j. It seems as though the node_auto_indexing and relationship_auto_indexing (along with the *_keys_indexable) configuration properties are part of Neo4j's legacy indexing:

http://neo4j.com/docs/milestone/auto-indexing.html

I'm not too familiar with legacy indexes, but in the new-style indexes there is no indexing on relationships. In that paradigm you find nodes first via their indexes and follow relationships from there, but there is no direct querying of relationships without first finding nodes.

You can read up about legacy indexes here:

http://neo4j.com/docs/milestone/indexing.html

But I'll copy/paste a useful passage:

"As of Neo4j 2.0, this is not the favored method of indexing data in Neo4j, instead we recommend defining indexes in the database schema."

"However, support for legacy indexes remains, because certain features, such as uniqueness constraints, are not yet handled by the new indexes."

I don't think that this is completely true, anymore, though, because Neo4j has supported unique constraints in the DB schema for a while:

http://neo4j.com/docs/stable/query-constraints.html