58271

Getting Wikipedia IDs in MQL

Question:

Freebase <a href="http://download.freebase.com/wex/" rel="nofollow">WEX dumps</a> contain a wpid column corresponding to the page_id from the source MediaWiki database in the <a href="http://wiki.freebase.com/wiki/WEX/Documentation#freebase_wpid" rel="nofollow">freebase_wpid</a> 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 <a href="http://wiki.freebase.com/wiki/Mid" rel="nofollow">lots of good reasons</a>, 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?

Answer1:

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 } }]​

<a href="http://tinyurl.com/6ct72sb" rel="nofollow">Try it out</a>

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 } }]​

<a href="http://tinyurl.com/6yt8eod" rel="nofollow">Try it out</a>

Recommend

  • How to Load a RavenDB Document, constrained to a Collection, when not using default ID generation st
  • Is this Guid random or guessable
  • Can I generate UserId for Entity Framework AspNet Identity manually?
  • How do I properly register the Type Library of A VB.NET COM+ Component?
  • Visual Studio 2017 hangs while loading a solution
  • MVC Identity 2.2.1 - Primary Key (Guid) as UniqueIdentifier instead of nVarChar(128)
  • Visual Studio Extention - Context Menu for 'Server Explorer'
  • How to add multiple columns in Apache Spark
  • sorting three number in a specific order
  • How to Count the Number of a Specific Character in a Cell with Excel VBA
  • GUIDs in DLLs (.Net)
  • Any real use for table-per-concrete-class with implicit polymorphism?
  • Is there a greater chance to collide when comparing GUIDs based on a hash vs \"Guid.NewGuid()?
  • Java Date object constructor for getting string is deprecated
  • Slowly changing dimension - What is Pure type 6 implementation
  • SQL - count occurrences of gender
  • SQL append distinct values from two columns and two tables
  • Hibernate: Inheritance and relationship mapping + generics
  • Should I use composite primary keys in Grails?
  • Many to Many in Linq using Dapper
  • how to set to NULL all the filestream varbinary(max) fields?
  • Extending the Django 1.11 User Model
  • How to Model Ternary Relationship in CakePhp?
  • Are there any side effects from calling SQLAlchemy flush() within code?
  • unable to get jsonEncode in magento2
  • encoding issues with content in response from HttpWebRequest
  • Updating Dojo provide
  • Defined variables not working in javascript files when I use getScript
  • How can I display the parent menu item's description using Wordpress walkers?
  • Automatically associate new Sonar project with custom quality profile and quality gate
  • Array with custom indexes in Ionic2
  • WPF - CanExecute dosn't fire when raising Commands from a UserControl
  • What is the “return” in scheme?
  • Azure Cloud Service Web Role web pages do not load
  • Check if a string to interpolate provides expected placeholders
  • Javascript + PHP Encryption with pidCrypt
  • jQuery tmpl and DataLink beta
  • VB.net deserialize, JSON Conversion from type 'Dictionary(Of String,Object)' to type '
  • What are the advantages and disadvantages of reading an entire file into a single String as opposed
  • How to get NHibernate ISession to cache entity not retrieved by primary key