"Thanks, I just updated the recipe! "
Contents |
The Schema Introspection Cookbook
The Schema Introspection Cookbook provides MQL recipes for querying information about schema objects, their properties, user interaction with those objects, and the links between them. All the recipes below have been tested, and can be cut-and-pasted into query editor to test the results with your own values. In some cases, links to the relevant sections of the MQL Reference Guide have been included to help you formulate your own queries and explain the query syntax.
MQL Recipes
ID, Keys, GUID
See the MQL Reference Guide, Section 3.3, for more information.
ID of a named object. Best practice is to ask for a list of results as there could be more than one object with the same name.
[{
"type" : "/music/artist",
"name" : "The Police"
"id" : null
}]
GUID of a named object. Best practice is to ask for a list of results as there could be more than one object with the same name.
[{
"type" : "/music/artist",
"name" : "The Police"
"guid" : null
}]
Keys of the object in "id" and their associated namespaces. Keys are a strong identifier of an object that usually come from external data sources. Examples include GNIS, GNS, Wikipedia, and Netflix. You are guaranteed that one key will match to only one topic, but one topic can have multiple keys.
{
"id" : "/en/the_police",
"key" : [{}]
}
Retrieve the ID for the article associated with an id
{
"id" : "/en/the_police",
"/common/topic/article" : {"id":null}
}
Domains
List all types in a domain
{
"id" : "/music",
"type" : "/type/domain",
"types" : []
}
User Queries
Topics created by a user, limited to 30 results.
[
{
"creator" : "/user/jamie",
"id" : null,
"limit" : 30,
"name" : null,
"type" : "/common/topic"
}
]
Types created by a user
[
{
"creator" : "/user/jamie",
"name" : null,
"type" : "/type/type"
}
]
Types and Properties
Lists properties of type named in "id". See the MQL Reference Guide, Section 3.4.5, for more information about all the property objects.
[
{
"id" : "/music/artist",
"properties" : [],
"type" : "/type/type"
}
]
Lists property names and ECTs of the type in "id"
[
{
"id" : "/common/topic",
"properties" : [
{
"expected_type" : null,
"name" : null
}
],
"type" : "/type/type"
}
]
Properties of the property in "id"
{
"id" : "/music/artist/album",
"type" : "/type/property",
"*" : null
}
Client-related properties are those used by the Freebase.com client to control the display of property information. These are all properties of /type/property and can be queried in the same way as other properties of a property. These are bare properties; the type is not asserted on the property.
- /freebase/documented_object/tip: Adding documentation to a property (ect: /type/text)
- /freebase/property_hints/display_none: True if the property is hidden
- /freebase/property_hints/disambiguator: True if the property will operate as a disambiguator
- /freebase/property_hints/display_orientation: vertical if the property should be displayed as such, horizontal otherwise
- /freebase/type_hints/included_types: lists types included with another type
Lists expected type of the property in "id"
{
"/type/property/expected_type" : null,
"id" : "/music/album/track"
}
List other types included with a type:
{
"/freebase/type_hints/included_types" : [
{}
],
"id" : "/music/artist"
}
Topic Queries
Everything about a topic
{
"*" : null,
"name" : "Jimi Hendrix",
"type" : "/music/artist"
}
When a topic was added, and by whom
[
{
"creator" : null,
"id" : "/wikipedia/en/Star_Wars_Episode_IV",
"name" : null,
"timestamp" : null,
"type" : "/film/film"
}
]
Link Queries
Find the master_property that links a top-level object and an object in a sub-query, and the direction (forward/reverse) of the link. See the MQL Reference Guide, Section 3.7.1, for more information.
{
"id" : "/en/the_police",
"/music/artist/album" : {
"name" : "Synchronicity",
"link" : {}
}
}
Find the master_property that links two objects
{
"id" : "/en/the_police",
"/music/artist/album" : {
"name" : "Synchronicity",
"link" : null
}
}
Show all properties of the link between the object in "id" and the object described through the type ("/music/artist/album") and "name".
{
"id" : "/en/the_police",
"/music/artist/album" : {
"name" : "Synchronicity",
"link" : {"*" : null}
}
}
Lists the creator and timestamp of the link between two objects
{
"id" : "/en/the_police",
"/music/artist/album" : {
"name" : "Synchronicity",
"link" : {
"timestamp" : null,
"creator" : null
}
}
Top-level queries
- All top-level queries must use "type" : "/type/link" to specify that the query is aimed at finding link information.
Top-level query for all the links originating from an object, including the name of the property that represents the link and the value or name, type, and ID at the other end of the link. See the MQL Reference Guide, Section 3.7.2, for more information. (Note use of "source" to define object)
[
{
"master_property" : null,
"source" : {
"id" : "/en/peppermint_creeps"
},
"target" : {},
"target_value" : null,
"type" : "/type/link"
}
]
Top-level query for all the objects incoming to an object, including the name, type and ID (note use of "target" to define object)
[
{
"master_property" : null,
"source" : {},
"target" : {
"id" : "/en/peppermint_creeps"
},
"type" : "/type/link"
}
]
Shows the invalidated links with timestamp for the "master_property" of the "source" object (essentially shows changes in values for the master_property)
[
{
"master_property" : "/type/object/name",
"source" : {
"id" : "/guid/9202a8c04000641f8000000002fe6a26"
},
"target_value" : {
"value" : null
},
"timestamp" : null,
"type" : "/type/link",
"valid" : false
}
]
Show all valid and invalid links for the "master_property" in sequential order (essentially shows changes between former value and new value in sequence)
[
{
"master_property" : "/type/object/name",
"sort" : "-timestamp",
"source" : {
"id" : "/guid/9202a8c04000641f8000000002fe6a26"
},
"target_value" : {
"value" : null
},
"timestamp" : null,
"type" : "/type/link",
"valid" : null
}
]
Show deleted links between an object (defined as "target") and objects linked to it through the "master_property". Note explicit use of "operation" : "delete". See the MQL Reference Guide, Section 3.7.4, for more information.
[
{
"creator" : null,
"master_property" : "/music/album/artist",
"operation" : "delete",
"source" : {},
"target" : {
"id" : "/en/peppermint_creeps"
},
"timestamp" : null,
"type" : "/type/link"
}
]
Show deleted links for an object, including where the link went, who deleted it, and when (explicit use of "operation" : "delete")
[
{
"creator" : null,
"operation" : "delete",
"source" : {
"id" : "/guid/9202a8c04000641f8000000004738d02"
}, "target" : null,
"timestamp" : null,
"type" : "/type/link"
}
]
Show all link operations, and all valid and invalid links, along with the creator and timestamp, in sequential order, for an object (use of "operation" : null with "valid" : null)
[
{
"creator" : null,
"operation" : null,
"sort" : "timestamp",
"source" : {
"id" : "/guid/9202a8c04000641f8000000004738d02"
},
"target" : null,
"timestamp" : null,
"type" : "/type/link",
"valid" : null
}
]
Show outgoing links to another object, incoming links from another object, and any links to a primitive value like /type/text and /type/datetime. See the MQL Reference Guide, Section 3.7.3, for more information.
[
{
"/type/reflect/any_master" : [
{
"id" : null,
"link" : null,
"name" : null,
"type" : []
}
],
"/type/reflect/any_reverse" : [
{
"id" : null,
"link" : null,
"name" : null,
"type" : []
}
],
"/type/reflect/any_value" : [
{
"link" : null,
"type" : null,
"value" : null
}
],
"id" : "/wikipedia/en/Star_Wars_Episode_IV"
}
]