目前我正在使用 janusgraph-0.2.0-hadoop2 服务器并使用 [email protected] 查询库
const Gremlin = require("gremlin");
const client = Gremlin.createClient(8182, "192.168.0.103");
function test(p){
client.execute(q, {}, (err, results) => {
if (err) {
console.error(err);
client.closeConnection();
}
else {
console.log(results);
client.closeConnection();
}
});
}
查询g.V().count()
结果为[ 12 ]
查询 g.V().has('name', 'saturn').valueMap()
结果为 [ { name: [ 'saturn' ],age: [ 10000 ] }]
我对此很满意
但是将我的janusgraph更新到janusgraph-0.5.0-hadoop2服务器并使用相同的库 [email protected]
获取不同格式的数据
查询g.V().count()
结果为[ { '@type': 'g:Int64', '@value': 12 } ]
查询g.V().has('name', 'saturn').valueMap()
结果为
[
{ '@type': 'g:Map', '@value': [ '姓名', [对象], '年龄', [对象] ] }
]
正在将库更新为 [email protected]
const gremlin = require('gremlin');
const client = new gremlin.driver.Client('ws://192.168.0.106:8182/gremlin', { traversalSource: 'g' });
async function test(q){
const res = await client.submit(q, {});
console.log('res',res)
client.close();
}
test()
查询g.V().count()
结果为[ 12 ]
查询g.V().has('name', 'saturn').valueMap()
结果是[ Map { 'name' => [ 'saturn' ], '年龄' => [ 10000 ] } ]
获取Hashmap中的数据 我想知道
1. Is it necessary to update gremlin library 3.4.6 getting correct result.
2. After updating to 3.4.6 get data in hashmap format, Means i want to know i am getting correct data or not.
3. I want data in object format but got in hashmap. I know i can convert to object but incase data is in nested hashmap, I dont want to repeat and convert it.
请给我建议
最佳答案
我想说,使用当前版本的 Janus Graph 是一个非常好的主意。请注意,您应该使用 Janus graph 附带的 Gremlin 库,而不是独立更新它们。正如您所看到的,最新的 Javascript/Node Gremlin 客户端确实返回 Map 类型。
关于gremlin - 更新 gremlin-server 后的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61015999/