Reputation: 370
How can you search the Wikidata SPARQL query service for a record whose official website (property P856) matches a specific value?
For example, fetch all records whose official website is "https://www.google.com". This should return Q95 and Q9366, but instead the following query yields no results:
SELECT ?entity
WHERE {
?entity wdt:P856 "https://www.google.com"
}
I can get it to work with a FILTER, but it's very slow:
SELECT ?entity
WHERE {
?entity wdt:P856 ?url FILTER(str(?url)="https://www.google.com")
}
Using FILTER seems very inefficient. Why doesn't the first query work?
Upvotes: 0
Views: 341
Reputation: 9434
Look at the values you get from this query --
SELECT ?entity ?value
WHERE
{
?entity wdt:P856 ?value
}
LIMIT 25
Note that they're all wrapped in <>
, marking them as URIs. To compare a URI with a string literal, you must change the URI to a string, as you are doing in the second query.
In other words -- there are no entities with an official website of "https://www.google.com"
, but there are some entities with an official website of <https://www.google.com>
.
Upvotes: 3