Wikidata talk:SPARQL query service/queries/examples/advanced

From Wikidata
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Why aren't these queries linked from the query service itself

[edit]

I discovered this page because I was looking for the classic 'female mayors of large cities', but I couldn't find it when I clicked on the "examples" button on the query service itself. Could the "advanced" queries please either be added there too, or at least linked out to from there? Wittylama (talk) 14:21, 5 April 2022 (UTC)[reply]

API?

[edit]

@Daanvr In what way is this query an API query? It seems like a totally normal query to me. Ainali (talk) 16:31, 16 August 2022 (UTC)[reply]

  1. It is not an API query.
  2. It is not an advanced query (in my opinion, others may have other definitions for what is advanced).
  3. It doesn't find all properties and their values of a given item as claimed, but only best rank properties and values.
I suggest to not keep the query here, alternatively to make description and query match. --Dipsacus fullonum (talk) 19:19, 16 August 2022 (UTC)[reply]
Thank you for pointing out that the query only keeps best rank values, good point.
For common users that navigate Wikidata's website, it possibly is an superflues query sins the query results strongly resembles the information stated on the item's page. However for me, as a developer, I have been looking for such a query for years. In light of this, I think it is relevant to create a category for SPARQL queries moste relevant to external services contacting wikidata through the API.
Feel free to improve on the query and it's description and add other queries mostly usefull for external services!
Again, thank you @Ainali and @Dipsacus fullonum for the feedback :) Daanvr (talk) 20:50, 16 August 2022 (UTC)[reply]
@Daanvr So, you mean that results of the query is useful for someone who wants to use the API? If so, since it is possible to also use the API:s in queries, you need to find a less ambiguous header. Ainali (talk) 21:14, 16 August 2022 (UTC)[reply]
Good point! Did't think of the use of API's within queries. Any suggestions? Daanvr (talk) 21:34, 16 August 2022 (UTC)[reply]
For now I have changed it to "Queries useful to external services". Feel free to improve on it! Daanvr (talk) 21:43, 16 August 2022 (UTC)[reply]

java.lang.StackOverflowError on example line chart 'Average number of children per year'

[edit]

Execute the example given here on line chart/'Average number of children per year' as described and receive the following :

Erreur inconnue: java.lang.StackOverflowError

SPARQL-QUERY: queryStr=#defaultView:LineChart
SELECT  (str(?year) AS ?year) (AVG( ?_number_of_children ) AS ?count) WHERE {
  ?item wdt:P31 wd:Q5.
  ?item wdt:P1971 ?_number_of_children.
  ?item wdt:P569 ?_date_of_birth.
  BIND( year(?_date_of_birth) as ?year ).
  FILTER( ?year > 1900)
}

GROUP BY ?year
java.util.concurrent.ExecutionException: java.util.concurrent.ExecutionException: java.lang.StackOverflowError
	at java.util.concurrent.FutureTask.report(FutureTask.java:122)
	at java.util.concurrent.FutureTask.get(FutureTask.java:206)
	at com.bigdata.rdf.sail.webapp.BigdataServlet.submitApiTask(BigdataServlet.java:292)
	at com.bigdata.rdf.sail.webapp.QueryServlet.doSparqlQuery(QueryServlet.java:678)
	at com.bigdata.rdf.sail.webapp.QueryServlet.doGet(QueryServlet.java:290)
	at com.bigdata.rdf.sail.webapp.RESTServlet.doGet(RESTServlet.java:240)
	at com.bigdata.rdf.sail.webapp.MultiTenancyServlet.doGet(MultiTenancyServlet.java:273)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:687)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
	at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:865)
	at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1655)
	at org.wikidata.query.rdf.blazegraph.throttling.ThrottlingFilter.doFilter(ThrottlingFilter.java:322)

Christian 🇫🇷 FR (talk) 19:07, 12 June 2024 (UTC)[reply]

tablet shows wrong location "Monuments and other heritage items located 1 km around "

[edit]

The example "Monuments and other heritage items located 1 km around the users location", on Samsung tablet (browser Internet), requests no authorization and provides strange result  : it describes around Berlin but I am near Paris.
Other tests : 1. on laptop, Firefox show authorisation question for location 2. if I refuse, view is centered on Berlin 3. if I accept, view is approximatively where i am

Question : how to adapt the script as to enter manually own user coordinates (more precise than browser informations) ? Thanks. --Christian 🇫🇷 FR (talk) 08:53, 27 June 2024 (UTC)[reply]