Page MenuHomePhabricator

Enable the MWAPI endpoint name to be defined via a variable (currently: endpoint name needs to be a constant)
Closed, ResolvedPublic

Description

Currently a request like the below throws an error: "java.lang.IllegalArgumentException: Endpoint name should be a constant"

SELECT *
WITH
{  
  SELECT ?link ?title ?endpoint
  {
    VALUES ?link { wd:Q8523541 }
    [] schema:about ?link; schema:isPartOf ?ws; schema:name ?title .
    MINUS { ?ws wikibase:wikiGroup "wikiquote" }    
    BIND( strbefore(strafter(str(?ws),"//"),"/") as ?endpoint)       
  }
} as %categories
WHERE
{  INCLUDE %categories
   SERVICE wikibase:mwapi {
        bd:serviceParam wikibase:api "Generator" .
        bd:serviceParam wikibase:endpoint ?endpoint .
        # bd:serviceParam wikibase:endpoint "eo.wikipedia.org" .
        bd:serviceParam mwapi:gcmtitle ?title .
        bd:serviceParam mwapi:generator "categorymembers" .
        bd:serviceParam mwapi:gcmprop "ids|title|type" .
        bd:serviceParam mwapi:gcmlimit "max" .
        ?article wikibase:apiOutput mwapi:title  .
        ?item wikibase:apiOutputItem mwapi:item .
        ?ns wikibase:apiOutput "@ns" .    
  }
}

To query several endpoints based on sitelinks on one or several items, it would be interesting if the endpoint name could be defined in a variable.

It would avoid to list specific endpoints in lines like:

bd:serviceParam wikibase:endpoint "eo.wikipedia.org" .

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript
Smalyshev triaged this task as Medium priority.Jul 22 2017, 12:04 AM
Smalyshev renamed this task from endpoint name can be a variable (currently: endpoint name should be a constant) to MWAPI endpoint name can be a variable (currently: endpoint name should be a constant).Jul 30 2018, 11:49 PM
Smalyshev moved this task from Current work to Incoming on the Wikidata-Query-Service board.
Daniel_Mietchen renamed this task from MWAPI endpoint name can be a variable (currently: endpoint name should be a constant) to Enable the MWAPI endpoint name to be defined via a variable (currently: endpoint name needs to be a constant).Aug 14 2018, 11:12 PM

As PetScan has some troubles these days, I'm using query server/mwapi:generator "categorymembers" again.

This reminds that the above would be helpful.

Codewise, is this complex or just a matter in which step the variable is defined?

I changed the sample in the description above.

Change 517160 had a related patch set uploaded (by Smalyshev; owner: Smalyshev):
[wikidata/query/rdf@master] Enable variable endpoint for MWAPI

https://gerrit.wikimedia.org/r/517160

Change 517160 merged by jenkins-bot:
[wikidata/query/rdf@master] Enable variable endpoint for MWAPI

https://gerrit.wikimedia.org/r/517160

excellent. Works fine. Thanks.

BTW, I edited the sample above to exclude Wikiquote. It isn't supported, but I wont miss it.