Gremlin console vs REST API
I'm trying to get a path and the properties of the vertices and the edges for that path by running a gremlin script via REST API in Neptune. The query is simple with some filters on the edges, but the result is different from what gremlin console gives me.
For example, the following query returns the path with the type of entities (vertex or edge) but only the label and the ID properties.
Similarly, by adding a
by(valueMap())
modulator I get all the properties of all edges and vertices in the path, but not the types ("@type": "g:Edge"
and "@type": "g:Vertex"
)
The call to Neptune is done as described here https://docs.aws.amazon.com/neptune/latest/userguide/access-graph-gremlin-rest.html
I guess the question is: is there a way to get the type of entity and all properties with one single query?Using the HTTPS REST endpoint to connect to a Neptune DB instance -...
Steps for connecting to Neptune using the HTTPS REST Endpoint.
Solution:Jump to solution
Generally speaking, the GLVs and the Gremlin Console (if sending queries as bytecode and connecting via websockets) will serialize the results back into types that are common to the runtime that you're using for your application.
Queries sent over HTTP will return the response using GraphSON (GraphSONv3, be default with Neptune) which includes all of the extra type information....
Queries sent over HTTP will return the response using GraphSON (GraphSONv3, be default with Neptune) which includes all of the extra type information....
8 Replies
Solution
Generally speaking, the GLVs and the Gremlin Console (if sending queries as bytecode and connecting via websockets) will serialize the results back into types that are common to the runtime that you're using for your application.
Queries sent over HTTP will return the response using GraphSON (GraphSONv3, be default with Neptune) which includes all of the extra type information.
Queries sent over HTTP will return the response using GraphSON (GraphSONv3, be default with Neptune) which includes all of the extra type information.
I see, thanks for the clarification. Regarding Neptune and GraphSON though, is there a standard way of getting the same response back in graphson format? I see in the docs that TinkerGraph has a different serializer than the rest. For more context here, I'm trying to build a simple UI that shows a very basic subraph to our users. I am using gdotv myself, but that's local and not a good solution for users - and I'm looking for something generic that given any arbitrary query I can construct and vizualize a graph. Is this a matter of me parsing the query before sending it to Neptune and change it to return a path and then ask for the same traversal but with a valueMap in the
by
modulator?Note that properties will (can) be returned on elements after 3.7.0: https://tinkerpop.apache.org/docs/current/upgrade/#_properties_on_elements Neptune does not yet support that version but should relatively soon.
@Dragos Ciupureanu - which client are you using to interact with Neptune?
I'm doing a simple POST request to Neptune's REST API from Javascript right now
Another approach... we now have support for issuing queries via the AWS CLI and SDKs. Still requires network access to your cluster endpoints. Example here:
Using the serializer above, it returns data in the more concise format without types:
More info on this Javascript module here: https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-neptunedata/
AWS SDK for JavaScript v3
API Reference
This is great, thanks for the suggestion.