Basic vertex querying does not work in Amazon Neptune but it works with local Gremlin Server

const fankode : any = await this.gremlinService.readClientSource
.V( profileId )
.hasLabel( 'FAN' )
.next();
const fankode : any = await this.gremlinService.readClientSource
.V( profileId )
.hasLabel( 'FAN' )
.next();
When I try to fetch vertex with properties like this , or with elementMap() and valueMap(true), It does not work, it just fetches empty object. I can only query properties of a vertex like this in Amazon neptune
this.gremlinService.readClientSource
.V( profileId )
.hasLabel( 'FAN' )
.properties()
.toList(),
this.gremlinService.readClientSource
.V( profileId )
.hasLabel( 'FAN' )
.properties()
.toList(),
but then I would need two queries for basic fetching which I don't want due to performance reasons. Can anyone give me hand here? Thanks
7 Replies
spmallette
spmallette3mo ago
Neptune does not yet support the "properties on elements" feature that was introduced in TinkerPop 3.7.x that allows graph elements like Vertex and Edge to be returned with properties. If you care to understand the history around this design choice you can read this: https://lists.apache.org/thread/xltcon4zxnwq4fyw2r2126syyrqm8spy In 3.7.x we describe how "properties on elements" works in the upgrade documentation: https://tinkerpop.apache.org/docs/current/upgrade/#_properties_on_elements It is therefore expected that when you return a Vertex with Neptune you don't get any properties, but it is odd that when you use elementMap() or valueMap() that you get empty maps. I'm not sure what to make of that. could you say what Neptune and TinkerPop versions you are using?
Memo
MemoOP2mo ago
Neptune version: 1.3.2.1 Gremlin version : 3.7.2 Thank you for your message, yes I have simplifed added removed for value map and element map but it did not work
ColeGreer
ColeGreer2mo ago
@Memo Can I ask how you are constructing and configuring your GraphTraversalSource (gremlinService.readClientSource)? I gave a quick test with the most basic setup (using gremlin 3.7.2 and Neptune 1.3.2.1) and it works as I would expect:
async function main(){
const g = traversal().withRemote(new DriverRemoteConnection('wss://my-neptune.cluster-xxxxxxxxxxxx.region.neptune.amazonaws.com:8182/gremlin'));
const results = await g.V().limit(1).elementMap().next()
console.log(results.value)
}
async function main(){
const g = traversal().withRemote(new DriverRemoteConnection('wss://my-neptune.cluster-xxxxxxxxxxxx.region.neptune.amazonaws.com:8182/gremlin'));
const results = await g.V().limit(1).elementMap().next()
console.log(results.value)
}
Map(4) {
EnumValue { typeName: 'T', elementName: 'id' } => '2',
EnumValue { typeName: 'T', elementName: 'label' } => 'person',
'name' => 'vadas',
'age' => 27
}
Map(4) {
EnumValue { typeName: 'T', elementName: 'id' } => '2',
EnumValue { typeName: 'T', elementName: 'label' } => 'person',
'name' => 'vadas',
'age' => 27
}
Memo
MemoOP2mo ago
thank you for your message, I am putting my code as a file
Memo
MemoOP2mo ago
thanks for the support again
Kennh
Kennh2mo ago
The gremlin-javascript driver deserializes the elementMap() step into the Map class. await this.gremlinService.readClientSource.V().elementMap().toList() will return an Array of Maps. JSON.stringify() , which NestJS is likely calling for you, doesn't support Maps so you need to convert them into objects using something like Object.fromEntries().
Memo
MemoOP2mo ago
Thank you very much. Yes nest.js 's logger was the issue after I switched to console log I saw the data structures that was returned. Thanks again!
Want results from more Discord servers?
Add your server