Search code examples
sparqldbpedia

Query returns no results when field is matched against string


That following resource http://dbpedia.org/page/Ulugh_Beg has a "foaf:name" field which has two values:

  • Beg, Ulugh
  • Ulugh Beg

Why then does this query return no results on http://dbpedia.org/sparql?

select ?article
where 
{
  ?article foaf:name "Ulugh Beg"
}

Solution

  • The value you see on http://dbpedia.org/page/Ulugh_Beg is an HTML rendering, and it doesn't always perfectly reflect the underlying RDF data. If you scroll to the bottom of that page, there are some Raw Data links where you can browse the data in actual RDF formats. For instance, if you grab the N3/Turtle version, you'll see

    dbpedia:Ulugh_Beg
      dc:description "Timurid ruler"@en , "Timurid ruler" ;
      foaf:givenName "Ulugh"@en ;
      foaf:name "Beg, Ulugh"@en , "Ulugh Beg"@en .
    

    The name has the language tag en. If you want to query by name like this, you'll need to include that. For instance:

    select ?person where {
      ?person foaf:name "Ulugh Beg"@en
    }
    

    SPARQL results