Stardog query returns NULL

Hi Team -

I am trying to play around with Stardog and came across following example code on one of the documentation pages -

const { Connection, query } = require('stardog');
 
const conn = new Connection({
  username: 'admin',
  password: 'admin',
  endpoint: 'http://localhost:5820',
});
 
query.execute(conn, 'myDatabaseName', 'select distinct ?s where { ?s ?p ?o }', {
  limit: 10,
  offset: 0,
}).then(({ body }) => {
  console.log(body.results.bindings);
});

I installed Stardog before running this code as Node application but I am getting back body as NULL.

Technical Specs -

OS - Ubuntu 16.04
Stardog Version - 5.0.5.1
Node version - 6.12.0
NPM Version - 3.10.10

P.S - Instead of ‘myDatabaseName’, I am inserting name of my own database

Please let me know if you need additional details. I would really appreciate if you could please help me in resolving this issue.

Thanks in advance.

Best-
Ishan

Hi Ishan,

query.execute has an accept parameter in between the query and params arguments, with which you can specify the RDF type you want your results to be. This is causing your limit and offset to be ignored and therefore every ?s in your database is being returned. Since you probably don’t care which format you get right now, try this:

query.execute(conn, 'myDatabaseName', 'select distinct...', undefined, {
  limit:10,
  offset: 0,
})

Hi Stephen-

Thank you very much for your prompt response. I appreciate it. I made changes as suggested by you and it worked!
Have a great weekend!

Best-
Ishan

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.