How to query Wikidata items using its labels?

前端 未结 4 590
逝去的感伤
逝去的感伤 2021-02-05 15:55

How can I query Wikidata to get all items that have labels contain a word? I tried this but didn\'t work; it retrieved nothing.

SELECT ?item ?itemLabel WHERE {
          


        
4条回答
  •  北荒
    北荒 (楼主)
    2021-02-05 16:27

    Following your question and the useful comments provided, I ended up with this query

    SELECT ?item ?itemLabel
    WHERE { 
      ?item rdfs:label ?itemLabel. 
      FILTER(CONTAINS(LCASE(?itemLabel), "city"@en)). 
    } limit 10
    

    For which I got those results

    item          itemLabel
    wd:Q515       city
    wd:Q7930989   city
    wd:Q15253706  city
    wd:Q532039    The Eternal City
    wd:Q1969820   The Eternal City
    wd:Q3986838   The Eternal City
    wd:Q7732543   The Eternal City
    wd:Q7737016   The Golden City
    wd:Q5119      capital city
    wd:Q1555      Guatemala City
    

    try it here

提交回复
热议问题