Uncategorized

Freebase MQL Query for Categories and Domains

January 13, 2008

author:

Freebase MQL Query for Categories and Domains

When you go to the Freebase Data page, there is a list of categories. Drilling down into these, you can see the top-level domains and their types. Looking at all the types in a domain is easy enough, but I could not figure out a way to get the categories and top-level domains. The documentation was no help.

I finally found the answer by looking at the mjt source code at this site:
http://mjtemplate.org/examples/schemas/index.html

Here’s the query to retrieve the categories:

{
  “query” : [
    {
      “name” : null,
      “type” : “/freebase/domain_category”
    }
  ]
}

And here’s the query to retrieve the top-level domains for a category:
(Caution: This query will take a long time to run as it returns the top-level domains and their properties

{
  “query” : [
    {
      “domains” : [
        {
          “id” : null,
          “name” : null,
          “type” : “/type/domain”,
          “types” : [
            {
              “/freebase/type_profile/instance_count” : null,
              “/type/reflect/any_reverse” : {
                “limit” : 1,
                “link” : {
                  “master_property” : “/freebase/type_hints/hinted_type”
                },
                “mediator” : null,
                “optional” : true,
                “type” : “/freebase/type_hints”
              },
              “id” : null,
              “name” : null,
              “optional” : true,
              “properties” : [],
              “sort” : “name”
            }
          ]
        }
      ],
      “name” : null,
      “type” : “/freebase/domain_category”
    }
  ]
}

I wish some of the types such as “/freebase/domain_category” or “/freebase/type_hints” were documented somewhere.

Founder NftyDreams; founder Decentology; co-founder DNN Software; educator; Open Source proponent; Microsoft MVP; tech geek; creative thinker; husband; dad. Personal blog: http://www.kalyani.com. Twitter: @techbubble
Leave a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.