无法使用neo4j插件和gremlin服务器定位方法:DefaultGraphTraversal.to
我正在为nodejs使用gremlin插件,通过嵌入的neo4j图形与gremlin服务器通信。我能够查询和创建顶点,但由于“无法找到方法:DefaultGraphTraversal.to”错误而无法创建任何边。有什么想法吗 我能够使用连接到与nodejs程序相同的gremlin服务器的gremlin控制台创建顶点和边 Gremlin控制台和服务器3.4.1 小精灵节点npm 3.4.1 Tinkerpop Neo4J小精灵插件:3.4.1无法使用neo4j插件和gremlin服务器定位方法:DefaultGraphTraversal.to,neo4j,gremlin-server,Neo4j,Gremlin Server,我正在为nodejs使用gremlin插件,通过嵌入的neo4j图形与gremlin服务器通信。我能够查询和创建顶点,但由于“无法找到方法:DefaultGraphTraversal.to”错误而无法创建任何边。有什么想法吗 我能够使用连接到与nodejs程序相同的gremlin服务器的gremlin控制台创建顶点和边 Gremlin控制台和服务器3.4.1 小精灵节点npm 3.4.1 Tinkerpop Neo4J小精灵插件:3.4.1 const gremlin = require('gr
const gremlin = require('gremlin');
const traversal = gremlin.process.AnonymousTraversalSource.traversal;
const Graph = gremlin.structure.Graph;
const DriverRemoteConnection = gremlin.driver.DriverRemoteConnection;
const g = traversal().withRemote(new DriverRemoteConnection('ws://localhost:8182/gremlin'));
async function run(){
const phil = await g.V().has('name', 'phil').next();
console.log("Have Phil: " +JSON.stringify(phil ));
g.V().has('name', 'stephen').next()
.then(stephen => {
console.log("Have Steve: " +JSON.stringify(stephen));
const e1 = g.V(phil).addE('friends').to(stephen).next();
console.log(e1);
})
.catch(err => console.log(err));
}
run();
下面是输出。正如您所看到的,我能够很好地获取顶点,但在创建边的过程中会收到此错误
Have Phil: {"value":{"id":18,"label":"person"},"done":false}
gremlin.js:13
Have Steve: {"value":{"id":7,"label":"person"},"done":false}
gremlin.js:17
Promise { pending }
gremlin.js:19
(node:48830) UnhandledPromiseRejectionWarning: Error: Server error: Could not locate method: DefaultGraphTraversal.to([{value={id=7, label=person}, done=false}]) (599)
at Connection._handleMessage (/Users/byronbailey/OneDrive - Cargill Inc/VSC/GraphTest/node_modules/gremlin/lib/driver/connection.js:265:9)
at WebSocket._ws.on (/Users/byronbailey/OneDrive - Cargill Inc/VSC/GraphTest/node_modules/gremlin/lib/driver/connection.js:128:43)
at WebSocket.emit (events.js:189:13)
at Receiver._receiver.onmessage (/Users/byronbailey/OneDrive - Cargill Inc/VSC/GraphTest/node_modules/ws/lib/WebSocket.js:141:47)
at Receiver.dataMessage (/Users/byronbailey/OneDrive - Cargill Inc/VSC/GraphTest/node_modules/ws/lib/Receiver.js:380:14)
at Receiver.getData (/Users/byronbailey/OneDrive - Cargill Inc/VSC/GraphTest/node_modules/ws/lib/Receiver.js:330:12)
at Receiver.startLoop (/Users/byronbailey/OneDrive - Cargill Inc/VSC/GraphTest/node_modules/ws/lib/Receiver.js:165:16)
at Receiver.add (/Users/byronbailey/OneDrive - Cargill Inc/VSC/GraphTest/node_modules/ws/lib/Receiver.js:139:10)
at Socket._ultron.on (/Users/byronbailey/OneDrive - Cargill Inc/VSC/GraphTest/node_modules/ws/lib/WebSocket.js:138:22)
at Socket.emit (events.js:189:13)
warning.js:18
(node:48830) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
warning.js:18
(node:48830) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
问题在于参数的数据类型。我以前尝试过这个解决方案的不同版本,但显然仍然没有达到目的。代码的ADD行应如下所示。帮助连接点 g、 V(phil.value.id).addE('knows').to(g.V(stephen.value.id)).next()