0

I'm dealing with a problem that I can't execute the same query (see Example below) multiple times against DBpedia, because the execution freezes after like 4-5 queries.

The thing is, with the same Apache Jena Code, I can execute hundreds of same queries against Wikidata (see Example below) without a problem. The Apache Jena Code is literally standard code (see below). The result is just returned as a normal string value. I also tried variations here, but that's not the issue.

Apache Jena Code Snippet from the DBpedia query (Wikidata is basically the same except the createServiceRequest-Method uses https://query.wikidata.org/sparql)

Query query = queryFactory.create(**!!see Query Example below!!**);
QueryEngineHTTP queryEngine = QueryExecutionFactory.createServiceRequest("http://de.dbpedia.org/sparql",
                query);
ResultSet results = queryEngine.execSelect();
        for (; results.hasNext();) {
            QuerySolution solution = results.nextSolution();
            String stringElement = solution.getLiteral("item").toString();
            stringArray.add(stringElement);
            // stringArray is then returned simply with System.out.println
        }

DBpedia Query:

prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix dbpprop-de: <http://de.dbpedia.org/property/>
prefix dbpedia-de: <http://de.dbpedia.org/resource/>
SELECT DISTINCT ?item WHERE {
    dbpedia-de:Deutschland dbpprop-de:hauptstadt ?y .
    ?y rdfs:label ?item 
}

Wikidata Query:

prefix wdt: <http://www.wikidata.org/prop/direct/>
prefix wd: <http://www.wikidata.org/entity/>
prefix wikibase: <http://wikiba.se/ontology#>
prefix bd: <http://www.bigdata.com/rdf#>
SELECT DISTINCT ?itemLabel WHERE {
wd:Q183 wdt:P36 ?item .
SERVICE wikibase:label { 
    bd:serviceParam wikibase:language "de" . 
    } 
}

Is there some kind of Execution Limit on queries for users in DBpedia? I know there are limits on ResultSets, but that's not the issue here as i only get like one result per one query back. It would be really helpful as i couldn't find a similar problem. Thanks in advance.

TallTed
  • 9,069
  • 2
  • 22
  • 37
grajkowski
  • 349
  • 1
  • 3
  • 14
  • Of course shared public resources have some limitations especially when you're running a bunch of course n a short time. This is quite obvious otherwise people could flood the servers and others couldn't use it. Use a delay between the queries or even better - for high load - setup your own DBpedia instance. – UninformedUser Apr 24 '17 at 14:27
  • Thanks for the fast answer. I'm not really using high load, but a delay sounds like a solution. What are the commands for a delay between the query execution? – grajkowski Apr 24 '17 at 15:01
  • there is nothing built-in in Jena. With standard Java it would be something like `Thread.sleep` I would say. – UninformedUser Apr 24 '17 at 16:40
  • Thread.sleep doesn't work, even though i set up a threshold of at least 10 Seconds (which is fairly high in my application) it still freezes. – grajkowski Apr 25 '17 at 10:45
  • 10 seconds would be quite long. Can you clarify what you mean by "freeze"? That the query execution takes longer? Are you iterating over several queries? And have you tried to print the query before execution such that you can see which query takes too much time? – UninformedUser Apr 25 '17 at 11:24
  • When I debug, it freezes exactly at `ResultSet results = queryEngine.execSelect();` Apache Jena doesn't want to resolve and freezes (does not terminate). I also forgot to mention that it doesn't matter which queries are taken as it always freezes at the 5th Query. The Queries are fairly simple as seen in the examples. – grajkowski Apr 25 '17 at 13:14
  • Though they may not be the immediate issue, please see the [DBpedia website](http://wiki.dbpedia.org/OnlineAccess#1.1%20Public%20SPARQL%20Endpoint) and [Usage Report](https://medium.com/openlink-software-blog/dbpedia-usage-report-a78b3802a1d3#a9ba) for more information about usage limits, – TallTed Apr 25 '17 at 21:21
  • Well I am definitely under the user Limit, but thanks for the info. I also found the issue: it's the DBpedia endpoint: `de.dbpedia.org/sparql` When i use `dbpedia.org/sparql` I can execute a lot of queries. But how come? – grajkowski Apr 26 '17 at 13:36

0 Answers0