Query on admin console vs REST yield different results

Hi,

I assume that any query that is executed in the web console should yield the same result as from the sparql endpoint.

Apparently, this is not the case as the following example demonstrates:

Given the following data:

@prefix : <test#> .

:a :before :b .
:b :before :c .
:c :before :d .

and the query: select * where {:a (:before)+ ?o}

Executed in the web console yields as expected the following result:

<?xml version='1.0' encoding='UTF-8'?>
<sparql xmlns='http://www.w3.org/2005/sparql-results#'>
	<head>
		<variable name='o'/>
	</head>
	<results>
		<result>
			<binding name='o'>
				<uri>http://api.stardog.com/test#b</uri>
			</binding>
		</result>
		<result>
			<binding name='o'>
				<uri>http://api.stardog.com/test#c</uri>
			</binding>
		</result>
		<result>
			<binding name='o'>
				<uri>http://api.stardog.com/test#d</uri>
			</binding>
		</result>
	</results>
</sparql>

Now I try the same via the SPARQL endpoint e.g. with curl:

curl --request POST --header "Accept: application/sparql-results+xml"  --data-binary 'query=select * where {:a (:before)+ ?o}'   'http://example.com:5820/test/query'

this gives me a restricted result missing c and d:

<?xml version='1.0' encoding='UTF-8'?>
<sparql xmlns='http://www.w3.org/2005/sparql-results#'>
	<head>
		<variable name='o'/>
	</head>
	<results>
		<result>
			<binding name='o'>
				<uri>http://api.stardog.com/test#b</uri>
			</binding>
		</result>
	</results>
</sparql>

It seems that the path operator + is ignored in this case - looks like a parse error?!

Note: I am running Stardog Community 5.0.3.

Regards, Immanuel

Hi,

This is a bit of a tricky situation, because the plus sign in a URL query string parameter is explicitly URL encoded as a space, so when your query is URL encoded to go over the wire, you get query=select * {:a (:before) ?o}.

You will need to manually URL encode the + character in your query. Fortunately it looks like cURL handles this gracefully, as when I run the command with --data-binary 'query=select * where {:a (:before)%2B ?o}' I get the three desired results.

Thanks Stephen, this solves the problem!

1 Like