/**
     * @param string $kw
     * @return array
     */
    public function keywordsAutocomplete( $kw = null )
    {
        $regularResults = parent::keywordsAutocomplete();

        foreach( $regularResults as $k => $v )
            $regularResults[$k]['type'] = 'r';
        
        if( is_null($kw) )
            $kw = isset($_GET['term']) ? $_GET['term'] : '';
        
        $input = mb_strtolower( $kw, 'UTF-8' );
        
        $solrFilter         = $this->solrFilter();
        $solrFacetsFiler    = $this->solrFacetsFilter();
        
        if( $solrFilter )
            $filters[] = $solrFilter;

        if( $solrFacetsFiler )
            $filters[] = $solrFacetsFiler;

        $filters[] = sprintf( 'attr_headline_lc_s:%s*', $input );
        
        $params = array( 'q'       => '*:*',
                         'qt'      => 'ezpublish',
                         'defType' => 'edismax',
                         'rows'    => 5,
                         'fl'      => 'meta_main_node_id_si, attr_headline_t, subattr_section___source_id____s',
                         'fq'      => implode( ' AND ', $filters ),
                         'json.nl' => 'arrarr' );

        $solrResults = MerckManualFunctionCollection::rawSearch($params);
        $topics      = array();

        if( $solrResults['response']['numFound'] )
        {
            foreach( $solrResults['response']['docs'] as $doc )
            {
                $sectionId      = $doc['subattr_section___source_id____s'][0];
                $topicUrlResult = MerckManualFunctionCollection::fetchUnifiedUrl( $sectionId, null, $doc['meta_main_node_id_si'], 'topic' );
                $topics[]       = array(
                            'label' => $doc['attr_headline_t'],
                            'url'   =>  $topicUrlResult['result'],
                            'type'  => 't' );
            }
        }

        return array_merge( $topics, array_slice($regularResults, 0, 10 - count( $topics ) ) );
    }
    /**
     * @param string $path
     * @param MerckManualSection $app
     * @return eZContentObjectTreeNode
     */
    public static function findNodeFromPath( $path, $app )
    {
        if( preg_match('#^/\d+/(?P<section>.*?)[/\?]?#', $path, $match) )
        {
            foreach ( array('url', 'remote', 'name') as $attribute )
            {
                $section = MerckManualFunctionCollection::fetchSection( $attribute, $match['section'] );
                if ( $section )
                {
                    $app->section = $section;
                    break;
                }
            }

            return eZContentObjectTreeNode::fetch(MerckManualShowcase::rootNodeId());
        }
        else
            return false;
    }
    /**
     * @see ezfSolrDocumentFieldBase::getData()
     * @return array
     */
    public function getData()
    {
        $data           = parent::getData();
        $content        = $this->ContentObjectAttribute->content();
        
        /* @var $content array */
        foreach ( array_merge( self::taxonomyAttribute(), array_keys($content) ) as $taxonomyIdentifier )
        {
            $taxonomyValues              = isset( $content[$taxonomyIdentifier] ) ? $content[$taxonomyIdentifier] : array(); 
            $subattrSourceIdValues       = array();
            $subattrSourceIdFieldName    = self::getCustomSubattributeFieldName(
                                                $taxonomyIdentifier,
                                                'source_id');
            
            foreach ( $taxonomyValues as $taxonomyValue )
            {
                if( preg_match( '#^symptom_.*$#', $taxonomyValue ) )
                {
                    $sourceKey                  = $taxonomyValue;
                    $subattrSourceIdValues[]    = $sourceKey;
                    
                    // we need a few more things for the symptoms
                    /* @type $node eZContentObjectTreeNode */
                    $contentObject = $this->ContentObjectAttribute->object();
                    $node          = $contentObject->mainNode();
                    $clusters      = NodeTool::getArticleClusters($node);

                    foreach( $clusters as $cluster )
                    {
                        ClusterTool::setCurrentCluster($cluster);

                        $ini = eZINI::fetchFromFile('extension/'.$cluster.'/settings/site.ini');
                        $node->setCurrentLanguage( $ini->variable('RegionalSettings', 'ContentObjectLocale') );

                        $applicationLocalized = CacheApplicationTool::buildLocalizedApplicationByIdentifier( MerckManualShowcase::mainApplicationIdentifier() );
                        if ( !$applicationLocalized )
                            continue;

                        $customSymptomAttributeKey = 'attr_custom_symptom_'.$cluster.'_s';
                        $labelTranslations         = FacetFilteringTool::getTaxonomyTranslation( 'symptom' );
                        $label                     = $labelTranslations[$sourceKey];
                        $url                       = preg_replace( '#^[^/]+#', '', MerckManualFunctionCollection::getMerckManualNodeUrl( 'meck-manual-showcase', $node, $ini->variable('RegionalSettings', 'ContentObjectLocale') ) );

                        ClusterTool::resetCurrentCluster();

                        $customSymptomAttributeValueParts = array(
                            mb_strtolower(mb_substr(StringTool::removeAccents( StringTool::CJK2Pinyin($label) ), 0, 1)),
                            $label,
                            $url
                        );

                        $data[$customSymptomAttributeKey] = implode( '##', $customSymptomAttributeValueParts );
                    }
                }
                else if ( preg_match('#^222\.[0-9]+$#', $taxonomyValue ) )
                {
                    $sourceKey                  = $taxonomyValue;
                    $subattrSourceIdValues[]    = $sourceKey;

                    /* @type $node eZContentObjectTreeNode */
                    /* @type $dataMap eZContentObjectAttribute[] */
                    $contentObject                    = $this->ContentObjectAttribute->object();
                    $node                             = $contentObject->mainNode();
                    $clusters                         = NodeTool::getArticleClusters($node);
                    $customSymptomAttributeValueParts = array(
                        $content['layer_natom'][0],
                        $content['sub_layer_natom'][0],
                    );

                    foreach( $clusters as $cluster )
                    {
                        ClusterTool::setCurrentCluster($cluster);

                        $customSymptomAttributeKey        = 'attr_custom_layer_sublayer_natom_'.$cluster.'_s';
                        $data[$customSymptomAttributeKey] = implode( '##', $customSymptomAttributeValueParts );

                        ClusterTool::resetCurrentCluster();
                    }
                }
                else
                    $subattrSourceIdValues[] = trim( $taxonomyValue );
            }

            $data[$subattrSourceIdFieldName] = empty($subattrSourceIdValues) ? '' : $subattrSourceIdValues;
        }
        
        return $data;
    }
    /**
     * @param string $applicationName Compatibility with other getNodeUrl operators
     * @param eZContentObjectTreeNode $node
     * @param boolean $languageCode
     * @return string
     */
    public static function getMerckManualNodeUrl($applicationName, $node, $languageCode = false)
    {
        if( $languageCode )
            $node->setCurrentLanguage($languageCode);

        /* @type $dataMap eZContentObjectAttribute[] */
        $chapterNode = ( $node->attribute( 'depth' ) > 4 ) ? $node->fetchParent() : $node;
        $topicNode   = ( $node->attribute( 'depth' ) > 4 ) ? $node : null;
        $linkType    = is_null( $topicNode ) ? 'chapter' : 'topic';
        $dataMap     = $chapterNode->dataMap();

        if ( !$dataMap || !isset($dataMap['serialized_taxonomies']) || !$dataMap['serialized_taxonomies']->hasContent() )
            return "";

        $serial        = $dataMap['serialized_taxonomies']->content();
        $sectionRemote = null;

        if( isset($serial['section']) && is_array($serial['section']) )
            $sectionRemote = $serial['section'][0];

        $fetchResult = MerckManualFunctionCollection::fetchUnifiedUrl($sectionRemote, $chapterNode, $topicNode, $linkType);

        return $fetchResult['result'];
    }
    /**
     * @param string $path
     * @param MerckManualShowcase $app
     * @return bool|eZContentObjectTreeNode
     */
    public static function findNodeFromPath( $path, &$app )
    {
        /* We remove the publisher folder id at the beginning of the url as we already have it */
        $path                  = preg_replace('#^/\d+/#', '/', $path );

        $manualAppNode         = eZContentObjectTreeNode::fetch( self::rootNodeId() );
        $manualAppNodePathName = $manualAppNode->pathWithNames();
        $tabNodePath           = explode('/', substr($path, 1));
        $remoteId              = end($tabNodePath);

        if(preg_match('/^[a-f0-9]{32}$/', $remoteId))
        {
            $nodeRemote = eZContentObjectTreeNode::fetchByRemoteID($remoteId);

            if($nodeRemote instanceof eZContentObjectTreeNode)
            {
                $app->fullContext = 'topic';
                return $nodeRemote;
            }
        }

        $pathParts = explode('/', substr($path, 1));

        if ( $pathParts[0] == 'table' )
        {
            $app->fullContext = 'table';
            return eZContentObjectTreeNode::fetch($pathParts[1]);
        }

        // Url with topic
        list($sectionName, $chapterName, $topicName, $mediaType, $mediaName, $other) = $pathParts;

        // Url without topic
        $matches = array();

        if ( preg_match('/media-([a-z]+)/', $topicName, $matches) )
        {
            list($sectionName, $chapterName, $mediaType, $mediaName, $other) = $pathParts;
            $topicName = null;
        }

        // Full section
        if ( $sectionName != null && is_null( $chapterName ) && is_null( $topicName ) )
        {
            $app->fullContext = 'section';
            $app->section = MerckManualFunctionCollection::fetchSection('url', $sectionName);
            return eZContentObjectTreeNode::fetch(MerckManualShowcase::rootNodeId());
        }
        if ( $sectionName == 'about-us' )
        {
            list($chapterName, $topicName, $mediaType, $mediaName, $other) = $pathParts;
        }

        $path = $manualAppNodePathName;
        // Full of chapter
        if ( $chapterName )
        {
            $app->fullContext = 'chapter';
            $path .= '/' . $chapterName;
        }

        // Full of topic
        if ( $topicName )
        {
            $app->fullContext = 'topic';
            $path .= '/' . $topicName;
        }

        $nodeId = eZURLAliasML::fetchNodeIDByPath($path);

        if ( $nodeId )
        {
            if ( $mediaName )
            {
                $mediaType = str_replace('media-', '', $mediaType);

                // Get media node
                // Full of html table image
                // /topic_name/(media-image-file)/oscar2/filename
                if ( $mediaType == 'image-file' )
                {
                    $app->fullContext = $mediaType;
                    $app->oscarFolder = $mediaName;
                    $app->mediaName = $other;
                }

                // Full of inline audio, video, image
                elseif ( $mediaType )
                {
                    // Construct the remote_id of the media folder
                    /* @type $dataMap eZContentObjectAttribute[] */
                    $contentObject        = eZContentObject::fetchByNodeID($nodeId);
                    $dataMap              = $contentObject->dataMap();
                    $publisherAttrContent = $dataMap['publisher']->content();

                    if ( isset($publisherAttrContent['relation_list'][0]['contentobject_remote_id']) )
                    {
                        // Get media folder
                        $mediaFolderRemoteId = sprintf('%s_media_%s', $publisherAttrContent['relation_list'][0]['contentobject_remote_id'], $mediaType);
                        $mediaFolder = eZContentObject::fetchByRemoteID($mediaFolderRemoteId);

                        if ( $mediaFolder )
                        {
                            // Get media
                            $mediaFolderPathName = $mediaFolder->mainNode()->pathWithNames();
                            $nodeId = eZURLAliasML::fetchNodeIDByPath($mediaFolderPathName . '/' . $mediaName);
                            $app->fullContext = $mediaType;
                        }
                    }
                }
            }
        }

        if ( $nodeId )
        {
            // Full of chapter must not be accessible, show first topic
            if ( $app->fullContext == 'chapter' )
            {
                $params = array(
                    'Depth'         => 1,
                    'DepthOperator' => 'eq',
                    'SortBy'        => array(array('priority', 'asc')),
                    'Limit'         => 1
                );
                $children = eZContentObjectTreeNode::subTreeByNodeID($params, $nodeId);

                if ( isset($children[0]) && $children[0] instanceof eZContentObjectTreeNode )
                {
                    $node = $children[0];
                    $app->fullContext = 'topic';
                }
                else
                    $node = null;
            }
            else
            {
                $node = eZContentObjectTreeNode::fetch($nodeId);
            }

            return $node;
        }

        return false;
    }
 /**
  * Return the right url of a node with application name and the node
  * (Used in the getUrlNode Override factory only)
  *
  * @param string $applicationName Identifier of the application
  * @param eZContentObjectTreeNode $node The article
  * @param string|boolean $languageCode
  *
  * @return null|string
  */
 public static function getMerckManualNodeUrl($applicationName, $node, $languageCode = false)
 {
     return MerckManualFunctionCollection::getMerckManualNodeUrl($applicationName, $node, $languageCode );
 }
    /**
     * The modify method gets the current content object AND the list of
     * Solr Docs (for each available language version).
     *
     * @param eZContentObject $contentObject
     * @param eZSolrDoc[] $docList
     */
    public function modify( eZContentObject $contentObject, &$docList )
    {
        /* @var eZContentObjectTreeNode $contentMainNode */
        $contentMainNode        = $contentObject->mainNode();
        $contentObjectLanguages = $contentObject->allLanguages();
        $articleLanguageArray   = array_keys($contentObjectLanguages);
        $publisherFolderNodeId  = PublisherFolderTool::getPublisherNodeIdFromArticleNode($contentMainNode);
        $isMerckManualShowcase  = false;
        // Depth : 0 => father article, 1+ => child article
        $articleRelativeDepth   = $contentMainNode->attribute('depth') - 4;

        if ( is_null($publisherFolderNodeId) )
            return;

        $publisherFolderInfos = PublisherFolderTool::getPublisherFolderInfosFromNodeId($publisherFolderNodeId);
        
        if ( !$publisherFolderInfos )
            return;

        $publisherFolderRelations = PublisherFolderTool::getPublisherFolderRelations($publisherFolderInfos['path']);

        if ( !$publisherFolderRelations || count($publisherFolderRelations['clusters']) === 0 )
            return;

        // node remote
        $remote = $contentMainNode->attribute("remote_id");
        $this->addValueToDoc( $docList, 'attr_node_remote_s', $remote);
        $this->addValueToDoc( $docList, 'attr_relative_depth_i', $articleRelativeDepth);

        foreach ( $publisherFolderRelations['clusters'] as $cluster => $applications )
        {
            ClusterTool::setCurrentCluster( $cluster );
            
            $applicationIdentifier = $applications[0];

            /* @var $applicationLocalized ApplicationLocalized */
            $applicationLocalized = CacheApplicationTool::buildLocalizedApplicationByIdentifier( $applicationIdentifier );

            if ( !($applicationLocalized instanceof ApplicationLocalized) )
            {
                if (count($applications) == 1)
                {
                    unset($publisherFolderRelations['clusters'][$cluster]);
                    continue;
                }

                $applicationIdentifier = $applications[1];
                $applicationLocalized = CacheApplicationTool::buildLocalizedApplicationByIdentifier( $applicationIdentifier );

                if ( !($applicationLocalized instanceof ApplicationLocalized) )
                {
                    unset($publisherFolderRelations['clusters'][$cluster]);
                    continue;
                }
                
                $publisherFolderRelations['clusters'][$cluster] = array ($applicationIdentifier);
            }

            // visibility per cluster
            $isVisible = ObjectVisibilityManager::isVisible($contentMainNode->attribute('contentobject_id'), $cluster);

            $this->addValueToDoc( $docList, 'attr_is_invisible_' . $cluster . '_b', !$isVisible );

            if (!isset(self::$_applicationIdentifierToId[$applicationIdentifier]))
                self::$_applicationIdentifierToId[$applicationIdentifier] = $applicationLocalized->applicationObject()->attribute ('id');

            $publisherFolder              = $applicationLocalized->getPublisherFolderFromPath($publisherFolderInfos['path']);
            $publisherLanguages           = $publisherFolder->getLanguages();
            $publisherAndArticleLanguages = array_intersect($publisherLanguages, $articleLanguageArray);

            if ( count($publisherAndArticleLanguages) == 0 )
                continue;

            $primaryLanguage = reset($publisherAndArticleLanguages);
            $contentMainNode->setCurrentLanguage($primaryLanguage);

            // publisher folder languages
            $languageKey       = 'subattr_language_' . $cluster . '____s';
            $formatedLanguages = array_map(
                array('kezfSolrArticleIndex', 'languageCode') ,
                $publisherAndArticleLanguages
            );

            $indexLanguages = array_unique( $formatedLanguages );

            $this->addValueToDoc( $docList, $languageKey, $indexLanguages, true, false );
            
            // Meck manual sections
            if( $applicationIdentifier == MerckManualShowcase::mainApplicationIdentifier() )
                $isMerckManualShowcase = true;

            // url computation
            /* @var eZContentObjectAttribute[] $dataMap */
            $dataMap = $contentMainNode->dataMap();

            ClusterTool::setCurrentCluster( $cluster );

            if( $applicationIdentifier == MerckManualShowcase::mainApplicationIdentifier() )
            {
                $urlContent = preg_replace(
                    '#^([^/]+/){2}#',
                    '',
                    MerckManualFunctionCollection::getMerckManualNodeUrl(
                        $applicationIdentifier,
                        $contentMainNode,
                        $primaryLanguage
                    )
                );
            }
            else
                $urlContent = preg_replace( '#^([^/]+/){2}#', '', $contentMainNode->urlAlias() );

            $this->addValueToDoc( $docList, 'attr_' . $cluster . '_url_s', $urlContent);

            $hasImage = array();

            for ( $mediaCase = 0; $mediaCase<=2; $mediaCase++ )
            {
                $hasImage[$mediaCase] = NodeOperatorHelper::hasImageArticle($contentMainNode, $mediaCase);
            }

            self::addValueToDoc( $docList, 'attr_has_image_' . $cluster . '_bst', base64_encode(json_encode($hasImage)) );

            $db = MMDB::instance();

            // index rating
            $row = $db->arrayQuery(sprintf("SELECT * FROM mm_rating_remote WHERE cluster_identifier = '%s' AND remote_id = '%s'", $cluster, $contentObject->remoteID()));
            if(count($row) && $row[0]["counter"] > 5 )
            {
                self::addValueToDoc( $docList, 'attr_content_rating_'.$cluster.'_f', $row[0]["total"]/$row[0]["counter"] );
                //update to_reindex
                $db->query(sprintf("UPDATE mm_rating_remote SET to_reindex=0 WHERE cluster_identifier = '%s' AND remote_id = '%s'", $cluster, $contentObject->remoteID()));
            }

            // index views
            $row = $db->arrayQuery(sprintf("SELECT * FROM mm_readcount_remote WHERE cluster_identifier = '%s' AND remote_id = '%s'", $cluster, $contentObject->remoteID()));
            if(count($row) && $row[0]["count"] > 0 )
            {
                self::addValueToDoc( $docList, 'attr_view_counter_'.$cluster.'_i', $row[0]["count"] );
                //update to_reindex
                $db->query(sprintf("UPDATE mm_readcount_remote SET to_reindex=0 WHERE cluster_identifier = '%s' AND remote_id = '%s'", $cluster, $contentObject->remoteID()));
            }

            if( $dataMap && $dataMap['media_content']->hasContent() )
            {
                $mediaContent      = $dataMap['media_content']->content();
                $mediaRelationList = $mediaContent['relation_list'];
                $entries           = array();
                $firstLink         = true;
                $totalQuizzes      = 0;

                foreach ( $mediaRelationList as $mediaRelation )
                {
                    $mediaObjectId = $mediaRelation['contentobject_id'];
                    $mediaClass = $mediaRelation['contentclass_identifier'];

                    /*******************************************************************************
                     * TODO : Adapt after PF Refactor
                     *******************************************************************************/
                    if ( !in_array($mediaClass, array('image', 'quiz', 'link')) )
                        continue;

                    
                    if ( $mediaClass === 'image' )
                    {
                        if ( count( $entries ) >= 3 )
                            continue;

                        // Language is DEPRECATED, Fake Language instead
                        $entries[] = $mediaObjectId . ";dep-DP";
                        /*******************************************************************************
                         * TODO : End : Adapt after PF Refactor
                         *******************************************************************************/
                    }
                    elseif ( ( $mediaClass === 'link' && $firstLink ) || $mediaClass === 'quiz' )
                    {
                        $mediaObject = eZContentObject::fetch( $mediaObjectId );

                        if ( !$mediaObject )
                            continue;

                        /* @var eZContentObjectAttribute[] $mediaDatamap */
                        $mediaDatamap = $mediaObject->dataMap();

                        if ( !is_array($mediaDatamap) )
                            continue;

                        if ( $mediaClass === 'link' )
                        {
                            if (!$mediaDatamap['url']->hasContent())
                                continue;

                            $firstLink = false;

                            self::addValueToDoc( $docList, 'attr_media_content_link_' . $cluster . '____ms', $mediaDatamap['url']->content(), false );
                        }
                        elseif ( $mediaClass === 'quiz' )
                        {
                            if ( $mediaDatamap['replies']->hasContent() )
                            {
                                $quizReplies = $mediaDatamap['replies']->content();
                                $quizReplies = $quizReplies->attribute('columns');
                                $quizReplies = $quizReplies['sequential'][1]['rows'];

                                if ( count($quizReplies) > 0 )
                                    self::addValueToDoc( $docList, 'attr_media_content_quiz_replies_' . $cluster . '____ms', $quizReplies, true);
                            }

                            if ( !empty($mediaDatamap['question']->DataText) )
                            {
                                self::addValueToDoc( $docList, 'attr_media_content_quiz_question_' . $cluster . '_ms', trim(strip_tags($mediaDatamap['question']->DataText)), false );
                            }

                            if ( !$mediaDatamap['points']->hasContent() )
                                continue;

                            $totalQuizzes+= $mediaDatamap['points']->content();
                        }
                    }
                }

                $withMediaDuration    = true;
                $typeMedias           = NodeOperatorHelper::getPictosMedia( $contentMainNode, $withMediaDuration );
                $typeMediasSerialized = base64_encode( json_encode($typeMedias) );

                // getPictosMedia as solr field
                self::addValueToDoc( $docList, 'attr_media_content_types_' . $cluster . '_bst', $typeMediasSerialized, false );

                // getMediaCount as solr field
                $mediaCount = NodeOperatorHelper::getMediaCount($contentMainNode);
                self::addValueToDoc( $docList, 'attr_media_content_count_' . $cluster . '_i', $mediaCount, false );

                // Used only for Quizz
                if ( $totalQuizzes > 0 )
                    self::addValueToDoc( $docList, 'attr_media_content_quiz_points_' . $cluster . '_i', $totalQuizzes, false );
            }
            
            unset($isHidden);
        }

        ClusterTool::resetCurrentCluster();

        $concernedNode = $contentMainNode;
        $concernedNode->setCurrentLanguage($articleLanguageArray[0]);

        if ( $contentMainNode->attribute('depth') > 4 )
        {
            $concernedNode = $contentMainNode->fetchParent();
            $concernedNode->setCurrentLanguage($articleLanguageArray[0]);
        }

        /* @type $concernedDM eZContentObjectAttribute[] */
        $concernedDM = $concernedNode->dataMap();
        $tags        = $concernedDM['tags'];

        $MerckManualAboutSectionId = eZIni::instance('merck.ini')->variable('MerckManualAboutSettings', 'SectionSourceId');
        $taxonomiesAttribute       = $concernedDM['serialized_taxonomies'];

        if( $taxonomiesAttribute instanceof eZContentObjectAttribute && $taxonomiesAttribute->hasContent() )
        {
            $taxonomies = $taxonomiesAttribute->content();

            foreach( array_keys($publisherFolderRelations['clusters']) as $cluster )
            {
                self::addValueToDoc(
                    $docList,
                    "attr_exclude_from_search_{$cluster}_b",
                    $MerckManualAboutSectionId && in_array($MerckManualAboutSectionId, $taxonomies['section']),
                    false
                );
            }
        }

        if( $tags instanceof eZContentObjectAttribute && $tags->hasContent() )
            self::addValueToDoc( $docList, 'subattr_tags____ms', explode("|", $tags->content()) );

        if ( $isMerckManualShowcase )
            $this->processSpecificMerckManual($docList, $concernedNode, $concernedDM, $publisherFolderRelations);

        foreach ( $publisherFolderRelations['clusters'] as $cluster => $applications )
        {
            ClusterTool::setCurrentCluster( $cluster );

            foreach( $applications as $key => $applicationIdentifier )
            {
                if ( !isset(self::$_applicationIdentifierToId[$applicationIdentifier]) )
                {
                    $applicationLocalized = CacheApplicationTool::buildLocalizedApplicationByIdentifier( $applicationIdentifier );

                    if( !($applicationLocalized instanceof ApplicationLocalized) )
                    {
                        eZDebug::writeError(
                            sprintf('Cluster: %s; Identifier: %s; ObjectId: %s', $cluster, $applicationIdentifier, $contentObject->attribute('id') ),
                            'Error getting application localized' );
                        unset( $publisherFolderRelations['clusters'][$cluster][$key] );
                    }
                    else
                        self::$_applicationIdentifierToId[$applicationIdentifier] = $applicationLocalized->applicationObject()->attribute('id');
                }
            }
        }

        ClusterTool::resetCurrentCluster();
        
        $applicationIds = array();

        foreach ( $publisherFolderRelations['clusters'] as $cluster => $applications )
            foreach( $applications as $applicationIdentifier )
                $applicationIds[] = self::$_applicationIdentifierToId[$applicationIdentifier];

        $uniqueApplicationIds = array_unique($applicationIds);

        foreach( $docList as $languageCode => $doc )
        {
            $dataMap               = $contentObject->fetchDataMap(false, $languageCode);
            $headline              = $dataMap['headline']->content();
            $headlineLowerCase     = mb_strtolower( StringTool::removeAccents($headline, 'utf-8', false), 'utf-8' );
            $unaccentedFirstLetter = mb_substr($headlineLowerCase, 0, 1, 'utf-8');

            $doc->addField( 'attr_headline_first_letter_lc_s', $unaccentedFirstLetter );
            $doc->addField( 'attr_headline_lc_s', $headlineLowerCase );

            foreach( $uniqueApplicationIds as $id )
            {
                $doc->addField( 'subattr_local_application___source_id____s', $id );
            }

            foreach( $publisherFolderRelations['clusters'] as $cluster => $applications )
            {
                foreach( $applications as $applicationIdentifier )
                {
                    $doc->addField('subattr_local_application___source_mixed____s', $cluster . '##unused##' . self::$_applicationIdentifierToId[$applicationIdentifier]);
                }
            }
        }
    }