Updated on 2024-01-04 GMT+08:00

Cypher Prerequisites

The current Cypher query compilation process uses the label-based vertex and edge indexes. To use Cypher normally, use the index creation API to create indexes.

  • Example command for adding a vertex label index. The index name is cypher_vertex_index, and the index type is global vertex index.
    POST http://{SERVER_URL}/ges/v1.0/{project_id}/graphs/{graph_name}/indices
    {
            "indexName": "cypher_vertex_index",
            "indexType": "GlobalCompositeVertexIndex",
            "hasLabel": "true",
            "indexProperty": []
    }
  • Example command for adding an edge label index. The index name is cypher_edge_index, and the index type is global edge index.
    POST http://{SERVER_URL}/ges/v1.0/{project_id}/graphs/{graph_name}/indices
    {
            "indexName": "cypher_edge_index",
            "indexType": "GlobalCompositeEdgeIndex",
            "hasLabel": "true",
            "indexProperty": []
    }
  1. You do not need to create the indexes if the graph is of the 100-million-edge, 1-billion-edge, or 10-billion-edge types. (The GES version must be 2.3.6 or later.)
  2. If you need to create indexes, you must create both two indexes (vertex label index and edge label index) at the same time to use Cypher for query.
  3. If your graph already has a vertex index or an edge index whose hasLabel is true and indexProperty is empty, you do not need to create the vertex index or edge index again.
  4. The API for creating an index is asynchronous. To check whether the index is successfully created, use the API for querying job status.
  5. If fine-grained permissions are used, a member account must have the schema permission and the read permission on all labels (including the default label __DEFAULT__) to create indexes. Otherwise, after an index is created, you need to use an account with the required permissions to send call db.schema() to update the compiler cache of Cypher queries.