protected function createOn($meta, $fromIndex, $relatedMeta, $toIndex)
    {
        if (!isset($meta->indexes[$fromIndex])) {
            throw new Exception("Index $fromIndex does not exist on {$meta->id}");
        }
        if (!isset($relatedMeta->indexes[$toIndex])) {
            throw new Exception("Index $toIndex does not exist on {$relatedMeta->id}");
        }

        $on = [];

        // If an index exists, you don't need to join on all of it.
        // This assumes that the indexes are properly numbered. If not, BOOM!
        foreach ($meta->indexes[$fromIndex]['fields'] as $idx=>$fromField) {
            if (!isset($relatedMeta->indexes[$toIndex]['fields'][$idx])) {
                break;
            }
            $on[$fromField] = $relatedMeta->indexes[$toIndex]['fields'][$idx];
        }

        return $on;
    }