query-53f41af2317c5942ee98f53849b1351e

rq turtle/ttl

Faster way to query sparql with labelsHi, I need to run SPARQL at wikidata endpoint using query that has a few labels in it, label query is very slow and inefficient, such as this, to find journalist that are born in Chicago it takes about 29 seconds, I have many other query that also time out. 10 LIMIT } } )"en" = )?valLabel(lang(FILTER ?valLabel label:rdfs ?val { OPTIONAL . ?ent ?wdtProperty2 ?val .?wdtProperty2 directClaim:wikibase ;en@"place of birth" ?labelB2 ?wdProperty2 } altLabel:skos label:rdfs { ?labelB2 VALUES .en@"Chicago" ?label2 ?ent } altLabel:skos label:rdfs { ?label2 VALUES ]. en@'journalist' ?label1 [ P106:wdt|P31:wdt ?val } altLabel:skos label:rdfs { ?label1 VALUES { WHERE ?valLabel ?val ?wdtProperty ?ent DISTINCT SELECT I have already read the query optimization page on searching the label, using the example given, it's still very slow, the below query still takes 11 seconds to return result, it's not usable for real world application. } )"Frankfurt" ,?label(CONTAINS FILTER .?label label:rdfs ?item } .title:mwapi apiOutputItem:wikibase ?item ."max" gsrlimit:mwapi ;"inlabel:Frankfurt" gsrsearch:mwapi ;"search" generator:mwapi ;"Generator" api:wikibase ;"www.wikidata.org" endpoint:wikibase serviceParam:bd { mwapi:wikibase SERVICE { WHERE ?label ?item SELECT then return the result back to php application and display it to the browser. https://query.wikidata.org/sparql it seems fast, so what I am thinking is using this method to convert all name to Q ID first then query the sparql using only Q id. is this the best solution ? What are the best practices ? I am developing a php application that will call the wikidata sparql endpoint at https://phabricator.wikimedia.org/source/tool-name-to-q/repository/master/Then I found a toolforge tool that convert the name to Q id at 15:17, 12 November 2020 (UTC)) talk (Dipsacus fullonum in the query. --(Q1297)Chicago directly instead of searching for a property with the label or alias "place of birth"@en. And note that the search for an item with the label or alias "Chicago"@en has 107 results. If you want all places of birth with a that name, that is the right things to do. If you instead want to find persons born in the biggest city of Illinois, USA, you should instead use (P19)place of birth But never the less, it would be preferable to use 14:56, 12 November 2020 (UTC)) talk (Dipsacus fullonum. --Wikidata:Request a query a certain word. That is a much harder thing to do fast. I don't know the tool you talk about but I suggest you just optimize the query. It can be much, much faster. You can ask for help at contains searches labels which Wikidata:SPARQL query service/query optimization#Searching labelsHi. In the first query above you search for exact label and alias names. That isn't slow. The query is slow for other reasons (lots of triples with very many results in many variables you don't use for anything). The second query from 15:31, 12 November 2020 (UTC)) talk (Esia1688hi, but I don't know why this query to know the Barack obama date of birth, it will time out, I query the label separately, there are only 3 result for label of Barack Obama and 2 result for date of birth, so the result set is small. --

Use at

PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT DISTINCT ?ent ?wdtProperty ?val ?valLabel WHERE { 

  ?ent rdfs:label|skos:altLabel "Barack Obama"@en. 
  ?wdProperty1 rdfs:label|skos:altLabel "date of birth"@en; 
               wikibase:directClaim ?wdtProperty1. 

  ?ent ?wdtProperty1 ?val .
}

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v1("?ent"):::projected v4("?val"):::projected v2("?wdProperty1") v3("?wdtProperty1") c2([sBarack Obama^^<http://www.w3.org/1999/02/22-rdf-syntax-ns#langString>"]):::literal c4([sdate of birth^^<http://www.w3.org/1999/02/22-rdf-syntax-ns#langString>"]):::literal subgraph union0[" Union "] subgraph union0l[" "] style union0l fill:#abf,stroke-dasharray: 3 3; v1 --"skos:altLabel"--> c2 end subgraph union0r[" "] style union0r fill:#abf,stroke-dasharray: 3 3; v1 --"rdfs:label"--> c2 end union0r <== or ==> union0l end subgraph union1[" Union "] subgraph union1l[" "] style union1l fill:#abf,stroke-dasharray: 3 3; v2 --"skos:altLabel"--> c4 end subgraph union1r[" "] style union1r fill:#abf,stroke-dasharray: 3 3; v2 --"rdfs:label"--> c4 end union1r <== or ==> union1l end v2 --"wikibase:directClaim"--> v3 v1 -->v3--> v4