Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Neo4j: Create index for nodes with same property

Tags:

neo4j

cypher

I have a graph with many different elements but every element has a property "ID". Now i would like to

CREATE INDEX ON :anyType(ID)

How can i trigger the index creation for any type?

like image 721
Joe Avatar asked Apr 11 '16 21:04

Joe


People also ask

What makes creating a full text schema index different from creating a property index?

What makes creating a full-text schema index different from creating a property index? Full-text schema indexes can use relationship properties. Full-text schema indexes can check for uniqueness. Full-text schema indexes can use multiple types of nodes for the index.

Why would you create an index using Neo4j?

Neo4j SQL supports Indexes on node or relationship properties to improve the performance of the application. We can create indexes on properties for all nodes, which have the same label name. We can use these indexed columns on MATCH or WHERE or IN operator to improve the execution of CQL command.

What do indexes do in Neo4j?

Indexes are commonly used for MATCH and OPTIONAL MATCH clauses that combine a label predicate with a property predicate.

How do you create a relationship between existing nodes in Neo4j?

To create a relationship between two nodes, we first get the two nodes. Once the nodes are loaded, we simply create a relationship between them. The created relationship is returned by the query.


1 Answers

CREATE INDEX ON takes a label, and cannot be called without the label (nor can it be called with multiple labels). So you'd have to execute this for each label type.

That is, you can't run:

CREATE INDEX(ID)

or

CREATE INDEX ON:*(ID)

You need to run:

CREATE INDEX ON:label(ID)
like image 193
David Makogon Avatar answered Sep 21 '22 02:09

David Makogon