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!
http://141.117.3.88:8890/sparql? If you're trying to query against DBpedia, wouldhttp://dbpedia.org/sparqlmake more sense? - Joshua Taylor