Open main menu

Wikidata talk:SPARQL query service

Contents

Adding multiple identifiers to a URL in a SPARQL queryEdit

Following the description on Getting_urls_out_of_Wikidata_properties I added a link to a SPARQL query to the ASCL library catalogue based on the National_Thesaurus_for_Author_Names_ID (map view ; y622hrrw). The query works fine:

SELECT ?item ?itemLabel ?image ?placeofbirth ?placeofbirthLabel ?coord ?dob ?sitelink ?clickable_url WHERE {
  ?item wdt:P27 ?nationality.
  wd:Q27394 wdt:P527 ?nationality.
  ?item wdt:P21 wd:Q6581072.
  ?item wdt:P31 wd:Q5.
  ?item (wdt:P106/wdt:P279*) wd:Q36180.
  ?sitelink schema:about ?item; 
  schema:isPartOf <https://en.wikipedia.org/> .
  OPTIONAL {
    ?item wdt:P19 ?placeofbirth.
    ?placeofbirth wdt:P625 ?coord.
    ?item wdt:P1006 ?National_Thesaurus_for_Author_Names_ID.
    BIND(IRI(CONCAT("http://catalogue.leidenuniv.nl/primo_library/libweb/action/dlSearch.do?vid=UBL_V1&institution=UBL&tab=leiden&search_scope=lib_asc&query=any,contains,", ?National_Thesaurus_for_Author_Names_ID)) AS ?clickable_url)
  }
  OPTIONAL { ?item wdt:P18 ?image. }
  OPTIONAL { ?item wdt:P569 ?dob. }
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}

Try it!

I would like to modify the SPARQL query to make it search for two identifiers in the ASCL library catalogue (f.e. the National_Thesaurus_for_Author_Names_ID and the Library_of_Congress_authority_ID), but I don’t know how:  

The link with one identifier: http://catalogue.leidenuniv.nl/primo_library/libweb/action/dlSearch.do?vid=UBL_V1&institution=UBL&tab=leiden&search_scope=lib_asc&query=any,contains,‪071124152‬ (National_Thesaurus_for_Author_Names_ID: ‪071124152‬)

  The link with two identifiers: http://catalogue.leidenuniv.nl/primo_library/libweb/action/dlSearch.do?vid=UBL_V1&institution=UBL&tab=leiden&search_scope=lib_asc&query=any,contains,071124152%20OR%2080037754 (National_Thesaurus_for_Author_Names_ID: ‪071124152‬ ; Library_of_Congress_authority_ID: n80037754)

  Complicating factor: the query to the library catalogue should  only search the numbers of the Library of Congress identifier not the preceding letters (thus ‪80037754‬ and not n80037754))

Thanks in advance and kind regards, Walkuraxx (talk) 07:07, 7 April 2019 (UTC)

@Walkuraxx: This, I think - presuming the initial character for the LoC is always "n".
SELECT ?item ?itemLabel ?image ?placeofbirth ?placeofbirthLabel ?coord ?dob ?sitelink ?clickable_url WHERE {
  ?item wdt:P27 ?nationality.
  wd:Q27394 wdt:P527 ?nationality.
  ?item wdt:P21 wd:Q6581072.
  ?item wdt:P31 wd:Q5.
  ?item (wdt:P106/wdt:P279*) wd:Q36180.
  ?sitelink schema:about ?item; 
  schema:isPartOf <https://en.wikipedia.org/> .
  OPTIONAL {
    ?item wdt:P19 ?placeofbirth.
    ?placeofbirth wdt:P625 ?coord.
    ?item wdt:P1006 ?National_Thesaurus_for_Author_Names_ID.
    ?item wdt:P244 ?Library_of_Congress_authority_ID.
    BIND(IRI(CONCAT("http://catalogue.leidenuniv.nl/primo_library/libweb/action/dlSearch.do?vid=UBL_V1&institution=UBL&tab=leiden&search_scope=lib_asc&query=any,contains,", ?National_Thesaurus_for_Author_Names_ID, "OR",strafter(?Library_of_Congress_authority_ID,"n"))) AS ?clickable_url)
  }
  OPTIONAL { ?item wdt:P18 ?image. }
  OPTIONAL { ?item wdt:P569 ?dob. }
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}
Try it! --Tagishsimon (talk) 01:14, 8 April 2019 (UTC)
@Tagishsimon: thank you very much. This is a big step forward. The majority of the LOC identifiers are now searchable in the ASCL catalogue together with the NTA. The LOC uses all in all four different prefixes for names: n,nb,nr,no. Any idea how to fix that? Kind regards, Walkuraxx (talk) 19:16, 8 April 2019 (UTC)
@Walkuraxx: This should do it. (Also, short variable names next time, please :)
SELECT ?item ?itemLabel ?image ?placeofbirth ?placeofbirthLabel ?coord ?dob ?sitelink ?clickable_url WHERE {
  ?item wdt:P27 ?nationality.
  wd:Q27394 wdt:P527 ?nationality.
  ?item wdt:P21 wd:Q6581072.
  ?item wdt:P31 wd:Q5.
  ?item (wdt:P106/wdt:P279*) wd:Q36180.
  ?sitelink schema:about ?item; 
  schema:isPartOf <https://en.wikipedia.org/> .
  OPTIONAL {
    ?item wdt:P19 ?placeofbirth.
    ?placeofbirth wdt:P625 ?coord.
    ?item wdt:P1006 ?National_Thesaurus_for_Author_Names_ID.
    ?item wdt:P244 ?Library_of_Congress_authority_ID.
    bind(if(strstarts(?Library_of_Congress_authority_ID,"nb"),strafter(?Library_of_Congress_authority_ID,"nb"),if(strstarts(?Library_of_Congress_authority_ID,"nr"),strafter(?Library_of_Congress_authority_ID,"nr"),if(strstarts(?Library_of_Congress_authority_ID,"no"),strafter(?Library_of_Congress_authority_ID,"no"),strafter(?Library_of_Congress_authority_ID,"n")))) as ?loc)
    BIND(IRI(CONCAT("http://catalogue.leidenuniv.nl/primo_library/libweb/action/dlSearch.do?vid=UBL_V1&institution=UBL&tab=leiden&search_scope=lib_asc&query=any,contains,", ?National_Thesaurus_for_Author_Names_ID, "OR",?loc)) AS ?clickable_url)
  }
  OPTIONAL { ?item wdt:P18 ?image. }
  OPTIONAL { ?item wdt:P569 ?dob. }
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}
Try it! --Tagishsimon (talk) 19:25, 8 April 2019 (UTC)
@Tagishsimon: you made my day. Thank you very much! (I try to be more precise next time). Kind regards, Walkuraxx (talk) 17:55, 9 April 2019 (UTC)

Adding multiple URLs to a SPARQL queryEdit

Following the description on Getting_urls_out_of_Wikidata_properties I added a link to a SPARQL query to the ASCL library catalogue based on the National_Thesaurus_for_Author_Names_ID (map view ; y622hrrw). The query works fine:

SELECT ?item ?itemLabel ?image ?placeofbirth ?placeofbirthLabel ?coord ?dob ?sitelink ?clickable_url WHERE {
  ?item wdt:P27 ?nationality.
  wd:Q27394 wdt:P527 ?nationality.
  ?item wdt:P21 wd:Q6581072.
  ?item wdt:P31 wd:Q5.
  ?item (wdt:P106/wdt:P279*) wd:Q36180.
  ?sitelink schema:about ?item; 
  schema:isPartOf <https://en.wikipedia.org/> .
  OPTIONAL {
    ?item wdt:P19 ?placeofbirth.
    ?placeofbirth wdt:P625 ?coord.
    ?item wdt:P1006 ?National_Thesaurus_for_Author_Names_ID.
    BIND(IRI(CONCAT("http://catalogue.leidenuniv.nl/primo_library/libweb/action/dlSearch.do?vid=UBL_V1&institution=UBL&tab=leiden&search_scope=lib_asc&query=any,contains,", ?National_Thesaurus_for_Author_Names_ID)) AS ?clickable_url)
  }
  OPTIONAL { ?item wdt:P18 ?image. }
  OPTIONAL { ?item wdt:P569 ?dob. }
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}

Try it!

I would now like to add a second url to my query, if possible. But I dont’ know how.

  Link 1: http://catalogue.leidenuniv.nl/primo_library/libweb/action/dlSearch.do?vid=UBL_V1&institution=UBL&tab=leiden&search_scope=lib_asc&query=any,contains, ‪071124152 ; ‬ National_Thesaurus_for_Author_Names_ID: ‪071124152‬

  Link 2 https://zoeken.beeldengeluid.nl/search/program?program.terms=nisv.person/person.name:103775 ; GTAA_ID: 103775  

[Link 3: http://d-nb.info/gnd/118718169 ; GND_ID: 118718169]

Thanks in advance and kind regards Walkuraxx (talk) 06:52, 7 April 2019 (UTC)

link from data access pageEdit

Hey :)

Thanks for starting this. Can you please link/incorporate in Wikidata:Data access? Thanks a lot! --Lydia Pintscher (WMDE) (talk) 10:58, 16 September 2015 (UTC)

@Lydia Pintscher (WMDE): I have added a link, diff Jheald (talk) 09:42, 17 September 2015 (UTC)
Thanks! --Lydia Pintscher (WMDE) (talk) 22:11, 17 September 2015 (UTC)

Logo?Edit

How about a logo/icon for SPARQL query service? To make it easy to remember/distinguish from WDQ, Reasonator etc. The wikidata logo with a (white?) question mark?

--Atlasowa (talk) 14:43, 23 September 2015 (UTC)

@Atlasowa: Thanks for the suggestion! This was turned into phab:T140577 and is being discussed there. --Deskana (WMF) (talk) 04:25, 20 July 2016 (UTC)
@Deskana (WMF): Thank you! --Atlasowa (talk) 19:39, 20 July 2016 (UTC)

Embed in map tutorialEdit

Is there a tutorial that explains how to embed a query in the wikimedia map like this:

https://query.wikidata.org/embed.html#%23%20Points%20culminants%20par%20d%C3%A9partement%20fran%C3%A7ais%0A%23defaultView%3AMap%0ASELECT%20DISTINCT%20%3Fitem%20%3FitemLabel%20%3Fculminant%20%3FculminantLabel%20%3Faltitude%20%3FpartieDeLabel%20%3Fcoordinate%20%3Fimage%20%28concat%28str%28floor%28%3Faltitude%2F500%29%2a500%29%2C%20%27-%27%2Cstr%28ceil%28%3Faltitude%2F500%29%2a500%29%29%20%20as%20%3Flayer%29%0AWHERE%20%7B%0A%0A%20%20%3Fitem%20wdt%3AP31%2Fwdt%3AP279%2a%20wd%3AQ6465%20.%0A%20%20%3Fitem%20p%3AP31%20%3Fdep%0A%20%20FILTER%20NOT%20EXISTS%20%7B%20%3Fitem%20p%3AP576%20%3Fx%20%7D%20%0A%20%20FILTER%20NOT%20EXISTS%20%7B%20%3Fitem%20p%3AP582%20%3Fx%20%7D%20%0A%20%20FILTER%20NOT%20EXISTS%20%7B%20%3Fdep%20pq%3AP582%20%3Fx%20%7D%20%20%0A%20%20OPTIONAL%7B%0A%20%20%20%20%3Fitem%20wdt%3AP610%20%3Fculminant%20%0A%20%20%20%20OPTIONAL%7B%20%3Fculminant%20wdt%3AP2044%20%3Faltitude%20%7D%0A%20%20%20%20OPTIONAL%7B%20%3Fculminant%20wdt%3AP361%20%3FpartieDe%20%7D%0A%20%20%20%20OPTIONAL%7B%20%3Fculminant%20wdt%3AP625%20%3Fcoordinate%20%7D%0A%20%20%20%20optional%20%7B%20%3Fculminant%20wdt%3AP18%20%3Fimage%20%7D%0A%20%20%7D%0A%20%0A%0A%20%20SERVICE%20wikibase%3Alabel%20%7B%20bd%3AserviceParam%20wikibase%3Alanguage%20%22fr%22.%20%7D%0A%20%20%0A%7D%20ORDER%20BY%20DESC%28%3Faltitude%29

Thanks! --Tobias1984 (talk) 10:01, 11 September 2016 (UTC)

Actually I got it to work now. This is a nice example that shows how to put the labels into the layer-bar:
#Armenian Sister City
#defaultView:Map
SELECT ?item ?itemLabel ?sisterCity ?sisterCityLabel ?coordinate ?layer
WHERE {
  ?item wdt:P17 wd:Q399 .
  ?item wdt:P190 ?sisterCity .
  ?sisterCity wdt:P625 ?coordinate .
  ?sisterCity wdt:P17 ?sisterCountry .
  SERVICE wikibase:label { 
    bd:serviceParam wikibase:language "en" . 
    ?item rdfs:label ?itemLabel .
    ?sisterCity rdfs:label ?sisterCityLabel .
	?sisterCountry rdfs:label ?layer .
  }
}

Try it!

or the link to the map:

https://query.wikidata.org/embed.html#%23Armenian%20Sister%20City%0A%23defaultView%3AMap%0ASELECT%20%3Fitem%20%3FitemLabel%20%3FsisterCity%20%3FsisterCityLabel%20%3Fcoordinate%20%3Flayer%0AWHERE%20{%0A%20%20%3Fitem%20wdt%3AP17%20wd%3AQ399%20.%0A%20%20%3Fitem%20wdt%3AP190%20%3FsisterCity%20.%0A%20%20%3FsisterCity%20wdt%3AP625%20%3Fcoordinate%20.%0A%20%20%3FsisterCity%20wdt%3AP17%20%3FsisterCountry%20.%0A%20%20SERVICE%20wikibase%3Alabel%20{%20%0A%20%20%20%20bd%3AserviceParam%20wikibase%3Alanguage%20%22en%22%20.%20%0A%20%20%20%20%3Fitem%20rdfs%3Alabel%20%3FitemLabel%20.%0A%20%20%20%20%3FsisterCity%20rdfs%3Alabel%20%3FsisterCityLabel%20.%0A%09%3FsisterCountry%20rdfs%3Alabel%20%3Flayer%20.%0A%20%20}%0A}%0A

--Tobias1984 (talk) 19:42, 12 September 2016 (UTC)

How to link to textual/ JSON data?Edit

Let's say I want a script to retrieve the data from a query. So I don't want to click in a browser to select the download format for my query, but instead want to construct a URL to get the JSON/ CSV directly. How is this possible? Given the way the Javascript is minimised, I can't see what URL my browser is calling to get the data. Thanks in advance for any help, MartinPoulter (talk) 14:17, 13 September 2016 (UTC)

the URL is: https://query.wikidata.org/bigdata/namespace/wdq/sparql?format=json&query=YOUR_QUERY --Pasleim (talk) 14:26, 13 September 2016 (UTC)
A delayed thank-you to User:Pasleim. Cheers, MartinPoulter (talk) 16:25, 26 October 2016 (UTC)

Wikidata Query OutputEdit

Can I choose the output format of the GUI tool? In addition to XML and JSON, can the GUI tool also output wiki formatted data (tables, lists, etc.) that I can simply paste into a wiki page? Thanks! SharkD (talk) 03:39, 24 March 2017 (UTC)

missing linksEdit

How often is the data updated in wikidata query?Edit

Hi, I tried to use the query, it states the query is updated 10 seconds ago. How long does the query reflect the edit I made in wikidata? --Napoleon.tan (talk) 12:58, 29 April 2017 (UTC)

Usually about every three or four seconds, but it varies. 10 seconds is a slightly longer lag than usual, I think. Jheald (talk) 22:16, 29 April 2017 (UTC)

View from an external websiteEdit

Moin Moin at all, I've there a query, which I have linked to an external website via iframe.

SELECT ?Kirche ?KircheLabel ?geographische_Koordinaten ?GeoNames_ID ?Bild WHERE {
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],de". }
  ?Kirche wdt:P31 wd:Q16970.
  ?Kirche wdt:P131 wd:Q23787499.
  OPTIONAL { ?Kirche wdt:P625 ?geographische_Koordinaten. }
  OPTIONAL { ?Kirche wdt:P1566 ?GeoNames_ID. }
  OPTIONAL { ?Kirche wdt:P18 ?Bild. }
}
LIMIT 100

Try it!

Now I don't want to have the view as a table, but directly the "Image Grid". Is there a parameter in iframe that I get directly "Image Grid"? Thanks in advance --Crazy1880 (talk) 20:44, 3 November 2017 (UTC)

No itemsEdit

I am trying to create this list and it brings a few names on the list generated on Wikidata Query.

However, when I copy the code to Wikipedia, it says there is "no items". Am I doing something wrong?—Teles «Talk to me˱M @ C S˲» 15:22, 2 December 2017 (UTC)

Try ?item instead of ?singer
--- Jura 15:25, 2 December 2017 (UTC)
@Jura1: This way?. Still the same.—Teles «Talk to me˱M @ C S˲» 15:32, 2 December 2017 (UTC)
I saw your edit there and ListeriaBot just edited the page. Thanks!!—Teles «Talk to me˱M @ C S˲» 15:47, 2 December 2017 (UTC)

SPARQL query service versus Wikidata QueryEdit

It seems like various places in Wikidata documentation call the tool at https://query.wikidata.org/ the "SPARQL query service", "Wikidata Query", and "Wikidata Query service". Do all of these names refer to the same tool? Blue Rasberry (talk) 20:20, 8 March 2018 (UTC)

Proposed moveEdit

Propose move Wikidata:SPARQL query service -> Wikidata:Wikidata Query Service

The name for this tool is "Wikidata Query Service". Here are some use instances of that name:

I am not aware of any publication preferring "SPARQL query service" as the name for this interface. This is a proper noun so I favor capitalizing every letter as some of these sources do.

I do not know how moves work on Wikidata. I am posting here then asking for admin support. Blue Rasberry (talk) 17:46, 9 April 2018 (UTC)

Ah - I see there's a lot of stuff sitting around under the top level page, including translations etc. We probably do want redirects though. Is there a tool that admins have access to for mass renaming like that? ArthurPSmith (talk) 08:30, 10 April 2018 (UTC)
@MichaelSchoenitzer: Your proposal is best. Blue Rasberry (talk) 21:01, 1 August 2018 (UTC)

Incorrect name propagating at Wikimedia CommonsEdit

At Wikimedia Commons I proposed a rename of a category containing images of output from this tool. Commons is calling this service's output the "Wikidata SPARQL data". I see this as incorrect and a result of the inconsistent use of the name here. I prefer "Wikidata Query Service" and to say that anything from it is "Wikidata Query Service output" or a "Wikidata Query Service data visualization". I appreciate anyone who can comment in Wikimedia Commons on what to call the illustrative image files which people are collecting to talk about this tool. Blue Rasberry (talk) 20:18, 8 August 2018 (UTC)

@Bluerasberry: Over time there have been a number of Query Services against data from Wikidata, including Magnus's original Wikidata Query (WDQ), and various off-site services run against local replications of Wikidata. Hence the original emphasis that this was a (the?) SPARQL query service, as opposed to Magnus's service which used its own syntax, or other services offering other query APIs. Jheald (talk) 21:26, 9 August 2018 (UTC)
@Jheald: The service at query.wikidata.org is the one that I identify as default and native.
I see two options -
  1. Keep this page named "SPARQL query service"
    1. This page remains named "SPARQL query service" and gives an overview of the many Wikidata tools which perform SPARQL queries
    2. We create a new page called "Wikidata Query Service" and make that the main documentation page for the particular tool at query.wikidata.org
  2. Rename this page to "Wikidata Query Service"
    1. Create a new page called "Wikidata tools for SPARQL queries"; put all content not related to the Wikidata Query Service there
    2. Reserve this page only for documenting the "Wikidata Query Service" at query.wikidata.org
Do you see other options? What do you prefer? Blue Rasberry (talk) 21:36, 9 August 2018 (UTC)

Get rid of tag cloudEdit

How do you get rid of the tag cloud from the default result display? This is just a waste of space and distracting. --Bamyers99 (talk) 22:23, 23 May 2018 (UTC)

We are reverting it. The change will be deployed soon. Then it will be gone. Sorry for the trouble. It should not have gone out like this. --Lydia Pintscher (WMDE) (talk) 08:32, 24 May 2018 (UTC)

Problems with embadding Commons Creator page on my Wikidata editEdit

Hi there,

if've created my Wikidata edit here: https://www.wikidata.org/wiki/Q54825941 but there is a misstake "This property is generally expected to contain only a single value." The help page doesn't help me. Can s.o. say me how to fix this? Thank you. --Taxiarchos228 (talk) 09:29, 6 June 2018 (UTC)

WikibooksEdit

There's quite an extensive training package on SPAQRL being built by user:HenkvD over on English-Wikibooks: https://en.wikibooks.org/wiki/SPARQL

Can/should that be prominently featured on the page Wikidata:SPARQL query service/Wikidata Query Help? Wittylama (talk) 13:24, 7 February 2019 (UTC)

@Lea Lacroix (WMDE): what do you think? Smalyshev (WMF) (talk) 19:00, 7 February 2019 (UTC)

Name for the visualization suite?Edit

I am trying to identify some documentation about the WDQS where I need to describe its features, and I want to separate the query function from the visualization function. The point is to describe these as separate interrelated features.

I think that in the wiki community we are all calling the query + visualization as the WDQS. Where is the specific documentation on just the visualization options? What do we call our package of visualizations? The Wikidata Visualization Suite? Thanks if anyone can either point to documentation or

speak up if you think visualization documentation does not exist!

Thanks Blue Rasberry (talk) 14:39, 21 July 2019 (UTC)

  Resolved

It is Wikidata:SPARQL query service/Wikidata Query Help/Result Views, identified at special:diff/983392210. Wow, it is better developed than I expected! I will look around to see how easy it is to navigate to this page and think about why I missed it. Blue Rasberry (talk) 13:15, 22 July 2019 (UTC)

Query timeout limit for important query reachedEdit

Hi! I need to perform this query in order to update our 32 Kinostarts pages. Here is for example Kinostarts 2019. Since August I've always been getting a timeout. Why is this the case? Any suggestions what to do? --Jobu0101 (talk) 21:55, 10 August 2019 (UTC)

Hallo @Jobu0101:

das Problem ("java.util.concurrent.TimeoutException") ist der Stern-Operator ("/wdt:P279*") für eine beliebige (Null bis unendlich) Anzahl von Unterklassen von "Film":

[...] Die Lösung: ?objekt wdt:P31/wdt:P279* ?klasse. Dies heißt, dass es eine "Instanz von" und dann eine beliebige Anzahl von "Unterklassen von" Aussagen zwischen dem Datenobjekt und der Klasse.

?kunstwerk wdt:P31/wdt:P279* wd:Q838948. # Instanz von einer beliebigen Unterklasse von Kunstwerk

Siehe auch d:Wikidata:Contact_the_development_team#Query_that_timeouts,_I_really_don't_understand_why


Mein Anfangsverdacht war, dass die Query möglicherweise in eine Endlosschleife läuft, wenn A Unterklasse von B ist und B Unterklasse von A und in der Baumstruktur für Filme und deren Unterklassen irgendwo so eine Endlosschleife eingebaut wurde.

Diesen Verdacht konnte ich allerdings durch die Baumansicht der Klasse Film (vorerst) nicht bestätigen:


Lässt man in der Query "/wdt:P279*" weg, so erhält man alle Filme, aber nicht Unterklassen davon.

Beispielsweise fehlt

  • d:Q18517638 ... ist ein: "Animationsfilm"/"3D-Film" als Unterklasse von "Film".

Gibt man hingegen "/wdt:P279+" an, so erhält nur die Unterklassen von "Film", nicht aber die Instanzen von "Film" selbst.


Eine Lösungsmöglichkeit ist daher aus meiner Sicht beides mittels UNION zu kombinieren, also

  
  {
    ?film wdt:P31 wd:Q11424 .
  } 
    UNION 
  {
    ?film wdt:P31/wdt:P279+ wd:Q11424 .
  }

Die Query pro Jahr würde also wie folgt lauten:

SELECT DISTINCT ?film ?release ?filmLabel WHERE {
  { ?film wdt:P31 wd:Q11424. }
  UNION
  { ?film (wdt:P31/(wdt:P279+)) wd:Q11424. }
  ?film p:P577 ?release_statement.
  ?release_statement (psv:P577/wikibase:timePrecision) 11 ;
    ps:P577 ?release.
  FILTER((YEAR(?release)) = 2019 )
  ?release_statement pq:P291 wd:Q183.
  FILTER(NOT EXISTS { ?release_statement wikibase:rank wikibase:DeprecatedRank. })
  FILTER(NOT EXISTS { ?release_statement pq:P400 ?platform. })
  FILTER(NOT EXISTS { ?release_statement pq:P437 ?distribution. })
  FILTER(NOT EXISTS { ?film wdt:P31 wd:Q506240. })
  FILTER(NOT EXISTS { ?film wdt:P31 wd:Q21191270. })
  SERVICE wikibase:label { bd:serviceParam wikibase:language "de". }
}
ORDER BY (?release) (?filmLabel)

Try it!

https://w.wiki/779

Zusätzlich zur bisherigen Variante habe ich hier auch ein "DISTINCT" im SELECT ergänzt, um keine Mehrfacheinträge zu erhalten.


Für die aktuellen Kinostarts sieht das wie folgt aus:

SELECT DISTINCT ?film ?release ?filmLabel WHERE {
  { ?film wdt:P31 wd:Q11424. }
  UNION
  { ?film (wdt:P31/(wdt:P279+)) wd:Q11424. }
  ?film p:P577 ?release_statement.
  ?release_statement (psv:P577/wikibase:timePrecision) 11 ;
    ps:P577 ?release.
  FILTER((?release >= "2019-08-15"^^xsd:dateTime) && (?release < "2019-08-29"^^xsd:dateTime))
  ?release_statement pq:P291 wd:Q183.
  FILTER(NOT EXISTS { ?release_statement wikibase:rank wikibase:DeprecatedRank. })
  FILTER(NOT EXISTS { ?release_statement pq:P400 ?platform. })
  FILTER(NOT EXISTS { ?release_statement pq:P437 ?distribution. })
  FILTER(NOT EXISTS { ?film wdt:P31 wd:Q506240. })
  SERVICE wikibase:label { bd:serviceParam wikibase:language "de". }
}
ORDER BY (?release) (?filmLabel)

Try it!

https://w.wiki/778

--M2k~dewiki (talk) 00:02, 15 August 2019 (UTC)


@M2k~dewiki: Vielen, vielen Dank! Ist das aber nicht merkwürdig, dass eine Vereinigung aus direkt film und +, welches mathematisch ja dasselbe wie * ist, so viel schneller bearbeitet wird? Gäbe es, wie von dir vermutet, eine Endlosschleife, so müsste diese doch auch bei + auftreten und zu einem Timeout führen, oder? --Jobu0101 (talk) 06:59, 15 August 2019 (UTC)

Hallo Jobu0101, darum war die Endlosschleife in den Film-Unterklassen ja auch nur eine Theorie, die nicht verifiziert werden konnte. Das Problem tritt auch in vielen (allen?) anderen Fällen mit dem Stern-Operator auf (nicht nur bei Filmen), so funktionieren auch die Beispiele aus dem Wikidata:SPARQL_tutorial/de#Instanzen_und_Klassen nicht (mehr?). Oder auch Wikidata:Contact_the_development_team#Query_that_timeouts,_I_really_don't_understand_why: Dort ist als Antwort zu finden You used "*". Daher hatte ich es ohne * versucht. Unklar ist auch, warum es bis Ende Juli noch funktioniert hat, dann aber nicht mehr. Eine Theorie wäre eine Umstellung der Software oder in der Konfiguration. In den meta:Tech/News/2019/31 Tech-News konnte ich allerdings keinen *unmittelbaren* Hinweis auf eine diesbezügliche Änderung finden (wenn, dann in einem größeren Paket/Update "versteckt"). --M2k~dewiki (talk) 10:36, 15 August 2019 (UTC)

wd:P27411 as resultEdit

Look at this query:

PREFIX p: <http://www.wikidata.org/prop/>
PREFIX v: <http://www.wikidata.org/prop/statement/>
PREFIX pq: <http://www.wikidata.org/prop/qualifier/>

SELECT ?cineplex ?film ?filmLabel (GROUP_CONCAT(DISTINCT(?country)) AS ?countries) (MIN(?release) AS ?release) (MIN(?grelease) AS ?grelease) WHERE {
  ?film wdt:P3077 ?cineplex .
  ?film p:P577 ?release_statement . ?release_statement psv:P577/wikibase:timePrecision "11"^^xsd:integer . ?release_statement v:P577 ?release .
  ?film p:P577 ?grelease_statement . ?grelease_statement psv:P577/wikibase:timePrecision "11"^^xsd:integer . ?grelease_statement v:P577 ?grelease . ?grelease_statement pq:P291 wd:Q183 .
  OPTIONAL{?film wdt:P495 ?country} .
  SERVICE wikibase:label { bd:serviceParam wikibase:language "de" }
}
GROUP BY ?cineplex ?film ?filmLabel
HAVING(year(?release)=1996 && year(?grelease)=1997 && day(?grelease)=30)

Try it!

Why do I not only get wd:Q27411 as result but also wd:P27411? I don't even know what wd:P27411 means. --Jobu0101 (talk) 07:00, 17 August 2019 (UTC)

@M2k~dewiki: Have you seen such a thing before? --Jobu0101 (talk) 07:01, 17 August 2019 (UTC)
Please also see Wikidata:Project_chat#References_to_non-existing_properties. --M2k~dewiki (talk) 14:40, 17 August 2019 (UTC)

simple query timeoutEdit

Hello, this

SELECT ?item ?itemLabel WHERE {
  ?item wdt:P31 wd:Q8054 .
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" . }
}

Try it!

hits 944k objects and presumably the label service is the reason for the timeout. Optimization via subsets however is not possible because any properties are too fine-grained (e.g. "found in taxon") or cannot be partitioned (external IDs). So how do I get a full list of protein objects and their labels? --SCIdude (talk) 14:36, 17 August 2019 (UTC)

You may concider using this query
SELECT ?item ?itemLabel WHERE {
  ?item wdt:P31 wd:Q8054 .
  ?item rdfs:label ?itemLabel. FILTER( LANG(?itemLabel)="en" )
}

Try it!

This will only work if all items have an english label (or your language). HenkvD (talk) 16:00, 17 August 2019 (UTC)
Runs without timeout, many thanks! I should put this solution on the optimization help page... --SCIdude (talk) 16:07, 17 August 2019 (UTC)
I think that this discussion is resolved and can be archived. If you disagree, don't hesitate to replace this template with your comment. SCIdude (talk) 16:45, 17 August 2019 (UTC)
Return to the project page "SPARQL query service".