Docker Janusgraph Custom ID Values
I'm trying to setup a janusgraph database with custom verex ID values. I have the following docker-compose configuration:
Then, after setting up a Python environment with gremlin-python version 3.5.7, I execute the following:
And I get the following error message:
version: '3.8'
services:
btc_janusgraph:
# build: ./janusgraph
image: janusgraph/janusgraph:latest
container_name: btc_janusgraph
environment:
janusgraph.set-vertex-id: true
ports:
- "${JANUSGRAPH_PORT:-8182}:${JANUSGRAPH_PORT:-8182}"
networks:
- btc-network
volumes:
- btc_janusgraph_data:/var/lib/janusgraph
- "./janusgraph/janusgraph.properties:/etc/opt/janusgraph/janusgraph.properties:ro"version: '3.8'
services:
btc_janusgraph:
# build: ./janusgraph
image: janusgraph/janusgraph:latest
container_name: btc_janusgraph
environment:
janusgraph.set-vertex-id: true
ports:
- "${JANUSGRAPH_PORT:-8182}:${JANUSGRAPH_PORT:-8182}"
networks:
- btc-network
volumes:
- btc_janusgraph_data:/var/lib/janusgraph
- "./janusgraph/janusgraph.properties:/etc/opt/janusgraph/janusgraph.properties:ro"Then, after setting up a Python environment with gremlin-python version 3.5.7, I execute the following:
from dotenv import load_dotenv
from graph.base import g
from gremlin_python import statics
from gremlin_python.process.traversal import T
from gremlin_python.process.graph_traversal import __
from gremlin_python.process.strategies import *
from gremlin_python.process.graph_traversal import GraphTraversalSource
from gremlin_python.structure.graph import Graph
from gremlin_python.driver.driver_remote_connection import DriverRemoteConnection
statics.load_statics(globals())
gremlin_version = tuple([int(x) for x in version('gremlinpython').split('.')])
if (gremlin_version <= (3, 4, 0)):
graph = Graph()
g = graph.traversal().withRemote(DriverRemoteConnection(GRAPH_DB_URL, 'g'))
else:
from gremlin_python.process.anonymous_traversal import traversal
g = traversal().withRemote(DriverRemoteConnection(GRAPH_DB_URL, 'g',
username=GRAPH_DB_USER, password=GRAPH_DB_PASSWORD))
# clear database
g.V().drop().iterate()
# add vertices
g.addV('person').property(T.id, 0).next()from dotenv import load_dotenv
from graph.base import g
from gremlin_python import statics
from gremlin_python.process.traversal import T
from gremlin_python.process.graph_traversal import __
from gremlin_python.process.strategies import *
from gremlin_python.process.graph_traversal import GraphTraversalSource
from gremlin_python.structure.graph import Graph
from gremlin_python.driver.driver_remote_connection import DriverRemoteConnection
statics.load_statics(globals())
gremlin_version = tuple([int(x) for x in version('gremlinpython').split('.')])
if (gremlin_version <= (3, 4, 0)):
graph = Graph()
g = graph.traversal().withRemote(DriverRemoteConnection(GRAPH_DB_URL, 'g'))
else:
from gremlin_python.process.anonymous_traversal import traversal
g = traversal().withRemote(DriverRemoteConnection(GRAPH_DB_URL, 'g',
username=GRAPH_DB_USER, password=GRAPH_DB_PASSWORD))
# clear database
g.V().drop().iterate()
# add vertices
g.addV('person').property(T.id, 0).next()And I get the following error message:
gremlin_python.driver.protocol.GremlinServerError: 500: Vertex does not support user supplied identifiersgremlin_python.driver.protocol.GremlinServerError: 500: Vertex does not support user supplied identifiersSolution
You could do both
Then you could use any arbitrary string ID, e.g.
graph.set-vertex-id=true
graph.allow-custom-vid-types=truegraph.set-vertex-id=true
graph.allow-custom-vid-types=trueThen you could use any arbitrary string ID, e.g.
g.addV("person").property(T.id, "1").next()g.addV("person").property(T.id, "1").next()