Help Center
»
Developing Applications
»
The MQL Cookbook
»
Creating relationships with the connect directive
Since concepts can have multiple types, you will always need to specify the type that you are populating values for. Alternatively, you can use the instance ID and the fully qualified property ID for your query:
{
"query" : {
"id" : movieID,
"story_by" : {
"connect" : "insert",
"id" : personID,
"type" : {
"connect" : "insert",
"id" : "/film/film_contributor"
}
},
"type" : "/film/film"
}
} and
{
"query" : {
"/film/film/story_by" : {
"connect" : "insert",
"id" : personID,
"type" : {
"connect" : "insert",
"id" : "/film/film_contributor"
}
},
"id" : movieID
}
} are equivalent queries. The second one is useful when you are populating values for multiple types for an instance.
When you're connecting the film contributor, MQL, unlike the web client, does not infer that if the personID you are adding is of type /film/film_contributor and you should specify it explicitly. If the person is already typed as a /film/film_contributor, MQL will return connect:present.
If you want to programatically find the ECT of a property, use this query:
{
"query" : {
"expected_type" : {
"id" : null,
"name" : null
},
"id" : "/film/film/story_by",
"type" : "/type/property"
}
}
Search Help Center
Discussions
There are no conversations on this topic. Would you like to start one?
Start the Discussion »- Building Bases
- Creating Schemas
-
Developing Applications
- An Introduction to Freebase Application Development
- Playing in the Sandbox
- Freebase Programming Libraries and Tools
- Data Dump FAQ
- Using the Query Editor
- The Complete Metaweb Query Language (MQL) Reference Guide
- MQL Cheatsheet
-
The MQL Cookbook
- Get data as of a specific time
- Read properties of a type
- values vs name/id
- Incoming links
- Any topics with a specific date
- Wikipedia article text
- Retrieve the Wikipedia URL for an object with a GUID
- Find distinct co-types
- Creating relationships with the connect directive
- Mark for deletion
- Sort by index and timestamp
- Traversing Through Non-Reversed Properties
- Combine queries
- Perform transitive queries
- Freebase API Reference
- Application Developer Tips
- The Acre Hosted Development Environment
- Introduction to the Metaweb Javascript Template Language (MJT)
- Freebase Community