SPARQL queries gives different answers on different servers

I am trying to run the following sparql query :

PREFIX  dct:  <http://purl.org/dc/terms/> 
select distinct ?subject 
where 
{ 
  ?concept rdfs:label 'Artificial intelligence'@en . 
  ?concept ^dct:subject ?subject . 
}
LIMIT 100

When I run this on dbpedia's public server, I get the following results : http://dbpedia.org/sparql?default-graph-uri=&query=PREFIX++dct%3A++%3Chttp%3A%2F%2Fpurl.org%2Fdc%2Fterms%2F%3E+select+distinct+%3Fsubject+where+%7B+%3Fconcept+rdfs%3Alabel+%27Artificial+intelligence%27%40en+.+%3Fconcept+%5Edct%3Asubject+%3Fsubject+.+%7D++LIMIT+100&format=text%2Fhtml&CXML_redir_for_subjs=121&CXML_redir_for_hrefs=&timeout=30000&debug=on

However, running the same query on a locally hosted instance of dbpedia, yields : http://34.195.108.80:8891/sparql?default-graph-uri=&query=PREFIX++dct%3A++%3Chttp%3A%2F%2Fpurl.org%2Fdc%2Fterms%2F%3E+select+distinct+%3Fsubject+where+%7B+%3Fconcept+rdfs%3Alabel+%27Artificial+intelligence%27%40en+.+%3Fconcept+%5Edct%3Asubject+%3Fsubject+.+%7D++LIMIT+100&format=text%2Fhtml&CXML_redir_for_subjs=121&CXML_redir_for_hrefs=&timeout=30000&debug=on

Why is there a discrepancy in the answers to the point where it's entirely different?

Upvotes: 0

Views: 76

Answers (1)

UninformedUser
UninformedUser

Reputation: 8465

I don't know what do you mean by "different", but without ORDER BY results will be returned more or less randomly simply influenced by the underlying system. There is even no guarantee that running the same query twice on the same server will return the results in the same order. Your query returns only 100 due to the LIMIT 100

The total number of results is the same for both queries, 271:

PREFIX  dct:  <http://purl.org/dc/terms/> 
SELECT count(distinct ?subject) WHERE { 
  ?concept rdfs:label 'Artificial intelligence'@en ; 
  ?        ^dct:subject ?subject . 
}  

For comparison, you have to use ORDER BY:

PREFIX  dct:  <http://purl.org/dc/terms/> 
SELECT ?subject WHERE { 
?concept rdfs:label 'Artificial intelligence'@en ; 
         ^dct:subject ?subject . 
}  
ORDER BY ?subject

Upvotes: 2

Related Questions