0

I am trying to execute a Neptune SparQl query inside a Lambda function.

Following the documentation : AWS Lambda function examples for Amazon Neptune

I have used the sample for nodeJS.

Running the sample I get in response :

{
  "value": "5403",
  "done": false
}

I am not familiar with the Gremlin syntax and while reading the following documentation : PRACTICAL GREMLIN there are some examples.

My working SparQl query in Jyppiter on AWS :

base <http://uri.name/>
prefix : <property/>
prefix class: <Class/>

SELECT *
from <graphs/Asset/EXTRA>
where {
    ?v ?e ?u
}
limit 100

Results like this :

http://uri.name/assets/1 || http://www.w3.org/1999/02/22-rdf-syntax-ns#type ||  http://uri.name/class/Class

Trying to translate to Gremlin :

    b: await g.V().hasLabel('assets').valueMap().toList(),
    c: await g.V().hasLabel('assets').values('assets').limit(20).next()

And several variants, however they all result like so :

"b": [
    {},
    {},
    {},
    {},
    {}
  ],
  "c": {
    "value": null,
    "done": true
  },

Is there something I'm missing with formatting or query related ?

Pogrindis
  • 7,755
  • 5
  • 31
  • 44
  • are you sure that your data contains nodes with the label `assets`? According to your SPARQL query the class is simply called `http://uri.name/class/Class`. Would be good if you show your Graph schema and some sample data. – UninformedUser Aug 11 '22 at 16:51
  • 1
    Are you trying to query RDF data loaded using SPARQL (or some other way) with Gremlin? Or do you have two different versions of your data loaded? Today with Neptune, RDF data must be queried using SPARQL and Property Graph data can be queried using Gremlin or openCypher – Kelvin Lawrence Aug 11 '22 at 16:59
  • @KelvinLawrence I'll be honest, that's a bit confusing for me.. Its RDF data using Neptune.. It seems I'm not able to use a 'raw' SPRQL query then inside the Gremlin ? – Pogrindis Aug 12 '22 at 07:16
  • @KelvinLawrence I war reading through your book on : https://kelvinlawrence.net/book/Gremlin-Graph-Guide.html but really is not clear in relation to gremlinJS & Neptune. Will read more though. – Pogrindis Aug 12 '22 at 10:46
  • Your RDF data needs to be queried using just SPARQL queries. I'll try to clarify in an answer – Kelvin Lawrence Aug 12 '22 at 18:11

1 Answers1

1

Amazon Neptune supports two data representations. RDF and Property Graph. Any data loaded as RDF must be queried using SPARQL. Data loaded as a property graph can be queried using Gremlin or openCypher. You cannot mix and match Gremlin and SPARQL over the same data.

To issue a SPARQL query from AWS Lambda, you will either need to just send an HTTP request to https:<neptune-cluster>:<port>/sparql or use a library such as SPARQLWrapper or RDFLib.

Kelvin Lawrence
  • 14,674
  • 2
  • 16
  • 38