Reputation: 3450
I'm trying to query Wikidata using entity names. My goal is to get the Wikidata ID of the entity. Right now I have something like:
SELECT ?item
WHERE {
?item rdfs:label "name_of_thing"@en
}
and while this usually gets the job done I also want to check whether the label is contained in the alternative names on Wikidata.
For example, if I replace "name_of_thing"
with "Philippines AirAsia"
then I don't get any results, but the reason why is because "AirAsia Philippines"
is the proper name of the entry, with "Philippines AirAsia"
contained in the "Also known as" column in the Wikidata page.
I want to query the page and if the first fetch fails then check whether the name is contained in the "Also known as" column. How should I go about doing this? Thanks.
Upvotes: 3
Views: 945
Reputation: 16394
The pipe operator works for me:
SELECT ?item ?prefLabel WHERE {
VALUES ?prefLabel { "AirAsia Philippines"@en }
?item rdfs:label|skos:altLabel ?prefLabel
}
Upvotes: 1