[Mulgara-general] empty results from SPARQL queries

Paul Gearon gearon at ieee.org
Fri Feb 3 22:25:36 UTC 2012

On Fri, Feb 3, 2012 at 4:33 PM, Mark Stubbeman
<MStubbeman at algebraixdata.com> wrote:
> Thanks Alex.  My problem here is that 1) I’m not sure what makes for an
> appropriate Graph URI

Any URI is fine. It can be anything like "http://host/path" all the
way through to "foo". So long as it's a valid URI then Mulgara will
accept it.

> and 2) I’m not sure how to encode that in the request.

There are two ways. First, you just put it into the query (which you
do below). Second, you put it in as a default-graph-uri parameter. I
don't know how that is provided in the Perl module, but I'm sure it's
an option.

> As for the graph URI, the data uploads and queries successfully from the
> webui if I use something like “goldfish:8080/sparql” (where goldfish is the
> hostname of the server on which Mulgara is running).  So going with that, if
> I modify the request as follows:
> SELECT DISTINCT ?s FROM <goldfish:8080/sparql> WHERE { ?s ?p ?o . }

While that will parse as a URI, it isn't what you might expect it to
be. That says that you have a scheme of "goldfish" (which is not
standard). The :8080 indicates that you're still looking to use http,
so that should have been your scheme. In other words, your query ought
to have been:

SELECT DISTINCT ?s FROM <http://goldfish:8080/sparql> WHERE { ?s ?p ?o . }

Incidentally, while http://goldfish:8080/sparql is a perfectly valid
URI to name a graph, it *looks* like a SPARQL endpoint URL, and is
therefore misleading. You may be better off with:

But it's up to you.

> then the line of Perl

> (still no rows of data however) and with Mulgara down and nc running I get:
> /sparql?query=SELECT%20DISTINCT%20%3Fs%20FROM%20%3Chttp%3A%2F%2Fgoldfish%3A8080%2Fsparql%3E%20WHERE%20%7B%20%3Fs%20%3Fp%20%3Fo%20.%20%7D

That's a little strange, since you said that you were using a URI of
<goldfish:8080/sparql> but then this encoding says
<http://goldfish:8080/sparql>. What's the name of the graph that
you've loaded the data into?

> FWIW I think you have me on the right path however.  I *know* I’m just
> guessing at what an appropriate Graph URI would be and how to specify it in
> the perl script request.

Just make sure to keep the graph URI consistent.

Try loading your data into a graph called "my:data". Then from the web
UI try the query:
  SELECT * FROM <my:data> WHERE { ?s ?p ?o }

That should contain all your data. If that works, then try exactly the
same query again in a Perl query. The result should be the same. It
won't matter what the default graph is, since this query is specifying
a particular graph and not relying on the default (which varies
between implementations).

BTW, Alex, the default graph is only sys:null if you don't change it.


More information about the Mulgara-general mailing list