سؤال

I tried to make this query on http://sparql.sindice.com/

PREFIX rev: <http://purl.org/stuff/rev#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT *
WHERE
{
 ?thing rdfs:label ?name .
  ?thing rev:hasReview ?review .
 filter regex(str(?name), "harlem", "i")
} LIMIT 10

And it returns 504 Gateway Time-out The server didn't respond in time. What i'm doing wrong? Thanks.

هل كانت مفيدة؟

المحلول

You made a query that was too hard for the endpoint to answer in a timely fashion hence why you got a timeout response. Note that there website states the following:

all queries are time and resource limited. notice that this means that sometime you will get incomplete or even no results. If this is happening often for you or you really want to run more complex queries please contact us

Your query essentially selects a vast swathe of data and then makes the engine run a regular expression over ever possible value which is extremely slow.

I believe Sindice use Virtuoso as their SPARQL implementation so you can cheat and use Virtuoso specific full text query extension like so:

PREFIX rev: <http://purl.org/stuff/rev#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT *
WHERE
{
  ?thing rdfs:label ?name .
  ?thing rev:hasReview ?review .
  ?name bif:contains "harlem" .
} 
LIMIT 10

However this query also seems to timeout, if you can add more conditions to constrain your query further you will have more chance of getting results in a timely fashion.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top