[Mulgara-general] empty results from SPARQL queries

Mark Stubbeman MStubbeman at algebraixdata.com
Fri Feb 3 21:33:41 UTC 2012


Thanks Alex.  My problem here is that 1) I’m not sure what makes for an appropriate Graph URI and 2) I’m not sure how to encode that in the request.

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 . }

then the line of Perl

my $iterator = $query->execute($webURL);

returns the an iterator which dumps as follows:

$VAR1 = bless( {
                 '_peek' => [],
                 '_row' => undef,
                 '_count' => 0,
                 '_type' => 'bindings',
                 '_finished' => 0,
                 '_names' => [
                               's'
                             ],
                 '_args' => {},
                 'sorted_by' => [],
                 '_stream' => sub { "DUMMY" },
                 '_open' => 0
               }, 'RDF::Trine::Iterator::Bindings' );

(still no rows of data however) and with Mulgara down and nc running I get:

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 HTTP/1.1
TE: deflate,gzip;q=0.3
Connection: TE, close
Accept: application/sparql-results+json, application/sparql-results+xml;q=0.9, application/rdf+xml, application/x-turtle, text/turtle
Host: goldfish:8080
User-Agent: RDF::Query::Client/0.107 (cpan:TOBYINK) libwww-perl/6.02
Content-Type: application/x-www-form-urlencoded

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.

-Mark

From: mulgara-general-bounces at mulgara.org [mailto:mulgara-general-bounces at mulgara.org] On Behalf Of Alex Hall
Sent: Friday, February 03, 2012 2:24 PM
To: Mulgara General
Subject: Re: [Mulgara-general] empty results from SPARQL queries

I think the problem is you haven't specified a default graph for the query. The default graph is where Mulgara looks to actually match the triple patterns in the WHERE clause. So you need to give Mulgara the URI of the graph where you loaded your data, either as part of the query string using a FROM clause...

SELECT DISTINCT ?s FROM <my_graph_uri> WHERE { ?s ?p ?o . }

or using the default-graph-uri parameter of the SPARQL HTTP request:

GET /sparql?query=SELECT...&default-graph-uri=my_graph_uri

Having no experience with the RDF module for Perl, so I don't know how you would set that request parameter.

If you don't specify a default graph URI in either the query string or request parameter, Mulgara uses the built-in graph URI sys:null which is always empty.

-Alex

On Fri, Feb 3, 2012 at 3:11 PM, Mark Stubbeman <MStubbeman at algebraixdata.com<mailto:MStubbeman at algebraixdata.com>> wrote:
Got it - here are go.

GET /sparql?query=SELECT%20DISTINCT%20%3Fs%20WHERE%20%7B%20%3Fs%20%3Fp%20%3Fo%20.%20%7D HTTP/1.1
TE: deflate,gzip;q=0.3
Connection: TE, close
Accept: application/sparql-results+json, application/sparql-results+xml;q=0.9, application/rdf+xml, application/x-turtle, text/turtle
Host: goldfish:8080
User-Agent: RDF::Query::Client/0.107 (cpan:TOBYINK) libwww-perl/6.02
Content-Type: application/x-www-form-urlencoded


-----Original Message-----
From: mulgara-general-bounces at mulgara.org<mailto:mulgara-general-bounces at mulgara.org> [mailto:mulgara-general-bounces at mulgara.org<mailto:mulgara-general-bounces at mulgara.org>] On Behalf Of Paul Gearon
Sent: Friday, February 03, 2012 1:32 PM
To: Mulgara General
Subject: Re: [Mulgara-general] empty results from SPARQL queries

I was actually referring to the HTTP exchange. (It's reasonably easy.
One way is to run "nc -l 8080" and then point your webURL to
http://localhost:8080/sparql)

I haven't used Perl in a few years, so I don't recall how to get modules from CPAN. When I get the time (I'm at work) I'll get the RDF stuff that you're using and try it myself.

Paul

On Fri, Feb 3, 2012 at 1:04 PM, Mark Stubbeman <MStubbeman at algebraixdata.com<mailto:MStubbeman at algebraixdata.com>> wrote:
> Here's the Dumper() print of the query before I execute it:
>
> $VAR1 = bless( {
>                 'query' => 'SELECT DISTINCT ?s WHERE { ?s ?p ?o . }',
>                 'error' => undef,
>                 'useragent' => undef,
>                 'results' => []
>               }, 'RDF::Query::Client' );
>
> I get the feeling I may be relying upon defaults which work with one DB but not the other.  Since I'm new to this I'm not able to pick it out though.
>
> Thanks,
> Mark
>
> -----Original Message-----
> From: mulgara-general-bounces at mulgara.org<mailto:mulgara-general-bounces at mulgara.org>
> [mailto:mulgara-general-bounces at mulgara.org<mailto:mulgara-general-bounces at mulgara.org>] On Behalf Of Paul Gearon
> Sent: Friday, February 03, 2012 10:11 AM
> To: Mulgara General
> Subject: Re: [Mulgara-general] empty results from SPARQL queries
>
> Mulgara usually works fine with HTTP, so I'm not sure.
>
> Would you be able to get a copy of the HTTP request for this please?
> That may contain a clue.
>
> Thanks in advance.
>
> Paul
>
> On Fri, Feb 3, 2012 at 10:21 AM, Mark Stubbeman <MStubbeman at algebraixdata.com<mailto:MStubbeman at algebraixdata.com>> wrote:
>> I'm new to SPARQL and to triple-store technology in general.  I have
>> a couple of example DBs - Mulgara being one of them - against which I
>> am trying to write some simple Perl code to submit queries and
>> extract responses.  The following works against one of my DB's but
>> not against
>> Mulgara:
>>
>>
>>
>> sub runQuery
>>
>> {
>>
>>   use RDF::Query::Client;
>>
>>
>>
>> # $webURL scrubbed of actual hostname but otherwise true to my actual
>> code
>>
>>   my $webURL = "http://$somehostname:8080/sparql";
>>
>>
>>
>> # an array of lines read from a file containing a SPARQL query
>>
>>   my @queryIn = @_;
>>
>>   my $funcQuery = join('', @queryIn);
>>
>>
>>
>>   print "Query\n-----\n\n$funcQuery\n";
>>
>>   my $query = RDF::Query::Client->new($funcQuery);
>>
>>   my $iterator = $query->execute($webURL);
>>
>>   print "Response\n------\n\n";
>>
>>   print Dumper($iterator);
>>
>>   while (my $row = $iterator->next)
>>
>>   {
>>
>>     print "$row\n";
>>
>>   }
>>
>> }
>>
>>
>>
>> With $webURL directed at another DB we get the following:
>>
>>
>>
>> Executing: C:\sandboxes\cdbms\Hawk\Tests\SP2Bench\queries\q1.sparql
>>
>>
>>
>> Query
>>
>> -----
>>
>>
>>
>> SELECT DISTINCT ?s WHERE { ?s ?p ?o . }
>>
>> Response
>>
>> ------
>>
>>
>>
>> $VAR1 = bless( {
>>
>>                  '_peek' => [],
>>
>>                  '_row' => undef,
>>
>>                  '_count' => 0,
>>
>>                  '_type' => 'bindings',
>>
>>                  '_finished' => 0,
>>
>>                  '_names' => [],
>>
>>                  '_args' => {},
>>
>>                  'sorted_by' => [],
>>
>>                  '_stream' => sub { "DUMMY" },
>>
>>                  '_open' => 0
>>
>>                }, 'RDF::Trine::Iterator::Bindings' );
>>
>> { s=<http://localhost/publications/articles/Journal1/1944/Article4> }
>>
>>
>>
>> (note that the output has been truncated to just one line).  However,
>> with $webURL set to our Mulgara installation the same code generates
>> the
>> following:
>>
>>
>>
>> Query
>>
>> -----
>>
>>
>>
>> SELECT DISTINCT ?s WHERE { ?s ?p ?o . }
>>
>> Response
>>
>> ------
>>
>>
>>
>> $VAR1 = bless( {
>>
>>                  '_peek' => [],
>>
>>                  '_row' => undef,
>>
>>                  '_count' => 0,
>>
>>                  '_type' => 'bindings',
>>
>>                  '_finished' => 0,
>>
>>                  '_names' => [
>>
>>                                's'
>>
>>                              ],
>>
>>                  '_args' => {},
>>
>>                  'sorted_by' => [],
>>
>>                  '_stream' => sub { "DUMMY" },
>>
>>                  '_open' => 0
>>
>>                }, 'RDF::Trine::Iterator::Bindings' );
>>
>>
>>
>> We get back an iterator (with slightly different properties) but no
>> results.  I know via the Mulgara webui that the data is there.
>> That's how I load the data.  I'm not sure what to use for Graph URI
>> (several settings seem to work) but for the above exercise I used "<hostname>:8080/sparql"
>> where <hostname> is the same as $somehostname from the sample code.
>>
>>
>> _______________________________________________
>> Mulgara-general mailing list
>> Mulgara-general at mulgara.org<mailto:Mulgara-general at mulgara.org>
>> http://lists.mulgara.org/mailman/listinfo/mulgara-general
>>
> _______________________________________________
> Mulgara-general mailing list
> Mulgara-general at mulgara.org<mailto:Mulgara-general at mulgara.org>
> http://lists.mulgara.org/mailman/listinfo/mulgara-general
> _______________________________________________
> Mulgara-general mailing list
> Mulgara-general at mulgara.org<mailto:Mulgara-general at mulgara.org>
> http://lists.mulgara.org/mailman/listinfo/mulgara-general
_______________________________________________
Mulgara-general mailing list
Mulgara-general at mulgara.org<mailto:Mulgara-general at mulgara.org>
http://lists.mulgara.org/mailman/listinfo/mulgara-general
_______________________________________________
Mulgara-general mailing list
Mulgara-general at mulgara.org<mailto:Mulgara-general at mulgara.org>
http://lists.mulgara.org/mailman/listinfo/mulgara-general

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mulgara.org/pipermail/mulgara-general/attachments/20120203/e1bf7230/attachment-0001.html>


More information about the Mulgara-general mailing list