当前我正在使用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': [ 'name', [Object], 'age', [Object] ] }
]
将库更新为[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' ], 'age' => [ 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图形随附的Gremlin库,而不要独立更新它们。如您所见,最新的Javascript / Node Gremlin客户端确实返回Map类型。