Arash.m.h
Arash.m.h

Reputation: 355

SPARQL Query with filtering over an integer

I am writing a very straightforward sparql query that filter an integer value.

I figured it out through this tutorial I know that Wikipedia Id = 856 is for apple_inc but this query doesn’t give any results, I don’t know what I am missing. Any help would be appreciated.

select ?uri where {?uri <http://dbpedia.org/ontology/wikiPageID> ?id. FILTER regex(?id, "856"^^xsd:integer, "i")}

Upvotes: 1

Views: 1035

Answers (2)

Joshua Taylor
Joshua Taylor

Reputation: 85843

There's no reason to use filter here at all. Conceptually a filter has to select all the page id triples, then filter out all but the right one. (Implementations should make the process more efficient though.)

It's much clearer to just put the value right in the query and skip the filter altogether:

select ?uri where {
  ?uri <http://dbpedia.org/ontology/wikiPageID> 856
} 

Upvotes: 2

Andi Keikha
Andi Keikha

Reputation: 1316

You should write it like this:

select ?uri where {?uri <http://dbpedia.org/ontology/wikiPageID> ?id. FILTER (?id=856)}

Upvotes: 1

Related Questions