Question

I want to write a query that gets back everything that is known about a topic (only needs to be one level deep.

When working in the Freebase MQL Editor they give the following example for "Everything we know about Jimi Hendrix":

{
  "*" : null,
  "name" : "Jimi Hendrix",
  "type" : "/music/artist"
}

The problem is that the query is bound to a type "/music/artist" and is only getting back properties that relate to that type. If you change the query to use a different type you get an entirely different result set.

{
  "*" : null,
  "name" : "Jimi Hendrix",
  "type" : "/people/person"
}

How can I write a query that really gets back everything that Freebase knows about Jimi Hendrix?

Was it helpful?

Solution

The Freebase Topic API might be what you're after:

http://www.freebase.com/experimental/topic/standard?id=/en/jimi_hendrix

The Topic API will grab all properties directly related to a topic in the graph. The API wraps a series of MQL queries to get all the data and outputs in JSON.

Google "Freebase Topic HTTP API" for further information.

OTHER TIPS

To do this you'll need a more advanced type of query that looks at the underlying links (/type/link) that make up the Freebase graph. Each link has a source, a target and a property assigned to it and they can be queried like this:

[
  {
    "master_property" : null,
    "source" : {
      "id" : "/en/jimi_hendrix"
    },
    "target" : null,
    "target_value" : null,
    "type" : "/type/link"
  }
]

These are called the outgoing links and represent most of the values that you usually see in the Freebase UI but you can also swap the source and target to get a list of incoming links links this:

[
  {
    "master_property" : null,
    "source" : null,
    "target" : {
      "id" : "/en/jimi_hendrix"
    },
    "type" : "/type/link"
  }
]

These links include properties on other topics that refer to Jimi Hendrix as their value and these values are not all shown on the Freebase Jimi Hendrix page to keep the volume of information to a manageable level.

After a while, we figured this is a typical use case, so we introduce a whole new API for doing this:

http://www.freebase.com/docs/topic_api

This will get you all the properties from the above queries, as well as mediators and other goodies.

Note that if you want all the properties from ALL the topics in Freebase, you should be using the data dumps and not the run-time query language (it will be many times faster).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top