Querying: Difference between revisions

From ottgaz.org
Jump to navigation Jump to search
Line 13: Line 13:


=== Label ===
=== Label ===
All items that are vilayets, as well as their English language label:
All items that are vilayets, as well as their English language label. [https://ottgaz.org/query/#PREFIX%20wd%3A%20%3Chttps%3A%2F%2Fottgaz.org%2Fentity%2F%3E%0APREFIX%20wdt%3A%20%3Chttps%3A%2F%2Fottgaz.org%2Fprop%2Fdirect%2F%3E%0A%0ASELECT%20%3Fvilayet%20%3FvilayetLabel%0AWHERE%20%0A%7B%0A%20%20%3Fvilayet%20wdt%3AP6%20wd%3AQ5%20.%20%0A%20%20optional%20%7B%20%0A%20%20%20%20%20%3Fvilayet%20rdfs%3Alabel%20%3FvilayetLabel%0A%20%20%20%20%20filter%20langMatches%28lang%28%3FvilayetLabel%29%2C%20%22en%22%29%0A%20%20%20%7D%0A%7D run]


  SELECT ?vilayet ?vilayetLabel
  SELECT ?vilayet ?vilayetLabel

Revision as of 17:52, 30 September 2022

Run SPARQL queries via the Ottgaz Query Service.

Remember: SPARQL is currently case sensitive, as elastic search is disabled in wikibase.cloud.

Namespace

Declare these namespaces at the start of every query:

PREFIX wd: <https://ottgaz.org/entity/>
PREFIX wdt: <https://ottgaz.org/prop/direct/>

Sample queries

Label

All items that are vilayets, as well as their English language label. run

SELECT ?vilayet ?vilayetLabel
WHERE 
{
  ?vilayet wdt:P6 wd:Q5 . 
  optional { 
     ?vilayet rdfs:label ?vilayetLabel
     filter langMatches(lang(?vilayetLabel), "en")
   }
}