CREATE INDEX FOR (p:Person) ON (p.name)
Create an index on nodes with label Person and property name.
CREATE INDEX index_name FOR ()-[k:KNOWS]-() ON (k.since)
Create an index on relationships with type KNOWS and property since with the name index_name.
CREATE INDEX FOR (p:Person) ON (p.surname)
OPTIONS {indexProvider: 'native-btree-1.0', indexConfig: {`spatial.cartesian.min`: [-100.0, -100.0], `spatial.cartesian.max`: [100.0, 100.0]}}
Create an index on nodes with label Person and property surname with the index provider native-btree-1.0 and given spatial.cartesian settings. The other index settings will have their default values.
CREATE INDEX FOR (p:Person) ON (p.name, p.age)
Create a composite index on nodes with label Person and the properties name and age, throws an error if the index already exist.
CREATE INDEX IF NOT EXISTS FOR (p:Person) ON (p.name, p.age)
Create a composite index on nodes with label Person and the properties name and age if it does not already exist, does nothing if it did exist.
CREATE LOOKUP INDEX lookup_index_name FOR (n) ON EACH labels(n)
Create a token lookup index with the name lookup_index_name on nodes with any label .
CREATE LOOKUP INDEX FOR ()-[r]-() ON EACH type(r)
Create a token lookup index on relationships with any relationship type.
CREATE FULLTEXT INDEX node_fulltext_index_name FOR (n:Friend) ON EACH [n.name]
OPTIONS {indexConfig: {`fulltext.analyzer`: 'swedish'}}
Create a fulltext index on nodes with the name node_fulltext_index_name and analyzer swedish. Fulltext indexes on nodes can only be used by from the procedure db.index.fulltext.queryNodes. The other index settings will have their default values.
CREATE FULLTEXT INDEX rel_fulltext_index_name FOR ()-[r:HAS\_PET|BROUGHT\_PET]-() ON EACH [r.since, r.price]
Create a fulltext index on relationships with the name rel_fulltext_index_name. Fulltext indexes on relationships can only be used by from the procedure db.index.fulltext.queryRelationships.
SHOW INDEXES
List all indexes.
MATCH (n:Person) WHERE n.name = $value
An index can be automatically used for the equality comparison. Note that for example toLower(n.name) = $value will not use an index.
MATCH (n:Person)
WHERE n.name IN [$value]
An index can automatically be used for the IN list checks.
MATCH (n:Person)
WHERE n.name = $value and n.age = $value2
A composite index can be automatically used for equality comparison of both properties. Note that there needs to be predicates on all properties of the composite index for it to be used.
MATCH (n:Person)
USING INDEX n:Person(name)
WHERE n.name = $value
Index usage can be enforced when Cypher uses a suboptimal index, or more than one index should be used.
DROP INDEX index_name
Drop the index named index_name, throws an error if the index does not exist.
DROP INDEX index_name IF EXISTS
Drop the index named index_name if it exists, does nothing if it does not exist.