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 »