Actually, the new features I’m talking about will also be in the MODx core, though I’m not sure if this is the final format. It will include two new API functions and a new array that maps parent documents to child documents, i.e.:
$modx->documentMap;
$modx->getParentIds($id);
$modx->getChildIds($id);
The new documentMap is a representation of the entire site map, persisted in the siteCache file. The two new API methods can then use that map to build an array of all the parent (getParentIds()) or all of the child document IDs (getChildIds()) from a specific document, without a single SQL query at runtime.
I created this specifically for the requirement of being able to use the FlexSearchForm snippet to query a finite set of documents without having to do complex queries, so we already have this tested and working as a proof of concept.