Skip to main content

Raw Neo4j indices

Raw Neo4j indices create an index of Neo4j with a type and options of your choice, either for a single property or for several properties of a schema. Like every index, they are created by a migration.

Indices of a property

A top-level property can carry a neo4j object with the type of the index and optional options:

{
"mode": "partial",
"properties": {
"title": {
"type": "string",
"neo4j": {
"type": "text"
}
},
"location": {
"type": "point",
"storage": "graph",
"neo4j": {
"type": "point"
}
}
}
}

The index is named ens_<type>_<property>_raw_<hash>, see index names and changes. It exists in addition to the indices of the intents of the property.

Indices of a schema

indices.neo4j is a list of indices which can span several properties, e.g. a composite range index for queries which filter by two properties at once:

{
"mode": "partial",
"properties": {
"country": {
"type": "string"
},
"population": {
"type": "integer"
},
"description": {
"type": "string"
}
},
"indices": {
"neo4j": [
{
"name": "byCountryAndPopulation",
"type": "range",
"properties": [
"country",
"population"
]
},
{
"name": "words",
"type": "fulltext",
"properties": [
"description"
],
"options": {
"indexConfig": {
"fulltext.analyzer": "english"
}
}
}
]
}
}

Every index has a name (a letter, followed by up to 63 letters, digits and underscores, unique within the schema), which becomes part of the name of the index in Neo4j, ens_<type>_<name>_composite_<hash>. The order of properties matters for composite range indices, Neo4j uses them for queries which filter by a prefix of the list.

Types

TypePropertiesProperty types
rangeone or moreboolean, integer, number, string, datetime, elementId, point
textexactly onestring
pointexactly onepoint
fulltextone or morestring

The properties have to be defined by the schema at the top level and stored in Neo4j: properties with "storage": "document", objects, lists and geometries other than points can not be indexed by Neo4j.

Options

options is passed to Neo4j as the OPTIONS of the index, with two keys:

  • indexProvider: the name of an index provider, e.g. text-2.0.
  • indexConfig: a map of settings to values, e.g. fulltext.analyzer, fulltext.eventually_consistent or spatial.wgs-84.min. Values are strings, numbers, booleans or lists of them.

The available settings depend on the version of Neo4j, see the Neo4j index documentation. Neo4j validates them when the migration runs; a setting which it does not know fails the step.

Changes

A migration compares the existing indices with the schema by name, type and properties. An index whose type or properties changed is dropped and created again. Neo4j does not report all options of an index back, so the hash in the name covers them, e.g. ens_place_words_composite_3f9a1c2e: changed options give the index another name, and the migration drops the old index and creates the new one. The order of the keys in options does not matter. Indices which are removed from the schema are dropped by the next migration.