1

Freebase WEX dumps contain a wpid column corresponding to the page_id from the source MediaWiki database in the freebase_wpid table. This table provides a mapping between Wikipedia numeric article/redirect IDs and Freebase GUIDs (Global Unique IDs).

guid use as foreign keys is deprecated by mid for lots of good reasons, but that doesn't change the fact that guids are still used at a system level so I'm going to call mid an accessor from here on.

Using the mid accessor is flexible in MQL. One can query using "mid": null and using "mid":[] depending on whether one needs the current mid or every mid.

Finding a list of wpid values per mid is straightforward in MQL:

[{
  "mid": null
  "key": [{"namespace":"/wikipedia/en_id", "value":null}]
}]

But if all is well in the universe, each current mid should have only one current wpid, so is there a way to do something like "wpid": null like one can with the mql accessor?

Alec Wenzowski
  • 3,878
  • 3
  • 25
  • 40

1 Answers1

2

If you only want one wpid value per mid you could do something like this:

[{
  "mid": null,
  "key": {
    "namespace": "/wikipedia/en_id",
    "value":     null,
    "limit":     1
  }
}]​

Try it out

Bare in mind that it is entirely possible that a Freebase topic would have more than one wmid. This happens whenever we need to merge duplicate topics that we've imported from Wikipedia, or if we import them before they get merged in Wikipedia.

If you're looking for links to Wikipedia pages you might also be interested in the /wikipedia/en_title namepace:

[{
  "mid": null,
  "key": {
    "namespace": "/wikipedia/en_title",
    "value":     null,
    "limit":     1
  }
}]​

Try it out

Shawn Simister
  • 4,613
  • 1
  • 26
  • 31
  • The likelihood of multiple wpid values is exactly why I was hoping there might be a lesser-documented accessor, similar to mid. – Alec Wenzowski Nov 04 '11 at 16:37
  • I'm not sure that I follow. Are you just looking for a less complicated way to query for wpids? As far as I know you always have to use the key property. – Shawn Simister Nov 04 '11 at 17:41
  • I'm not concerned with complicated, I'm concerned with accuracy. The freebase mids are resilient throughout a merge or a split whereas picking a wpid out of wpids per mid is not resilient. Since so many things in the official gui are linked to wikipedia, I was hoping that some of that mid magic had been applied to wpid. – Alec Wenzowski Nov 04 '11 at 17:52
  • "key":[{"namespace":"/wikipedia/en_id",...}] is functionally equivalent to a hypothetical "wpid":[] property and with a limit of 1 it is equivalent to "wpid":null – Shawn Simister Nov 04 '11 at 18:10
  • When a split or a merge happens, all the keys (like /wikipedia/en_id) are suppose to be moved over to the correct topics. You can always follow these keys back to the correct split/merged topic simply by resolving the key using the id property like {"id":"/wikipedia/en_id/49728",...} – Shawn Simister Nov 04 '11 at 18:14
  • oh, really? My understanding from the docs was that there were some extra goodies going on with `"mid":null` – Alec Wenzowski Nov 05 '11 at 05:04