tags:

views:

211

answers:

2

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?

+3  A: 

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.

narphorium
+1  A: 

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.

txchou