Talk:Wikidata Query Service/Archive 1

More in Wikidata
See also suggestions at https://www.wikidata.org/wiki/Wikidata:SPARQL_query_service/suggestions

Duplicates and missing rows.
I am getting duplicates and missing rows. The duplicates seem to arise when the a value has been edited in the references. I do not know why the row is missing.

An example of a duplicate with the below SPARQL is "wd:Q21076992 * En røv bag øret" and the missing one is "wd:Q21083886 * Beton - historier fra skurvognen" from. I am also getting duplicate elements, e.g., "Ove Dahl, Ove Dahl (politi)". This seems also to be related to editing the value.

&mdash; Fnielsen (talk) 22:16, 15 October 2015 (UTC)
 * This issue has now been phabricated: https://phabricator.wikimedia.org/T116622 &mdash; Fnielsen (talk) 17:53, 26 October 2015 (UTC)

Scratch pad
A scratch pad beside the query box would be really convenient for quickly storing queries. The pgAdmin tool for managing Postgresql databases has had this feature for years (http://www.pgadmin.org/docs/1.6/images/query.png). The main use case is when people are experimenting with queries, they often need a temporary place (ends up being a text file) to store and compare variations of a query. This feature is an effective and "low-tech" alternative to providing multiple tabs for running queries.

Rename page and subpages
Should this page and subpages be titled 'Wikidata Query Service' ? John Vandenberg (talk) 02:37, 6 January 2016 (UTC)

Exceptions and timeouts using wikidata query service
Hi there,

there might be a problem with the current wikidata query service.

I try to write a tool, which can answer questions with given answer candidates. To accomplish this I match the children of a parsed entity from the question and match the found candidates with the given.

One way which is realy fast and effective is using queries like these:

But currently I am receiving timeouts or exceptions
 * This seems to be fine now. --Smalyshev (WMF) (talk) 18:43, 16 March 2016 (UTC)

"Execute" shortcut
Can we have a keyboard shortcut for the "Execute" button, please? --Magnus Manske (talk) 12:34, 9 March 2016 (UTC)

"Error:"
This one gives a blank error. Query via WDQ2SPARQL, converted from CLAIM[131:(TREE[1198][150][131])] AND CLAIM[31:(TREE[473972][][279])]. --Magnus Manske (talk) 18:39, 10 March 2016 (UTC)
 * I think that is the same as T127014 added as another example there. - Jan Zerebecki 14:32, 11 March 2016 (UTC)
 * Yes, there's something fishy there, I'm looking into it. Smalyshev (WMF) (talk) 18:43, 16 March 2016 (UTC)

Old short links are broken
Something seems to have happened recently that broke old short URLs, such as tinyurl.com/htb92er. You can see the query in the final URL, but it doesn't appear in the box, and can't be executed. Cheers, Bovlb (talk) 20:55, 22 March 2016 (UTC)
 * Which browser are you using? --Lydia Pintscher (WMDE) (talk) 15:58, 23 March 2016 (UTC)
 * That's an excellent question, so I did some testing. I observe this problem using Google Chrome Version 49.0.2623.87 (64-bit) on MacOS, and also using an unknown version of Google Chrome on Windows.  I do not observe it in Safari 8.0.7 or Firefox 35.0.1.  This used to work fine in Google Chrome, and I'm not aware that I've updated since it was working.  The expanded URL is  which also fails on Google Chrome.  I also observe the same behaviour using the new short link mechanism.  Looking in the JavaScript console, I see this error;

App.js:126 Uncaught TypeError: this._editor.registerCallback is not a function
 * UPDATE: As I did more testing, the problem disappeared, and old links started working in Chrome. Did you update the site?  Now the only console message I see is the relatively benign:

modernizr-2.8.3-respond-1.4.2.min.js:4 Mixed Content: The page at 'https://query.wikidata.org/#SELECT%20%3Fx%20%3FxLabel%20(MIN(%3Fdate)%20AS%…20%7D%0A%7D%20GROUP%20BY%20%3Fx%20%3FxLabel%20ORDER%20BY%20DESC(%3Fmindate)' was loaded over HTTPS, but requested an insecure font 'http://themes.googleusercontent.com/static/fonts/inconsolata/v5/BjAYBlHtW3CJxDcjzrnZCIbN6UDyHWBl620a-IRfuBk.woff'. This request has been blocked; the content must be served over HTTPS.
 * Cheers, Bovlb (talk) 16:16, 23 March 2016 (UTC)


 * It seems your browser cache had an old version of Editor.js which broke App.js

✅ (caching problem)

Query Logs
Hello,

would it be possible to get query logs of Wikidata (https://query.wikidata.org/)? I'd love to have them for my research project. Thanks a lot!

Fadirra (talk) 13:54, 31 March 2016 (UTC)

Missing ps/pq
It appears that the ps and pq prefixes are automatically added in the web interface, but not in https://query.wikidata.org/sparql?format=json&query= The automatic prefixes should be consistent. --Magnus Manske (talk) 20:28, 12 April 2016 (UTC)

WDQ2SPARQL query timeout
So I have a deceptively simple WDQ query: CLAIM[1435:(TREE[916475][][279])] AND CLAIM[131:(TREE[12526][][131])] which WDQ2SPARQL converts to SELECT ?item WHERE { ?item wdt:P1435 ?sub0. ?sub0 (wdt:P279)* wd:Q916475. ?item wdt:P131 ?sub1. ?sub1 (wdt:P131)* wd:Q12526 } Now, WDQ returns the ~1000 items in about 1 second. However, the SPARQL query (can't link to it, because tinyurl prevents me from saving the page) times out (still returns JSON though?). Is there anything you can do on the SPARQL engine or WDQ2SPARQL to improve this? I would like to retire WDQ sooner rather than later, but as long as auto-conversion essentially breaks functionality in downstream tools, I can't do it. --Magnus Manske (talk) 14:22, 13 April 2016 (UTC)
 * Unlimited path queries are usually the hardest for the engine in my experience. I'll look into what can be done to make it better, maybe use vertex-based search service instead... --Smalyshev (WMF) (talk) 22:19, 16 August 2016 (UTC)

Sardinia (Q1462) is not returned when I query for regions of Italy (Q16110)
This query should return 20 regions but instead only returns 19. Sardinia for some reason is missing. I checked and the relation Q16110 seems to be correctly declared for Sardinia.

This is my query

SELECT * WHERE {?resource wdt:P31 wd:Q16110.}

and this is the result

resource wd:Q1210 wd:Q1216 wd:Q1222 wd:Q1237 wd:Q1243 wd:Q1250 wd:Q1256 wd:Q1263 wd:Q1273 wd:Q1279 wd:Q1280 wd:Q1282 wd:Q1284 wd:Q1438 wd:Q1443 wd:Q1447 wd:Q1452 wd:Q1458 wd:Q1460

FrBailo (talk) 14:40, 13 April 2016 (UTC)
 * It's in wdq: http://wdq.wmflabs.org/api?q=claim[31:16110] --Magnus Manske (talk) 15:01, 13 April 2016 (UTC)
 * Returns 20 now so I assume it's ok. --Smalyshev (WMF) (talk) 22:21, 16 August 2016 (UTC)

Deleted items showing up in queries??
I've been trying to clean up self-instances (which are never logically justified) - the query is at tinyurl.com/jq5hduf - I cleaned up the ones I could, but the remaining 5 are all deleted items like Q21704990. Why is the query service returning deleted items in responses??? ArthurPSmith (talk) 16:03, 13 April 2016 (UTC)

deleted items show up repeatedly: SPARQL server with old cache/data
i have a problem on a couple of user subpages visible best here (notice all the ListeriaBot edits of size +321/-321). the 3 items Q1499520, Q1792416 and Q2560705 were deleted in April 2016, but -since May- are added and removed again and again.

Magnus explained to me that this is because one of the SPARQL servers has current data, but the other has outdated/old cache data (if i understood it correct, see in German).

Can somebody please fix this issue. Holger1959 (talk) 20:17, 4 August 2016 (UTC)
 * Smalyshev, maybe you can have a look? don't know if you noticed this. Holger1959 (talk) 15:48, 13 August 2016 (UTC)

Should be fine now, please ping me if it is still a problem. --Smalyshev (WMF) (talk) 22:08, 16 August 2016 (UTC)
 * thanks, seems ok now. Holger1959 (talk) 17:43, 1 November 2016 (UTC)

the problem returned, see diff from yesterday and notice that Q1590717 was deleted on 2016-04-30. Holger1959 (talk) 00:34, 3 January 2017 (UTC)
 * Looks like still old deletes not updated... Should be ok now. --Smalyshev (WMF) (talk) 01:50, 5 January 2017 (UTC)

Not properly synced?
SELECT ?item WHERE { ?item wdt:P131 wd:Q2107. ?item wdt:P1435 wd:Q15632117 } (can't link because tinyurl not allowed) should include Q16832586, but doesn't. I tried to purge the item, but no joy. WDQ finds it correctly. Any idea? --Magnus Manske (talk) 14:46, 28 April 2016 (UTC)

Updated data ?
Maybe I'm wrong but it seems that data are for now not updated. Results are different from those of WDQ. Is it an old version? Example: instances of sculpture (or subclass) with image WDQ results – SPARQL results. Is there somewhere a place to have live information about the service? Thanks --Shonagon (talk) 16:52, 28 April 2016 (UTC)
 * It is currently catching up and should be all good again soon. --Lydia Pintscher (WMDE) (talk) 09:37, 2 May 2016 (UTC)

Result on map : reverses lat/lon
Latitude and longitude are set in place of the other one.
 * Yeah there was a switch. Will be fixed tonight. --Lydia Pintscher (WMDE) (talk) 09:34, 2 May 2016 (UTC)

Translation
I cannot find the tool on Translatewiki. Is the UI not internationalized yet? Danmichaelo (talk) 06:53, 2 May 2016 (UTC)
 * It is not there yet. We've got the patch to make it happen but it still needs some manual work. --Lydia Pintscher (WMDE) (talk) 09:35, 2 May 2016 (UTC)

SPARQL endpoint is down?
I am rarely able to run any query for the past 18 hours or so. When I load the website, the status bar at the bottom eventually displays: "Data last updated: [unable to connect]". Is this possibly related to this task:? https://phabricator.wikimedia.org/T133566 —seav (talk) 04:12, 3 May 2016 (UTC)
 * Any idea what happened here? --Lydia Pintscher (WMDE) (talk) 08:41, 3 May 2016 (UTC)
 * Separate bug has been filed in Phabricator: https://phabricator.wikimedia.org/T134238 —seav (talk) 13:37, 3 May 2016 (UTC)

Way to get the precision of time values?
Is there a way to get the precision of time values using this service? —seav (talk) 01:58, 5 May 2016 (UTC)
 * See Wikibase/Indexing/RDF Dump Format. Matěj Suchánek (talk) 16:25, 3 October 2016 (UTC)

502 Bad Gateway
I constantly receive 502 bad gateway from spraql query service. I tried with 3 different browsers and it is still the same. Is the problem related with me or the server?
 * Seems like the server. I haven't been able to query it for some hours now. Danmichaelo (talk) 19:42, 7 May 2016 (UTC)
 * Found T134238. Danmichaelo (talk) 19:50, 7 May 2016 (UTC)

Completion, Plotting OSM relations in the results, instead of a single coordinate
It would be nice with completion on #defaultView:. Also, when doing the example query that returns rivers, it would be nice if there was an option in the Display drop-down that would show their associated OSM relations. Like with. On Wikipedia, clicking the inline map on that page will show the whole route. --Ysangkok (talk) 01:49, 13 May 2016 (UTC)

Blank error and search does not complete
I tried running the following query: PREFIX wdt: 

SELECT ?compound ?name ?smiles WHERE {

?compound wdt:P31 wd:Q11173 ;

rdfs:label ?name.

OPTIONAL {?item wdt:P233 ?smiles}

}

and the query runs, but after a few seconds the text ERROR: appears, but no message is displayed. The query doesn't display a time out and appears to continue running for minutes until I close the browser window. Without the OPTIONAL statement the query will return 156546 results in 8138 ms. I get the same error if I use the OPTIONAL statement looking for other properties eg P234 (inchi). Any ideas on what the error is? Is it my query or a bug? Ideally I would like to get InChIs and SMILES data where they exist for a compound. Thanks --The chemistds (talk) 10:18, 2 June 2016 (UTC)

Handling properties with variable unit types
[Disclaimer: My knowledge of SPARQL and other query languages is almost zero.]

I'm trying to see how well I can generate lists of geographical entities (mountains, lakes, rivers, etc.) sorted by a particular measured physical property: elevation, area, volume, depth, length, width, etc. Here's an example Wikidata Query that actually works (after a fashion):

Once I got to this point I discovered that a lot of the lakes showing up at the top of my list of largest lakes were actually mid-sized lakes in Sweden. After some digging I discovered that some lake volume figures are given in cubic meters and others in cubic kilometers. Clearly these can be converted, so long as I can identify which unit of measurement is being used for each and adjust it as needed. How would I do that? (I tried a lot of times and failed.) This seems to be a pretty broadly applicable requirement as there are lots of properties here that accept values with various types of units.

Also, some items show up more than once. For example, the shows up twice because it is an instance of both an  and a, both of which are subclasses of lake. Is there a way I can rewrite the query so that I don't get duplicate items? Rupert Clayton (talk) 22:59, 7 June 2016 (UTC)

Queries are down at this time: (6th of July 2016 : 7:16 UTC).

Is the number of arguments in a query limited?
Hi, I just wonder whether there is some limitation as to the length of a query. Here is the query: tinyurl.com/zdn4lfl

When I add more fields, the server returns "ERROR: Could not contact server" Is this a feature or a bug? Is it documented somewhere? -- Beat Estermann (talk) 22:13, 16 July 2016 (UTC)

Why don't URIs work in queries?
This works: This doesn't:


 * You need to use different URL for property, wdt: prefix is http://www.wikidata.org/prop/direct/ so full URL is http://www.wikidata.org/prop/direct/P828. See: https://www.mediawiki.org/wiki/Wikibase/Indexing/RDF_Dump_Format#Full_list_of_prefixes --Smalyshev (WMF) (talk) 22:11, 16 August 2016 (UTC)

Add WDQ to SPARQL conversion?
Many of Magnus's tools (eg PetScan) now have a wonderful WDQ2SPARQL feature which can take a standard WDQ query (eg claim[31:5]) and convert it into the correct SPARQL form. Given how relatively easy WDQ is to remember for simple queries, and that this conversion tool works so neatly on PetScan, could it be added as a feature on the Wikidata query service as well? Andrew Gray (talk) 19:44, 2 August 2016 (UTC)

Add support for bds: to SPARQL endpoint?
Blazegraph supports full text search which can be executed in SPARQL with bsd: predicates. Would it be possible to add support for bsd:?

For example:

This currently results to the following error message:


 * Well, this is because free text index has not been enabled :) We are working on integrating WDQS with our own full-text index solution that is indexing wikidata, see T141813. --Smalyshev (WMF) (talk) 22:13, 16 August 2016 (UTC)

Suggestion: Query formatting function
Hi, Just have to say I love the SPARQL interface. Slick and with very useful functionality!

The only little thing I wish sometimes, is ability to automatically format the query, with nesting, spacing etc.

This is useful sometimes when pasting queries copied from oneliners (such as when they have been embedded in URLs) etc.

Links in query results should be https, not http
The Wikidata query service delivers http links (without TLS encryption) in the query results. Could you please switch to https, or at least use protocol-relative links? Example: go to the query service, select the very first example (“Cats”), and look at the links in the “item” column. Thanks! —MisterSynergy (talk) 10:48, 2 September 2016 (UTC)
 * These are entity identifiers, not links. They need to be fixed and unique for an item, and traditionally most linked data ontologies use http in their URI schemes, almost nobody uses https. This does not mean if you want to use this URI to access the data you have to use http. BTW, what is the problem with identifiers using http URIs? --Smalyshev (WMF) (talk) 19:31, 7 September 2016 (UTC)


 * Thanks for response. The entity identifiers are used as links here, but not fully displayed as such in the GUI (they are listed as "wd:Qxxxx"). I am often using public unencrypted wireless networks and try to hide as much traffic as possible with https, and I am also not sure whether anything sensible such as cookies are sent unencrypted if I click on unencrypted links. It would suffice if I could activate https links as an option in the WDQS GUI, in those situations where I am not primarily interested in entity identifiers. --MisterSynergy (talk) 19:42, 7 September 2016 (UTC)

RGB
Do RGB color values only work when they are upper case? Example: --Tobias1984 (talk) 13:09, 3 September 2016 (UTC)

Getting started
I'm unable to find documentation on Wikidata query service that is complete enough to actually write queries. Everything I've found is hit or miss.

As an example, I started out with a query, which is found at Wikidata Property talk:P569 (search for "Wrong calendar and click on "Violations query")

My intent was to add a new requirement, in addition to the date-related requirement, that the item have the property "Country of citizenship" and the value of that property be "Kingdom of Great Britain". So I modified the query by adding this line:

?item p:P27 wd:Q161885.

on a separate line just above the right curly brace.

This query didn't return any results. I couldn't find any documentation that one could read from the point of view of "this is what I want to do, how do I do it?" Any suggestions? Jc3s5h (talk) 23:35, 30 September 2016 (UTC)


 * Jens on my team is currently working on better documentation. Hope to have something to show in a week. --Lydia Pintscher (WMDE) (talk) 11:07, 2 October 2016 (UTC)


 * i'm very interested in such a beginners' guide too. is there a "better documentation" somewhere now? Holger1959 (talk) 00:42, 1 December 2016 (UTC)


 * Check out d:Wikidata:SPARQL query service/Wikidata Query Help. --Lydia Pintscher (WMDE) (talk) 10:20, 1 December 2016 (UTC)

Missing data in query
I'm trying to query cities. Algiers (Q3561) is an instance of capital (Q5119) and city (Q515). But when I make the following query, information about city is lost and result consists only of one entity.

SELECT * {wd:Q3561 wdt:P31 ?class}

https://query.wikidata.org/#SELECT%20%2a%20%7Bwd%3AQ3561%20wdt%3AP31%20%3Fclass%7D

I get the following result: wd:Q5119, but I expect it to be wd:Q515 and wd:Q5119

Is it a bug, or am I doing something wrong? --176.14.69.93 19:38, 1 October 2016 (UTC)


 * See for instance T125558. Matěj Suchánek (talk) 16:21, 3 October 2016 (UTC)

Label service button
Could we have a button that adds the "label service" magic incantation? Maybe before the last "}", or just append otherwise? We can move it around as needed, just copying that thing all the time gets annoying... --Magnus Manske (talk) 13:19, 13 October 2016 (UTC)

New visitors do not see the "Run" button because my query is very long.
When I send lay people to my shiny query, all they see is a wall of text, and nothing to click on. That's because my query has many lines, even though I have compacted the code a lot.

SOLUTION: Make the query area scrollable if the query is more than 20 lines.

What do you think about it? Thanks! Syced (talk) 13:23, 14 October 2016 (UTC)

Knowledge Graph
Hello, please add information on blogger Alexei Pechkurove https://www.wikidata.org/wiki/Q27303908 in the Knowledge Graph
 * This item was deleted as spam. Syced (talk) 08:09, 18 October 2016 (UTC)

number align
it would be useful right align numeric columns or count columns--Edoardo88 (talk) 11:45, 1 November 2016 (UTC)

SPARQL servers use different item order system?
Smalyshev, maybe you can have a look into the following issue:

we have a problem on dewiki with a couple of pages visible best in this example (notice all the ListeriaBot edits of size +/- 0) or here for 2016-10-31/11-01. Some specific items are reordered/rearranged again and again, otherwise nothing is changed. it looks as if the reason is only a slightly different order (alphabetical, per ID, or similar, don't know).

As far i know, ListeriaBot uses SPARQL servers, which may have a bit different cache data (see above). Can you identify a pattern and fix this behaviour please? Holger1959 (talk) 17:43, 1 November 2016 (UTC)
 * In general, items order is not guaranteed unless you explicitly sort them. So it could be the bot gets different order in different queries. I guess it should either ask for some kind of sorting or check that the set of entries did not change despite different order and not change, not sure. --Smalyshev (WMF) (talk) 20:26, 1 November 2016 (UTC)
 * Smalyshev, thank you for the reply. the sorting in our lists is usually done by property, and within a property section by alphabet. is there something special Magnus could add to his bot or to the Wikidata list template? (i don't understand the technics myself) Holger1959 (talk) 21:53, 1 November 2016 (UTC)
 * I am using the PHP Collator class to get proper sorting in the respective language. Not sure why that would "flip" the sort order. Investigating, but if you have any ideas, let me know. Relevant code, and here as well. --Magnus Manske (talk) 11:13, 2 November 2016 (UTC)
 * Update: Have fiddled with the code, I hope it's sorting more stable now, without breaking anything. Let me know please. --Magnus Manske (talk) 10:32, 3 November 2016 (UTC)

Image grid and timeline view not working anymore since display types update?
Before the addition of the (very awesome!) new types of displays, I could select an image grid and a timeline view for a query like this one. Now not anymore - those view options are greyed out ('bubble chart' as well). Is this intentional? Spinster (talk) 18:39, 1 November 2016 (UTC)
 * Yes, sorry, known bug, will be fixed soon. --Smalyshev (WMF) (talk) 20:26, 1 November 2016 (UTC)

Textual representation fails when using VALUES
In my (well initially prepared with help of I don't remember who on #wikidata) query tinyurl.com/jhhq89r (btw, why don't we have a url shortening service specifically for SPAQRL which would allow not to have it blacklisted?) after I used VALUES the textual representation is sure that I am looking for anything. That is rather unfortunate since it is handy in picking needed item without need to look it's entity id up directly on Wikidata, while I used VALUES to define a variable exactly for merging value used in 2 places into one being. --Base (talk) 00:07, 7 November 2016 (UTC)
 * Well it looks I still can use its window to actually look up entities but well still the original thing is a bug. --Base (talk) 00:18, 7 November 2016 (UTC)

Simple query does not work (dewiki project)
this question is related to a comprehensive Wikidata project on dewiki.
 * background: i use Magnus' ListeriaBot for many pages on dewiki, all related to geographical objects in Germany. The goal and usage is broad: better sorting items by federal state>district>municipality, finding wrong classifications, adding missing descriptions/images/Commonscat/etc (example page for one district). this is extremely helpful and my (together with Aeroid's) subpages cover already 11 of 16 federal states of Germany by district/independent city using queries like "all items [P131] located in the administrative territorial entity, including [P150] subdivisions, and sorted by [P31] instance of". Additionally, queries for certain topics are used on associated subpages, eg. "all rivers/mountains/cultural heritage monuments/windmills/etc located in [administrative unit]". This worked fine for months.
 * problem: about 2 weeks ago, queries stopped working for some topics, eg. "all protected areas in a certain administrative unit". ListeriaBot with WDQ displays an error, with SPARQL it displays "no items" and when using query.wikidata.org i see only "Query timeout limit reached".
 * example:
 * see subpage DE-RP (German state of Rhineland-Palatinate)
 * old WDQ definition for ListeriaBot  worked fine for months, stopped working (errors)
 * new SPARQL definition works on DE-SL (German state of Saarland), cf. and following bot edits
 * new SPARQL definition does not work for DE-RP (only difference is the federal state item Q1200 instead of Q1201) and for other related/similar queries:
 * question: what can i do, or how can this issue be fixed? Holger1959 (talk) 16:22, 1 December 2016 (UTC)
 * question: what can i do, or how can this issue be fixed? Holger1959 (talk) 16:22, 1 December 2016 (UTC)

Smalyshev (WMF), could you have a look into this, or tell an other staff member with SPARQL experience to help, please? the users who work on these topics are really lost without Listeria worklist updates and/or without functioning query.wikidata.org. Maybe you know an alternative query to achieve the same result, as it was possible with the WDQ definition given above? (please note that my own understanding of SPARQL, unfortunately, is limited, and none of the other users i asked was able to find a solution.) Holger1959 (talk) 02:03, 8 December 2016 (UTC)
 * The query doesn't seem right but I'm not sure wherer it's me not understanding what it's supposed to do or conversion bug. I think "protected items in specific territory" should be give by this:

but please verify if it's indeed the case and if not, please point me to what's missing. --Smalyshev (WMF) (talk) 21:41, 9 December 2016 (UTC)


 * many thanks for your help! the new query at least works (no timeouts), but the results are incomplete (only ca. 1/5 of items formerly found). i am currently trying to get help by an other german-speaking user who seems to understand SPARQL. will report back here if we find a functioning query scheme.
 * Either way, i still think the results i want to achieve (all objects of type A located in a defined area B, like eg. "all towers somewhere in England"), should only require a simple query. This type of request (or its structure) is rather trivial and very common, isn't it? so i really don't understand why it is so complicated. (in despair) Holger1959 (talk) 06:52, 16 December 2016 (UTC)
 * now MisterSynergy found the solution! it works also for larger federal states with many items, complete results (as before) and without timeouts.
 * i hope this example helps also other users with similar query problems. Holger1959 (talk) 18:34, 16 December 2016 (UTC)
 * The last query does not have P150 check though. Is it not required? --Smalyshev (WMF) (talk) 01:59, 20 December 2016 (UTC)
 * it gives all relevant results without P150 obviously :) and if needed, we can now use a separate query for P150, which works the same. this solved also a couple of similar problematic queries ("Cities in Saxony"). maybe someone can add this hint to T116298? Holger1959 (talk) 00:45, 3 January 2017 (UTC)
 * it gives all relevant results without P150 obviously :) and if needed, we can now use a separate query for P150, which works the same. this solved also a couple of similar problematic queries ("Cities in Saxony"). maybe someone can add this hint to T116298? Holger1959 (talk) 00:45, 3 January 2017 (UTC)

WDQ
What is the reason of abolishing such short and convenient syntax? Earlier I used auto-generated WDQ queries like: http://wdq.wmflabs.org/api?q=claim[2936]&noitems=1. And how should I get the number of items with some claim? Compare: "noclaim[31]" and "SELECT ?item WHERE { OPTIONAL { ?item wdt:P31 ?dummy0 }  FILTER(!bound(?dummy0))}". What is easier to remember? May be to make at least reverse compatibility? --Infovarius (talk) 12:36, 7 December 2016 (UTC)
 * The reason is WDQ and Query Service are two completely different tools, which use completely different codebases and completely different platforms. It's not really feasible to implement WDQ syntax on top of SPARQL graph engine, it's be quite a lot of work for which we just don't have resource. You can however use the translator here: http://tools.wmflabs.org/wdq2sparql/w2s.php to translate from WDQ syntax to SPARQL. --Smalyshev (WMF) (talk) 04:46, 13 December 2016 (UTC)
 * in SPARQL that is better said:

select * {?item a wikibase:Item. filter not exists {?item wdt:P31 []}} --Vladimir Alexiev (talk) 19:28, 13 March 2017 (UTC)
 * Thanks. But I will not remember this, and the translator above (and in PetScan, e.g.) gives me my version... --Infovarius (talk) 16:05, 17 March 2017 (UTC)
 * https://github.com/smalyshev/wdq2sparql/issues/12 --Vladimir Alexiev (talk)
 * Another problem with absence of WDQ. I used to get a list of all films (>250 thousands) by WDQ-quering "claim[31:(TREE[11424][][279])]". Now it seems that I have no any alternative... --Infovarius (talk) 16:06, 17 March 2017 (UTC)
 * This is translated to

Which has equivalent but simpler form

Just tested, both of them run fast and return 244k results --Vladimir Alexiev (talk) 15:02, 23 March 2017 (UTC)

Display URLs with an icon
Excellent tool but if you have hyperlinks in a list/map... then they take to much space. I would like to see a possibility t just show a [https://query.wikidata.org/embed.html#%23%20Query%20Find%20in%20WikiData%20people%20with%20Place%20of%20Burial%20Q252312%20Norra%20Begravningsplatsen%0A%23%20Show%20Wikitree%20ID%2C%20Find%20A%20Grave%20ID%20and%20if%20picture%20of%20the%20grave%20exist%0A%23%20version%202%20Google%20map%20link%0A%23defaultView%3AImageGrid%0Aselect%20distinct%20%20%3Farticle%20%3Fperson%20%3FpersonLabel%20%20%3FpersonDescription%20%20%3Fgraveplot%20%20%20%3Fcoord%20%3FpicGrave%20%3FWikiTree%20%3FFindAGrave%0A%28IRI%28CONCAT%28%22https%3A%2F%2Fwww.google.com%2Fmaps%2F%3Fq%3D%22%2C%20STR%28%3Flat%29%2C%20%22%2C%22%2C%20STR%28%3Flon%29%29%29%20AS%20%3FGoogleMap%29%20%3FSBL%20%7B%0A%7B%0A%09%3Fperson%20wdt%3AP119%20wd%3AQ252312%3B%20%23Place%20of%20burial%0A%20%20%20%20%20%20%20%20%20%20%20%20p%3AP119%20%5B%20%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20pq%3AP965%20%3Fgraveplot%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20pq%3AP625%20%3Fcoord%3B%20%20%20%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20pqv%3AP625%20%5B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20wikibase%3AgeoLatitude%20%3Flat%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20wikibase%3AgeoLongitude%20%3Flon%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%5D%0A%20%20%20%20%20%20%20%20%20%20%20%20%5D.%20%20%20%20%20%20%20%20%0A%20%20%20%7B%20%3Fperson%20wdt%3AP3217%20%3FSBLID%20.%7D%20%09%09%09%09%09%09%23%20SBL%0A%20%20%20OPTIONAL%7B%20%3Fperson%20wdt%3AP18%20%3Fpic%20.%7D%20%09%09%09%09%09%23%20If%20we%20have%20an%20illustration%0A%20%20%20OPTIONAL%7B%20%3Fperson%20wdt%3AP1442%20%3FpicGrave%20.%7D%20%09%09%09%23%20If%20we%20have%20a%20picture%20of%20the%20grave%0A%20%20%20BIND%20%28URI%28CONCAT%28%22https%3A%2F%2Fsok.riksarkivet.se%2Fsbl%2FPresentation.aspx%3Fid%3D%22%2C%3FSBLID%29%29%20AS%20%3FSBL%29%0A%20%20%20OPTIONAL%20%7B%0A%20%20%20%20%20%20%3Farticle%20schema%3Aabout%20%3Fperson%20.%0A%20%20%20%20%20%20%3Farticle%20schema%3AinLanguage%20%22sv%22%20.%0A%20%20%20%20%20%20%3Farticle%20schema%3AisPartOf%20%3Chttps%3A%2F%2Fsv.wikipedia.org%2F%3E%20.%0A%20%20%20%20%7D%0A%20%20%20OPTIONAL%20%7B%0A%20%20%20%20%20%20%3Farticle%20schema%3Aabout%20%3Fperson%20.%0A%20%20%20%20%20%20%3Farticle%20schema%3AinLanguage%20%22en%22%20.%0A%20%20%20%20%20%20%3Farticle%20schema%3AisPartOf%20%3Chttps%3A%2F%2Fsv.wikipedia.org%2F%3E%20.%0A%20%20%20%20%7D%0A%0A%20%20%20OPTIONAL%20%7B%20%3Fperson%20wdt%3AP106%20%3Fgroup%20.%7D%20%09%09%09%23%20Occupation%20in%20Layer%0A%0A%7D%20%20%20%0A%20%20SERVICE%20wikibase%3Alabel%20%7B%20bd%3AserviceParam%20wikibase%3Alanguage%20%22sv%22%2C%22en%22%7D%0A%20%7D%0AOrder%20by%20%3FpersonLabel Example query] displaying gravestones with external links..... - Salgo60 (talk) 13:46, 30 December 2016 (UTC)
 * Wiki icon that is clickable
 * Google map icon that is clickable
 * SBL icon that is clickable
 * Spotify icon

Answers questions
Yes I am have been working with P2949 and now working with P3217 Adding value with references using P3217 that is a source from the Swedish National Archives Its more than excellent but some reports would benefit from not displaying the URL instead an icon
 * ''Do you consider yourself part of the Wikimedia movement?
 * ''What are you using the service for? (e.g. building an interactive timeline of British prime ministers)
 * ''Were you able to get what you needed from the service?

Query parameter for simple json
What is the API parameter for simple JSON. "format=json" gives a standard long format with "results", "bindings", etc. &mdash; Fnielsen (talk) 15:12, 8 February 2017 (UTC)

Optimize regex filter
A regex filter now times out when searching on

I tried a modification, but that also timed out:

This is a not entirely satisfactory workaround:

Is there any other way to change the query? &mdash; Fnielsen (talk) 15:22, 8 February 2017 (UTC)


 * adding  .  gets you a few additional ones. --Esc3300 (talk) 09:54, 26 March 2017 (UTC)


 * Do you think that the hint works? I was under the impression that it does not do much when there is only one triple pattern. If I now execute the first statement I listed, I do not get a time out. I suspect that the time out has been set up or that the engine has been improved. &mdash; Fnielsen (talk) 19:55, 27 March 2017 (UTC)

Why schema:name and skos:prefLabel are missing?
Trying to get names of concentration camps. This returns a bunch of names for Auschwitz: curl -L -Haccept:text/turtle https://www.wikidata.org/entity/Q7341 (more schema:name=skos:prefLabel, fewer skos:altLabel

But this returns only altLabels. No matter whether I use schema:name or skos:prefLabel, it returns none of those: select * { ?x wdt:P31 wd:Q328468; wdt:P625 ?coords. {?x schema:name ?pref} union {?x skos:altLabel ?alt} } --Vladimir Alexiev (talk) 19:25, 13 March 2017 (UTC)

From Wikidata_query_service/User_Manual I grokked that I should use rdfs:label instead of schema:name/skos:prefLabel. What threw me off is that skos:prefLabel and skos:altLabel are both subprops of rdfs:label, so nominally speaking rdfs:label should return both. Oh well, I'll use what is present. --Vladimir Alexiev (talk) 19:49, 13 March 2017 (UTC)

Wikidata Query Short URLs are blocked
When you run a query on Wikidata at https://query.wikidata.org there is a links button with a "Short URL to Result" generator option. But as it produces a tinyurl.com link, you then block it from being saved. Can tinyurl.com be whitelisted for use on User pages? I don't want to have to expand the URL to the full code, or save the tinyurl as plaintext, not a link, to be able to save it. Or can Wikipedia/Wikidata/Wikimedia ensure that all of its INTERNAL tools are able to be used effectively across all sites and not use external services that you block. The-Pope (talk) 15:23, 8 May 2017 (UTC)

Sometimes, broken JSON (latin1 encoding) is emitted when using "Download JSON file"
Steps to reproduce:

SELECT ?label WHERE { wd:Q648745 rdfs:label ?label. }
 * Go to https://query.wikidata.org/
 * Enter the following query:


 * Click run
 * Click the "Download" → "Download JSON file" button
 * Inspect the downloaded file. It is encoded using latin1 and fails to load in any spec-conforming json implementation

I managed to reproduce this using current Chrome and Firefox on Linux.

Ctrl space not working
I tried to control space (in Chrome), and it wasn't working. Is there a breaking bug? Sadads (talk) 23:16, 31 May 2017 (UTC)

Adding simple sameas reasoning
Dear Dev Team, Proposal for language extension for SPARQL.

Here is an example ontology with owl:sameAs statements to rename predicates: https://raw.githubusercontent.com/h4ck3rm1k3/wikidata_varnish/master/enmap.ttl

I would like to add a sparql preprocessor that would take a query like this :

PREFIX wdt:  PREFIX bd:  PREFIX wikibase:  PREFIX wd:  prefix owl:  prefix enmap:  prefix varnish:  prefix objects:  prefix void: 

SELECT ?countryLabel WHERE { OPTIONAL {varnish:done varnish:import enmap:ontology} OPTIONAL {objects:country owl:sameas wd:Q146} ?country enmap:sameas objects:country. SERVICE wikibase:label { bd:serviceParam wikibase:language "en". } } ORDER BY ?countryLabel

the query would be rewritten to :

PREFIX wdt:  PREFIX bd:  PREFIX wikibase: <http://wikiba.se/ontology#> PREFIX wd: <http://www.wikidata.org/entity/> SELECT ?countryLabel WHERE { ?country wdt:P31 wd:Q6256. SERVICE wikibase:label { bd:serviceParam wikibase:language "en". } } ORDER BY ?countryLabel

wdt: should have normalized values
2016 Quantities


 * 1) ^ - because we use them in sorting; labels "sq km" "acre" should be inside
 * 2) we should have an option to use Labeling service to describe values using "hidden labels" back D1gggg (talk) 06:37, 4 July 2017 (UTC)

Probably same remark about values in  D1gggg (talk) 06:42, 4 July 2017 (UTC)