Wikidata talk:Request a query
Archiving
[edit]Archiving doesn't seem to work. First sections should already be in archive. {{User:Hazard-Bot/Archiver}}
seems to be correctly formatted. --Edgars2007 (talk) 06:05, 31 August 2016 (UTC)
- Thanks, Pasleim. --Edgars2007 (talk) 07:22, 31 August 2016 (UTC)
write data to Wikidata
[edit]Hello,
I would like to write data to Wikidata from a framework. Is it possible to write data to wikidata using SPARQL queries? I have seen a lot of queries regarding reading data from wikidata but I am not sure if data can be written to wikidata using SPARQL queries. Please advise.
Sharmeelaashwin (talk) 21:07, 23 January 2017 (UTC)
- It is not possible to edit Wikidata by using SPARQL. You need to use the API. --Pasleim (talk) 21:11, 24 January 2017 (UTC)
Do we need second page to ask questions?
[edit]Wikidata talk:SPARQL query service/queries
It was re-added.
I find two pages as confusing for newcomers and more difficult to monitor without clear advantages. d1g (talk) 12:14, 31 July 2017 (UTC)
- 112 bookmarked this one
- 43 another one
Difference in views even more prevalent. d1g (talk) 12:16, 31 July 2017 (UTC)
- I think this second page was created for basic questions.
--- Jura 12:19, 31 July 2017 (UTC)- No strong opinion but I would prefer only one page and if we really need two pages, it should be better indicated and documented, right now the two pages have more or less the same type of questions (something like beginner and advanced would make more sense to me than the actual request a query and request help for/about a query). Cdlt, VIGNERON (talk) 13:15, 31 July 2017 (UTC)
- Most archives are under 100KB. I think most pages are browsable under 5MB. d1g (talk) 21:10, 31 July 2017 (UTC)
- No strong opinion but I would prefer only one page and if we really need two pages, it should be better indicated and documented, right now the two pages have more or less the same type of questions (something like beginner and advanced would make more sense to me than the actual request a query and request help for/about a query). Cdlt, VIGNERON (talk) 13:15, 31 July 2017 (UTC)
Query requests for Google Code-in
[edit]It would be interesting to give Google Code-in students some query requests (and bot requests), especially ones which are more difficult. I will set up a very simple generic introductory sparql task, which can be done by many students.
Please let me know if there are any old or new query requests which might be suitable. Time sensitive requests are not suitable, as it may take a few weeks before a student completes the request. John Vandenberg (talk) 05:13, 28 December 2017 (UTC)
RAQ header
[edit]@Matěj Suchánek, Micru and others: can we please fix the header to a more beautiful style? I understand that it has been harmonized with other pages, but right now the elements in the header of this page don’t really get along with each other. The image is too big, and the “Start a new discussion” button is centered vertically, unlike the other parts. Elements were able to flow better before the update. Any ideas? —MisterSynergy (talk) 13:22, 1 June 2018 (UTC)
- @MisterSynergy: I find it more beautiful now than it was before, but I guess that is subjective :) Things I can do: I can hide the button from the right, and add it at the bottom. Would that help? I don't know if the message "Translate this header box!" should be hidden, though.--Micru (talk) 13:30, 1 June 2018 (UTC)
- Maybe, but here the elements don’t get along with each other. I need to scroll more than 1.5 screen heights to the actual content, on a FullHD display. Particularly in the upper box there is a lot of whitespace which I think we should avoid (btw. my thumbnail size at Special:Preferences#mw-prefsection-rendering is 400px, due to my “large” display). —MisterSynergy (talk) 13:40, 1 June 2018 (UTC)
- @MisterSynergy: I have reduced the upper padding from
{{Chat header}}
. Maybe you don't appreciate it much, but there is now less whitespace. I think the next step would be removing the image. Are you ok with that? --Micru (talk) 16:04, 1 June 2018 (UTC)- The upper padding isn’t the problem at all. Here is a temporary screenshot on my toolaccount. Maybe we can move the image to the right, and the button below the other text? It wouldn’t change the page/box height, but elements wouldn’t appear to be randomly dropped any longer. —MisterSynergy (talk) 17:26, 1 June 2018 (UTC)
- @MisterSynergy: Can you take a look to Wikidata:Request a query/Header/text? If it is now ok for you, I will request for it to be marked for translation, and it will appear on the page. But I must say that the image looks really big on your computer, for me it looks smaller.--Micru (talk) 08:32, 2 June 2018 (UTC)
- Yeah, the image size is set at Special:Preferences#mw-prefsection-rendering (thumbnail size). With my “big” display (which has probably just a standard resolution) I think that the standard 220px thumbnails are way too small. If the image could start further above next to the headline, it would be great, but it does not look possible to my knowledge. Another possibility would be to set a fixed image size, so that it looks the same for all users. —MisterSynergy (talk) 08:51, 2 June 2018 (UTC)
- @MisterSynergy: I don't know how to make that the image starts next to the header, and I don't know either how to set up a fixed image size. If you know how to do it, please feel free to modify the template.--Micru (talk) 17:31, 2 June 2018 (UTC)
- Done. IMO it is okay now. —MisterSynergy (talk) 18:01, 2 June 2018 (UTC)
- @MisterSynergy: I don't know how to make that the image starts next to the header, and I don't know either how to set up a fixed image size. If you know how to do it, please feel free to modify the template.--Micru (talk) 17:31, 2 June 2018 (UTC)
- Yeah, the image size is set at Special:Preferences#mw-prefsection-rendering (thumbnail size). With my “big” display (which has probably just a standard resolution) I think that the standard 220px thumbnails are way too small. If the image could start further above next to the headline, it would be great, but it does not look possible to my knowledge. Another possibility would be to set a fixed image size, so that it looks the same for all users. —MisterSynergy (talk) 08:51, 2 June 2018 (UTC)
- @MisterSynergy: Can you take a look to Wikidata:Request a query/Header/text? If it is now ok for you, I will request for it to be marked for translation, and it will appear on the page. But I must say that the image looks really big on your computer, for me it looks smaller.--Micru (talk) 08:32, 2 June 2018 (UTC)
- The upper padding isn’t the problem at all. Here is a temporary screenshot on my toolaccount. Maybe we can move the image to the right, and the button below the other text? It wouldn’t change the page/box height, but elements wouldn’t appear to be randomly dropped any longer. —MisterSynergy (talk) 17:26, 1 June 2018 (UTC)
- @MisterSynergy: I have reduced the upper padding from
- Maybe, but here the elements don’t get along with each other. I need to scroll more than 1.5 screen heights to the actual content, on a FullHD display. Particularly in the upper box there is a lot of whitespace which I think we should avoid (btw. my thumbnail size at Special:Preferences#mw-prefsection-rendering is 400px, due to my “large” display). —MisterSynergy (talk) 13:40, 1 June 2018 (UTC)
Links to external resources
[edit]Is it suitable to write in the page header something like the following? —
You could also ask your question on:
- I'm not sure what need that would be meeting. It's rare that a request is made here that has not been answered. --Tagishsimon (talk) 15:06, 1 November 2018 (UTC)
- @Tagishsimon: OK. Cool job! Is there any list of unanswered questions? -- Luitzen (talk) 22:40, 5 November 2018 (UTC)
- The top three questions on the board are unanswered and have not ever been removed - probably because they're unsigned & the bot depends on a signature date to archive them. Other than that, no. --Tagishsimon (talk) 23:06, 5 November 2018 (UTC)
Signing unsigned posts
[edit]Colleagues may find it convenient to use {{Unsigned2}}
, for example:
{{subst:unsigned2| 06:57, 16 April 2019 |Xunonotyk }}
to add a sig to unsigned posts, as I did here. The required values are easily copied from a single line in the page history, and the template should always be Subst:. Andy Mabbett (Pigsonthewing); Talk to Andy; Andy's edits 17:35, 18 April 2019 (UTC)
Longer Timeout
[edit]For those queries that need a long time to run, I suggest allowing the users to submit such queries and then let the community vote and decide which ones of them are interesting enough to be allowed to consume the server resources. Similar with timesharing on a telescope.
For example I find it interesting to generate a list of all articles about people from English Wikipedia. The SPARQL will timeout on such a query. Also PetScan will timeout too.
For sure the users can come up with very interesting queries that can't be run using the current system. For example such scripts can detect which disambiguation pages should be created. — Ark25 (talk) 23:48, 4 April 2020 (UTC)
Help to write a query
[edit]I would like to write a query to get the list of movies in which Brad Pitt and Leonardo DiCaprio appear together. Nicookie (talk) 09:26, 2 May 2020 (UTC)
- Try it!
SELECT ?item ?itemLabel ?date WHERE { ?item wdt:P161 wd:Q35332, wd:Q38111 . OPTIONAL { ?item wdt:P577 ?date } . SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" } . }
- Please post requests to the project page, not this talk page.
- --Matěj Suchánek (talk) 07:40, 6 May 2020 (UTC)
SPARQL template breaks if given "}}" in query; }} template does not help
[edit]This query gets the files in Category:1930s photographs in Auckland Museum and extracts three data points from the source
parameter of the file's {{Artwork}} template.
Because it contains two right curly braces (}}
) in the first REPLACE
operation, it breaks the {{SPARQL}}
template, and using {{))}}
does not help.
SELECT
?file ?title
(GROUP_CONCAT(DISTINCT ?en_label; separator=", ") as ?labels_en)
(GROUP_CONCAT(DISTINCT ?mi_label; separator=", ") as ?labels_mi)
?section ?object ?id
WITH {
SELECT * WHERE {
BIND (URI(CONCAT('https://commons.wikimedia.org/entity/M', ?pageid)) AS ?file)
SERVICE wikibase:mwapi {
bd:serviceParam wikibase:api "Generator";
wikibase:endpoint "commons.wikimedia.org";
mwapi:gcmtitle "Category:1930s photographs in Auckland Museum";
mwapi:generator "categorymembers";
mwapi:gcmtype "file";
mwapi:gcmlimit "50";
mwapi:prop "revisions";
mwapi:rvslots "main";
mwapi:rvprop "content".
?title wikibase:apiOutput mwapi:title.
?pageid wikibase:apiOutput mwapi:pageid.
?content wikibase:apiOutput 'revisions/rev/slots/slot/text()'.
}
BIND(REPLACE(?content, "^.*?Images from Auckland Museum\\
Not sure where else to post this and the Talk page for {{SPARQL}}
doesn't yet exist so I thought this would be more readily seen here. Thanks. —Hugh (talk) 22:13, 30 September 2021 (UTC)
- @HughLilly: I just saw this thread now, and don't know if the problem still exists, but as nobody else was responded, I will.
{{))}}
does indeed work so the{{SPARQL}}
template doesn't break. The problem is rather the pipe character (|) that ends the query argument in the SPARQL template. You will need to replace it with {{!}}. Also note that the query will give a syntax error in the regular expression because of wrong use of { which is a special character in regular expressions. You need to escape them with backslashes to use them literally in the regular expression. --Dipsacus fullonum (talk) 19:15, 23 February 2022 (UTC)
How to rank Wikidata properties by their popularity (when linking to other items)?
[edit]I know this query may take time to execute but anyone knows how to do that. Thank you! A l p h a m a 15:55, 16 February 2023 (UTC)
- @Alphama: If you're looking for reports on the use of all properties on all items, that's probably beyond WDQS's capabilities. You may, though, be interested in User:Mr. Ibrahem/claims.
- The SPARQL for such a report on WDQS would be something like this - this example looks for the use of properties as truthy claims, but does not count property use as qualifiers, references, &c. But it will timeout.
- --Tagishsimon (talk) 16:17, 16 February 2023 (UTC)Try it!
SELECT ?property ?propertyLabel ?count WITH { SELECT ?property (count(?item) as ?count) WHERE { ?item ?predicate ?value . ?property wikibase:directClaim ?predicate . } group by ?property } as %i WHERE { INCLUDE %i SERVICE wikibase:label { bd:serviceParam wikibase:language "en" . } } order by desc(?count)
- You save my day, thank you. A l p h a m a 08:56, 17 February 2023 (UTC)
Move content in `ak` on Wikidata to `tw` or `fat`
[edit]Can anyone here help move content in Akan language (ak) to tw or fat? This would involve writing and executing a query that involves several items such as: property labels, statements, lexemes, site links, etc. See here for more information: T333765. Thanks! SSethi (WMF) (talk) 22:05, 31 August 2023 (UTC)
- Hi @SSethi (WMF) - as mentioned on phab:T333765, we can write a query to find them, eg https://w.wiki/7P28 is countries with ak labels, but it's worth clarifying that the query service isn't able to do any editing. To edit them, we'd need to go through the normal Wikidata channels (API or the web interface), neither of which will allow adding/removing/updating of labels in an unsupported language.
- Unfortunately, there are still about half a million items with Akan labels. I think you may have to turn it back on for the time being so that these can be removed, otherwise they will just be left cluttering up items. Andrew Gray (talk) 23:04, 2 September 2023 (UTC)
- @SSethi (WMF):
You may be looking for a combination of a query got get data + Excel (or R, or Python...) to turn data into QuickStatements commands + QuickStatements to edit.--Pere prlpz (talk) 10:23, 19 September 2023 (UTC) - After reading the question again, if the problem is an unsupported language, I don't think QuickStatements can do better than the API or other tools.--Pere prlpz (talk) 13:51, 19 September 2023 (UTC)
- And what tool is able to edit ak-labels? Because LabelLister already fails do this. --Infovarius (talk) 20:52, 20 September 2023 (UTC)
- This change in Gerrit about adding Akan back was recently merged. It should now be possible to change `ak` values in `Commons` & `Wikidata`. SSethi (WMF) (talk) 23:30, 16 October 2023 (UTC)
- And what tool is able to edit ak-labels? Because LabelLister already fails do this. --Infovarius (talk) 20:52, 20 September 2023 (UTC)
- @SSethi (WMF):
What to do/where to go for large queries?
[edit]I want to know which en.wiki pages & associated QIDs are using 8 highly-populated properties (for example VIAF ID (P214)), each of which should be close to or over a million results, but the service times out after ~300,000 results. —Tom.Reding (talk) 12:06, 20 October 2023 (UTC)
- @Tom.Reding: Qlever, probably. Example: https://qlever.cs.uni-freiburg.de/wikidata/U3NV3E --Tagishsimon (talk) 12:12, 20 October 2023 (UTC)
- @Tagishsimon: thank you! It's amazing! —Tom.Reding (talk) 16:26, 20 October 2023 (UTC)