Tiago and Rod,

Thanks for the responses.  Looks like the two of you have provided me two federated options (one to submit from the new scholarly endpoint and one for the OG endpoint), as well as an endpoint (query-legacy-full) where I can submit my original query.

I suppose another option is to submit the original query twice... once to the scholarly endpoint and once to the original endpoint... and perform the union of the results on the client side.

Questions:


I am asking those questions because what I am doing is putting together a way to automatically


After learning about the split graph and the need for federated queries, my concern is that if I build something now it will need to be revisited later in the year as things evolve.

Thanks,

MIKE


From: Tiago Lubiana <tiagolubiana@gmail.com>
Sent: Friday, June 13, 2025 3:24 PM
To: rdmpage <rdmpage@gmail.com>
Cc: bhl-wiki@lists.wikimedia.org <bhl-wiki@lists.wikimedia.org>; Lichtenberg, Mike <LichtenbergM@si.edu>
Subject: Re: [bhl-wiki] Re: Help with wikidata query

External Email - Exercise Caution

Oh, yes, a complete pain. 

We are trying to do a parallel documentation for some of the things here: https://meta.wikimedia.org/wiki/WikiCite/WDQS_graph_split  (this is kind of my job until August!) 

Quickest way: use https://query-legacy-full.wikidata.org/  until November, here is it https://w.wiki/EUAp

Now is an attempt at the federated version (it seems to be relatively simple for this case). It gives 67858 results, same as legacy, so it may be fine: 

query link here

Best, 
Tiago

Tiago Lubiana
tiago.bio.br


On Fri, Jun 13, 2025 at 5:14 PM Roderic D. M. Page <rdmpage@gmail.com> wrote:
Of course, that’s not much help. What you need is to do a federated query that spans both graphs. These have caused some heartache. I’ll try and do one for the original query.

Regards, Rod
On 13 Jun 2025 at 19:04 +0100, Lichtenberg, Mike <LichtenbergM@si.edu>, wrote:
Please help out a sparql newbie!

I have the following query to select identifiers for BHL Titles:

SELECT DISTINCT ?TitleID ?Wikidata ?OCLC ?ISSN ?Linking_ISSN ?ISBN13 ?ISBN10 ?Coden ?DLC ?NLM ?TL2 ?DOI WHERE {
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE]". }
  {
    SELECT DISTINCT ?item WHERE {
      ?item p:P4327 ?statement0.
      ?statement0 ps:P4327 _:anyValueP4327.
    }
  }
  BIND(REPLACE(STR(?item), "http://www.wikidata.org/entity/", "") AS ?Wikidata )
  OPTIONAL { ?item wdt:P4327 ?TitleID. }
  OPTIONAL { ?item wdt:P243 ?OCLC. }
  OPTIONAL { ?item wdt:P236 ?ISSN. }
  OPTIONAL { ?item wdt:P7363 ?Linking_ISSN. }
  OPTIONAL { ?item wdt:P212 ?ISBN13. }
  OPTIONAL { ?item wdt:P957 ?ISBN10. }
  OPTIONAL { ?item wdt:P1159 ?Coden. }
  OPTIONAL { ?item wdt:P244 ?DLC. }
  OPTIONAL { ?item wdt:P1055 ?NLM. }
  OPTIONAL { ?item wdt:P5878 ?TL2. }
  OPTIONAL { ?item wdt:P356 ?DOI. }
}

It seems to work, as it returns about 170K unique identifiers for about 64K titles.

However, after adding those identifiers to a BHL database table where I could compare the data to what is already in BHL, I found that some items are missing from the sparql result.

For example, Q51512257 is associated with BHL Title 88, Q54792313 with BHL TItle 100, and Q51399752 with BHL Title 1231.  The query above does not return any of those wikidata items.  I modified the query to return just one of those wikidata items...

SELECT DISTINCT ?item ?TitleID ?Wikidata ?OCLC ?ISSN ?Linking_ISSN ?ISBN13 ?ISBN10 ?Coden ?DLC ?NLM ?TL2 ?DOI WHERE {
  BIND(wd:Q51512257 AS ?item)
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE]". }
  BIND(REPLACE(STR(?item), "http://www.wikidata.org/entity/", "") AS ?Wikidata )
  OPTIONAL { ?item wdt:P4327 ?TitleID. }
  OPTIONAL { ?item wdt:P243 ?OCLC. }
  OPTIONAL { ?item wdt:P236 ?ISSN. }
  OPTIONAL { ?item wdt:P7363 ?Linking_ISSN. }
  OPTIONAL { ?item wdt:P212 ?ISBN13. }
  OPTIONAL { ?item wdt:P957 ?ISBN10. }
  OPTIONAL { ?item wdt:P1159 ?Coden. }
  OPTIONAL { ?item wdt:P244 ?DLC. }
  OPTIONAL { ?item wdt:P1055 ?NLM. }
  OPTIONAL { ?item wdt:P5878 ?TL2. }
  OPTIONAL { ?item wdt:P356 ?DOI. }
}

... and it did return the item, but no identifier values.  Viewing https://www.wikidata.org/wiki/Q51512257 shows that the item does in fact have a DOI, BHL Bibliography ID (Title ID), and OCLC Control Number.

So, what is going wrong?  Is there something wrong with my query, or is there something unusual about those items?  (Or, I guess... both... is there something unusual that my query is not accounting for?)

Thanks in advance!

MIKE

_______________________________________________
bhl-wiki mailing list -- bhl-wiki@lists.wikimedia.org
List information: https://lists.wikimedia.org/postorius/lists/bhl-wiki.lists.wikimedia.org/
_______________________________________________
bhl-wiki mailing list -- bhl-wiki@lists.wikimedia.org
List information: https://lists.wikimedia.org/postorius/lists/bhl-wiki.lists.wikimedia.org/