Prev |  | Next

## 14.1. Indexes

Cypher allows the creation of indexes over a property for all nodes that have a given label. These indexes are automatically managed and kept up to date by the database whenever the graph is changed.

### 14.1.1. Create index on a label

To create an index on a property for all nodes that have a label, use `CREATE` `INDEX` `ON`. Note that the index is not immediately available, but will be created in the background. See Section 3.7.1, “Indexes” for details.

Query.

    CREATE INDEX ON :Person(name)

Result

Indexes added: 1
`(empty result)`

### 14.1.2. Drop index on a label

To drop an index on all nodes that have a label, use the `DROP` `INDEX` clause.

Query.

    DROP INDEX ON :Person(name)

Result

Indexes removed: 1
`(empty result)`

### 14.1.3. Use index

There is usually no need to specify which indexes to use in a query, Cypher will figure that out by itself. For example the query below will use the `Person(name)` index, if it exists. If you for some reason want to hint to specific indexes, see Section 9.7, “Using”.

Query.

    MATCH (n:Person { name: 'Andres' })
    RETURN n

Result

n
0 row
`(empty result)`

Copyright © 2014 Neo Technology

Prev | Up | Next
| Home |