Help Center
»
Developing Applications
»
The MQL Cookbook
»
Traversing Through Non-Reversed Properties
Problem:
I was trying to create a find documents that were used as posts in a discussion thread. While there exists the property /community/discussion_thread/post on discussion threads, there is no corresponding reverse property, i.e. there is no property of the form /common/document/XXXXX refers to the same link type. I don't have access to add this reverse property to the /common/document type schema so I couldn't do that, and I needed the document to be at the top (root) of my query, so I couldn'y simply flip the query upside down in order to use the property on the thread.Solution:
I used the /type/reflect/any_reverse property to reference the link between the document and thread by the master property name as in this example:{"Q":{
"type":"/common/document",
"id":"#DOCUMENT_ID_GOES_HERE",
"/type/reflect/any_reverse":{
"id":null,
"link":{
"master_property":"/community/discussion_thread/post"
}
}
}
} Will give me the ID of the discussion thread associated with the named document.
Explanation:
/type/reflect is a "virtual type" on all topics whose purpose is to provide "lower level" access to all of the links on a topic. /type/reflect/any_reverse references all of the incoming (non-literal bearing) links of a topic. The "id":null clause above will be filled out with the id of the thread. "link" refers to the link between the topics, and all links have a "master_property", which refers to the property ID of the link in the forward direction.More information on /type/reflect can be found in the Top-Level Queries section of the Schema Introspection Cookbook.
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