All versions of this manual
X
 

Configuring data-sources: Google Spanner

google cloud spanner logo

ℹ️ This feature is currently in beta. If you would like to enable it, please get in touch.

If you have data in Google Cloud Spanner, you can explore this data as a graph using Linkurious Enterprise.

To achieve this, you must first define a property graph schema in Spanner, which defines a projection of the data in your tables as a graph.

Prerequisites

This section defines the technical requirements to use Spanner with Linkurious Enterprise.

Graph Schema

Make sure that your graph schema defines at least one KEY property for each node and edge in the graph schema.

For edges, we recommend using:

  • for one-to-many edge types: the key property of the target table row (e.g. for Person (1) -OWNS_BIKE-> (*) Bike, a good key for the OWNS_BIKE edge is the key property of the Bike node-table);
  • for many-to-many edge types, when multiples edges of that type is possible between two nodes: the key property of the join-table itself (e.g. for Account (*) <-TRANSACTION-> (*) Account a good key for the TRANSACTION edge is the key of the TRANSACTION edge-table);
  • for many-to-many edge types, when only one edge of that type is possible between two nodes: a combination of the key property of the source and target table rows (e.g. for Person (*) <-KNOWS-> (*) Person, a good key for the KNOWS edge is (sourcePersonId, targetPersonId))

Full-text search

To use this feature, you must have at least one node property in your graph that is tokenized, and at least one index that contains that tokenized property.

Example of how to create a tokenized property:

CREATE TABLE Album (
  id STRING(MAX) NOT NULL,
  title STRING(MAX),
  title_tokens TOKENLIST AS (TOKENIZE_FULLTEXT(title)) HIDDEN
) PRIMARY KEY(id);

Example of how to add a tokenized property to an index:

CREATE SEARCH INDEX AlbumIndex
ON Album(title_tokens);

Configuration

To edit the Spanner data-source configuration, you can either use the Web user-interface or edit the configuration file located at linkurious/data/config/production.json.

Example configuration:

{
  "dataSources": [
    {
      "graphdb": {
        "databaseName": "spanner-dev-db",
        "graphName": "spanner_dev_graph",
        "vendor": "spanner",
        "url": "https://cloud.google.com",
        "projectId": "dev-test-spanner",
        "instanceId": "spanner-test-instance",
        "keyFileContent": "<secret>"
      },
      "index": {
        "vendor": "spannerSearch"
      }
    }
  ]
}

Supported graphdb options with Spanner:

  • vendor (required): must be spanner;
  • projectId (required): Your Google Cloud project ID;
  • instanceId (required): Your Google Spanner instance ID;
  • databaseName (required): Your Google Spanner database name;
  • graphName (required): Your property graph's name;
  • keyFile (required if keyFileContent is not set): If you are running Linkurious Enterprise on GCP, you must set up application credentials and set this field to $ENV:GOOGLE_APPLICATION_CREDENTIALS (this will read the value of this environment variable);
  • keyFileContent (required if keyFile is not set): If you are not running Linkurious Enterprise on GCP, you must create a service account key file and copy the full content of the file in this field;
  • url (required): must be https://cloud.google.com.

You will also need to add the following index configuration, it is required:

{ "vendor": "spannerSearch" }

Importing data

See Google Spanner's documentation about importing data.