6.7. Indexes

6.7.1. Create node index
6.7.2. Create node index with configuration
6.7.3. Delete node index
6.7.4. List node indexes
6.7.5. List node indexes (empty result)
6.7.6. Add node to index
6.7.7. Find node by exact match

An index can contain either nodes or relationships.

[Note]Note

To create an index with default configuration, simply start using it by adding nodes/relationships to it. It will then be automatically created for you.

What default configuration means depends on how you have configured your database. If you haven’t changed any indexing configuration, it means the indexes will be using a Lucene-based backend.

If you want to customize the index settings, see Section 6.7.2, “Create node index with configuration”.

6.7.1. Create node index

[Note]Note

Instead of creating the index this way, you can simply start to use it, and it will be created automatically.

Example request

  • POST http://localhost:7474/db/data/index/node/
  • Accept: application/json
  • Content-Type: application/json
{
  "name" : "favorites"
}

Example response

  • 201: Created
  • Content-Type: application/json
  • Location: http://localhost:7474/db/data/index/node/favorites/
{
  "template" : "http://localhost:7474/db/data/index/node/favorites/{key}/{value}"
}

6.7.2. Create node index with configuration

This request is only necessary if you want to customize the index settings. If you are happy with the defaults, you can just start indexing nodes/relationships, as non-existent indexes will automatically be created as you do. See Section 7.10, “Configuration and fulltext indexes” for more information on index configuration.

Example request

  • POST http://localhost:7474/db/data/index/node/
  • Accept: application/json
  • Content-Type: application/json
{"name":"fulltext", "config":{"type":"fulltext","provider":"lucene"}}

Example response

  • 201: Created
  • Content-Type: application/json
  • Location: http://localhost:7474/db/data/index/node/fulltext/
{
  "template" : "http://localhost:7474/db/data/index/node/fulltext/{key}/{value}",
  "provider" : "lucene",
  "type" : "fulltext"
}

6.7.3. Delete node index

Example request

  • DELETE http://localhost:7474/db/data/index/node/kvnode
  • Accept: application/json

Example response

  • 204: No Content

6.7.4. List node indexes

GET ${org.neo4j.server.rest.web}/index/node/

@throws PropertyValueException

Example request

  • GET http://localhost:7474/db/data/index/node/
  • Accept: application/json

Example response

  • 200: OK
  • Content-Type: application/json
{
  "favorites" : {
    "template" : "http://localhost:7474/db/data/index/node/favorites/{key}/{value}",
    "provider" : "lucene",
    "type" : "exact"
  }
}

6.7.5. List node indexes (empty result)

This is an example covering the case where no node index exists.

Example request

  • GET http://localhost:7474/db/data/index/node/
  • Accept: application/json

Example response

  • 204: No Content

6.7.6. Add node to index

Associates a node with the given key/value pair in the given index.

[Note]Note

Spaces in the URI have to be escaped.

[Caution]Caution

This does not overwrite previous entries. If you index the same key/value/item combination twice, two index entries are created. To do update-type operations, you need to delete the old entry before adding a new one.

Example request

  • POST http://localhost:7474/db/data/index/node/favorites/key/the%20value
  • Accept: application/json
  • Content-Type: application/json
"http://localhost:7474/db/data/node/0"

Example response

  • 201: Created
  • Content-Type: application/json
  • Location: http://localhost:7474/db/data/index/node/favorites/key/the%20value/0
{
  "indexed" : "http://localhost:7474/db/data/index/node/favorites/key/the%20value/0",
  "outgoing_relationships" : "http://localhost:7474/db/data/node/0/relationships/out",
  "data" : {
  },
  "traverse" : "http://localhost:7474/db/data/node/0/traverse/{returnType}",
  "all_typed_relationships" : "http://localhost:7474/db/data/node/0/relationships/all/{-list|&|types}",
  "property" : "http://localhost:7474/db/data/node/0/properties/{key}",
  "self" : "http://localhost:7474/db/data/node/0",
  "outgoing_typed_relationships" : "http://localhost:7474/db/data/node/0/relationships/out/{-list|&|types}",
  "properties" : "http://localhost:7474/db/data/node/0/properties",
  "incoming_relationships" : "http://localhost:7474/db/data/node/0/relationships/in",
  "extensions" : {
    "FunctionalTestPlugin" : {
      "connected_nodes" : "http://localhost:7474/db/data/ext/FunctionalTestPlugin/node/0/connected_nodes",
      "pathToReference" : "http://localhost:7474/db/data/ext/FunctionalTestPlugin/node/0/pathToReference",
      "getThisNodeOrById" : "http://localhost:7474/db/data/ext/FunctionalTestPlugin/node/0/getThisNodeOrById",
      "createRelationships" : "http://localhost:7474/db/data/ext/FunctionalTestPlugin/node/0/createRelationships",
      "getRelationshipsBetween" : "http://localhost:7474/db/data/ext/FunctionalTestPlugin/node/0/getRelationshipsBetween"
    },
    "GraphCloner" : {
      "clonedSubgraph" : "http://localhost:7474/db/data/ext/GraphCloner/node/0/clonedSubgraph"
    }
  },
  "create_relationship" : "http://localhost:7474/db/data/node/0/relationships",
  "paged_traverse" : "http://localhost:7474/db/data/node/0/paged/traverse/{returnType}{?pageSize,leaseTime}",
  "all_relationships" : "http://localhost:7474/db/data/node/0/relationships/all",
  "incoming_typed_relationships" : "http://localhost:7474/db/data/node/0/relationships/in/{-list|&|types}"
}

6.7.7. Find node by exact match

[Note]Note

Spaces in the URI have to be escaped.

Example request

  • GET http://localhost:7474/db/data/index/node/favorites/key/the%20value
  • Accept: application/json

Example response

  • 200: OK
  • Content-Type: application/json
[ {
  "indexed" : "http://localhost:7474/db/data/index/node/favorites/key/the%20value/0",
  "outgoing_relationships" : "http://localhost:7474/db/data/node/0/relationships/out",
  "data" : {
  },
  "traverse" : "http://localhost:7474/db/data/node/0/traverse/{returnType}",
  "all_typed_relationships" : "http://localhost:7474/db/data/node/0/relationships/all/{-list|&|types}",
  "property" : "http://localhost:7474/db/data/node/0/properties/{key}",
  "self" : "http://localhost:7474/db/data/node/0",
  "outgoing_typed_relationships" : "http://localhost:7474/db/data/node/0/relationships/out/{-list|&|types}",
  "properties" : "http://localhost:7474/db/data/node/0/properties",
  "incoming_relationships" : "http://localhost:7474/db/data/node/0/relationships/in",
  "extensions" : {
    "FunctionalTestPlugin" : {
      "connected_nodes" : "http://localhost:7474/db/data/ext/FunctionalTestPlugin/node/0/connected_nodes",
      "pathToReference" : "http://localhost:7474/db/data/ext/FunctionalTestPlugin/node/0/pathToReference",
      "getThisNodeOrById" : "http://localhost:7474/db/data/ext/FunctionalTestPlugin/node/0/getThisNodeOrById",
      "createRelationships" : "http://localhost:7474/db/data/ext/FunctionalTestPlugin/node/0/createRelationships",
      "getRelationshipsBetween" : "http://localhost:7474/db/data/ext/FunctionalTestPlugin/node/0/getRelationshipsBetween"
    },
    "GraphCloner" : {
      "clonedSubgraph" : "http://localhost:7474/db/data/ext/GraphCloner/node/0/clonedSubgraph"
    }
  },
  "create_relationship" : "http://localhost:7474/db/data/node/0/relationships",
  "paged_traverse" : "http://localhost:7474/db/data/node/0/paged/traverse/{returnType}{?pageSize,leaseTime}",
  "all_relationships" : "http://localhost:7474/db/data/node/0/relationships/all",
  "incoming_typed_relationships" : "http://localhost:7474/db/data/node/0/relationships/in/{-list|&|types}"
} ]