Hi there - there is an answer on StackOverflow - the timeout is only 3 seconds.

    Andy

On 25/04/2019 12:44, Alnazer, Ahmed wrote:
Hi ,



Having problem returning result using Jena



The result is not the same if I use Jena VS http://dbpedia.org/sparql

my Code in Jena

I try to return two lists contain the types for the searched text name

s1 = "Ketolide";

s2 = "Aminocoumarin";

String sparqlQueryString1 = "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> 
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>" +

                         "SELECT  distinct ?type1 " +

                         "WHERE { ?data  rdfs:label ?label1. ?data rdf:type ?type1.   FILTER 
contains(lcase(str(?label1)),'" + s1.toLowerCase()  + "'). }";



Query query = QueryFactory.create(sparqlQueryString1);



QueryEngineHTTP objectToExec = 
QueryExecutionFactory.createServiceRequest("http://dbpedia.org/sparql";, query);



objectToExec.addParam("timeout","3000");

ResultSet results = objectToExec.execSelect();

List<QuerySolution> s = ResultSetFormatter.toList(results);

ResultSetFormatter.out(System.out, results, query);



sparqlQueryString1 = "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> PREFIX 
rdfs: <http://www.w3.org/2000/01/rdf-schema#> " +

                         "SELECT distinct ?type1 " +

                         "WHERE {?data  rdfs:label ?label1. ?data rdf:type ?type1.  FILTER 
contains(lcase(str(?label1)),'" + s2.toLowerCase()  + "'). }";



query = QueryFactory.create(sparqlQueryString1);



objectToExec = 
QueryExecutionFactory.createServiceRequest("http://dbpedia.org/sparql";, query);

objectToExec.addParam("timeout","3000");

results = objectToExec.execSelect();

List<QuerySolution> s22 = ResultSetFormatter.toList(results);

ResultSetFormatter.out(System.out, results, query);

then when I use the same query In the website and it get result

SELECT distinct ?type1 WHERE{ ?data rdf:type ?type1. ?data  rdfs:label  ?label1 
.    FILTER contains(lcase(str(?label1)), 'ketolide') .}

return

type1



http://dbpedia.org/ontology/ChemicalCompound

http://dbpedia.org/class/yago/WikicatKetolideAntibiotics

http://dbpedia.org/class/yago/Agent114778436

http://dbpedia.org/class/yago/Antibacterial102716205

http://dbpedia.org/class/yago/Antibiotic102716866

http://dbpedia.org/class/yago/CausalAgent100007347

http://dbpedia.org/class/yago/Drug103247620

http://dbpedia.org/class/yago/Matter100020827

http://dbpedia.org/class/yago/Medicine103740161

http://dbpedia.org/class/yago/PhysicalEntity100001930

http://dbpedia.org/class/yago/Substance100020090

http://dbpedia.org/class/yago/WikicatAntibiotics

what the reason and cause of this difference



link for my question on stackoverflow

https://stackoverflow.com/questions/55835144/not-get-result-queering-using-jena-but-when-i-use-the-http-dbpedia-org-sparql

thanks


Reply via email to