Skip to main content

Kuzu

Exports data to a Kuzu graph database.

Get Started

Read Property Graph Targets for more information to get started on how it works in CocoIndex.

Spec

CocoIndex supports talking to Kuzu through its API server.

The Kuzu target spec takes the following fields:

  • connection (auth reference to KuzuConnectionSpec): The connection to the Kuzu database. KuzuConnectionSpec has the following fields:
    • api_server_url (str): The URL of the Kuzu API server, e.g. http://localhost:8123.
  • mapping (Nodes | Relationships): The mapping from collected row to nodes or relationships of the graph. For either nodes to export or relationships to export.

Kuzu also provides a declaration spec KuzuDeclaration, to configure indexing options for nodes only referenced by relationships. It has the following fields:

  • connection (auth reference to KuzuConnectionSpec)
  • Fields for nodes to declare, including
    • nodes_label (required)
    • primary_key_fields (required)

Kuzu dev instance

If you don't have a Kuzu instance yet, you can bring up a Kuzu API server locally by running:

KUZU_DB_DIR=$HOME/.kuzudb
KUZU_PORT=8123
docker run -d --name kuzu -p ${KUZU_PORT}:8000 -v ${KUZU_DB_DIR}:/database kuzudb/api-server:latest

To explore the graph you built with Kuzu, you can use the Kuzu Explorer. Currently Kuzu API server and the explorer cannot be up at the same time. So you need to stop the API server before running the explorer.

To start the instance of the explorer, run:

KUZU_EXPLORER_PORT=8124
docker run -d --name kuzu-explorer -p ${KUZU_EXPLORER_PORT}:8000 -v ${KUZU_DB_DIR}:/database -e MODE=READ_ONLY kuzudb/explorer:latest

You can then access the explorer at http://localhost:8124.

Example

Docs to Knowledge Graph