I'm trying to write a query that will search dbpedia movies only and find movies with the keyword "Inception". The query is working on http://dbpedia.org/sparql but not in my java code. I'm using jena libraries.
This is my Query
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
select ?Concept where {
?Concept a dbpedia-owl:Film.
?Concept rdfs:label ?label. FILTER (strStarts(str(?label), 'Inception')). } limit 10
Here is my Java function
public static String extractDbpedia (String jenaString) {
String result;
String queryString =
"prefix rdfs:<http://www.w3.org/2000/01/rdf-schema#>" +
"prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>" +
"prefix dbpedia-owl:<http://dbpedia.org/ontology/>" +
"prefix xsd: <http://www.w3.org/2001/XMLSchema#>" +
"SELECT * WHERE { " +
" SERVICE <http://141.117.3.88:8890/sparql> { " +
"select ?Concept where { ?Concept a dbpedia-owl:Film. ?Concept rdfs:label ?label. FILTER (strStarts(str(?label), 'Inception')). } limit 10" +
" }" +
"}" ;
LogCtl.setCmdLogging();
Query query = QueryFactory.create(queryString) ;
try(QueryExecution qexec = QueryExecutionFactory.create(query, ModelFactory.createDefaultModel())) {
ResultSet rs = qexec.execSelect();
result = (ResultSetFormatter.asText(rs));
}
return result;
I am getting Error HttpException: 400 and I don't know why. Thanks!
Your query may work at DBpedia, but the part that's supposed to be executed on
http://141.117.3.88:8890/sparql
doesn't work athttp://141.117.3.88:8890/sparql
. If you try runningSPARQL Results (an error message)
there, you get:
The about text for the server says:
Perhaps that version of Virtuoso doesn't support all the SPARQL 1.1 functions? You'd need to check the Virtuoso documentation, but based on Does Virtuoso versions <=6.0 support SPARQL 1.1?, it sounds like the version you've got, 6.01, may not support SPARQL 1.1 completely. The public DBpedia endpoint, on the other hand, is running a 7.x version: