I have the following query: select * WHERE { ?ambiguate <http://www.w3.org/2000/01/rdf-schema#label> "Armstrong"@en . ?ambiguate <http://dbpedia.org/ontology/wikiPageDisambiguates> ?resource . ?resource <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://schema.org/Person> . }

When I run it against live.dbpedia.org/sparql, I get three results (Louis, Neils and Lance Armstrong).

However, with the following Java code (using com.hp.hpl.jena.query.*), my ResultSet contains only one answer. String query = "select * WHERE { ?ambiguate http://www.w3.org/2000/01/rdf-schema#label "Armstrong"@en .n" + " ?ambiguate http://dbpedia.org/ontology/wikiPageDisambiguates ?resource .n" + " ?resource http://www.w3.org/1999/02/22-rdf-syntax-ns#type http://schema.org/Person .n" + "}"; System.out.println(query); Query q = QueryFactory.create(query); QueryExecution qexec = QueryExecutionFactory.sparqlService("http://live.dbpedia.org/sparql", q); ResultSet RS = qexec.execSelect();

I am absolutely puzzled as I have no idea what could be causing this difference in behaviour. Can anyone point me to something I'm missing?


asked 13 Dec '12, 10:39

Johannes%20Simon's gravatar image

Johannes Simon
accept rate: 0%

1/ The query in the Java string is bad (java) synatx. Are you sure you are not running an old copy of the program?

2/ How are you handling the results?

3/ try adding ?default-graph-uri=http%3A%2F%2Fdbpedia.org to

sparqlService("http://live.dbpedia.org/sparql?default-graph-uri=http%3A%2F%2Fdbpedia.org", q);

(more recent versions of jena only)

permanent link

answered 13 Dec '12, 12:35

AndyS's gravatar image

AndyS ♦
accept rate: 32%

Thanks for your response! It was actually point 2. After looking at my code again to explain how I'm handling the results, I realized that I had left the original handling of the result from where I copied the code. They only needed one result, so it looked like this: if (RS.hasNext()) { String match = RS.next().get("resource").toString(); ...

The problem obviously was the if, which should be a while. That's pretty embarrasing! :-)

(14 Dec '12, 07:25) Johannes Simon Johannes%20Simon's gravatar image
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:


question asked: 13 Dec '12, 10:39

question was seen: 1,541 times

last updated: 14 Dec '12, 07:27