Пример #1
0
 /**
  * Provides suggestion results when adding tags to object
  *
  * @static
  * @param mixed $args
  * @return array
  */
 public static function suggest($args)
 {
     $tags = array();
     $siteINI = eZINI::instance('site.ini');
     if ($siteINI->variable('SearchSettings', 'SearchEngine') == 'ezsolr' && class_exists('eZSolr')) {
         $tagsCount = 1;
         $filteredTagsArray = array();
         $http = eZHTTPTool::instance();
         $tagsString = $http->postVariable('tags_string');
         $tagsArray = explode('|#', $tagsString);
         $subTreeLimit = $http->postVariable('subtree_limit');
         $hideRootTag = $http->postVariable('hide_root_tag') == '1' ? true : false;
         if (!empty($tagsArray) && strlen(trim($tagsArray[0])) > 0) {
             $solrFilter = '"' . trim($tagsArray[0]) . '"';
             $filteredTagsArray[] = strtolower(trim($tagsArray[0]));
             for ($i = 1; $i < count($tagsArray); $i++) {
                 if (strlen(trim($tagsArray[$i])) > 0) {
                     $solrFilter = $solrFilter . ' OR "' . trim($tagsArray[$i]) . '"';
                     $filteredTagsArray[] = strtolower(trim($tagsArray[$i]));
                     $tagsCount++;
                 }
             }
             $solrFilter = 'ezf_df_tags:(' . $solrFilter . ')';
             $solrSearch = new eZSolr();
             $params = array('SearchOffset' => 0, 'SearchLimit' => 0, 'Facet' => array(array('field' => 'ezf_df_tags', 'limit' => 5 + $tagsCount, 'mincount', 1)), 'SortBy' => null, 'Filter' => $solrFilter, 'QueryHandler' => 'ezpublish', 'FieldsToReturn' => null);
             $searchResult = $solrSearch->search('', $params);
             $facetResult = $searchResult['SearchExtras']->attribute('facet_fields');
             $facetResult = $facetResult[0]['nameList'];
             $tags = array();
             foreach ($facetResult as $facetValue) {
                 if (!in_array(strtolower($facetValue), $filteredTagsArray)) {
                     $tags[] = trim($facetValue);
                 }
             }
             if (!empty($tags)) {
                 $tags = eZTagsObject::fetchByKeyword(array($tags));
             }
         }
     }
     $returnArray = array();
     $returnArray['status'] = 'success';
     $returnArray['message'] = '';
     $returnArray['tags'] = array();
     foreach ($tags as $tag) {
         if (!$subTreeLimit > 0 || $subTreeLimit > 0 && strpos($tag->attribute('path_string'), '/' . $subTreeLimit . '/') !== false) {
             if (!$hideRootTag || $hideRootTag && $tag->attribute('id') != $subTreeLimit) {
                 $returnArrayChild = array();
                 $returnArrayChild['tag_parent_id'] = (int) $tag->attribute('parent_id');
                 $returnArrayChild['tag_parent_name'] = $tag->hasParent() ? $tag->getParent()->attribute('keyword') : '';
                 $returnArrayChild['tag_name'] = $tag->attribute('keyword');
                 $returnArrayChild['tag_id'] = (int) $tag->attribute('id');
                 $returnArray['tags'][] = $returnArrayChild;
             }
         }
     }
     return $returnArray;
 }
Пример #2
0
 /**
  * Regression test for issue #17576
  * Expected : Result from Solr should holds local Node when searching with subtree_array
  * @link http://issues.ez.no/17576
  * @group issue17576
  */
 public function testNodeIDWithSubtreeArray()
 {
     $expectedNodeID = 0;
     foreach ($this->object->nodes as $node) {
         if (strpos($node->attribute('path_string'), '/1/43/') === 0) {
             $expectedNodeID = $node->attribute('node_id');
         }
     }
     $res = $this->solrSearch->search('foo', array('SearchOffset' => 0, 'SearchLimit' => 1, 'SearchContentClassID' => 'folder', 'SearchSubTreeArray' => array(43), 'AsObjects' => true, 'IgnoreVisibility' => false, 'QueryHandler' => 'ezpublish', 'EnableElevation' => true, 'ForceElevation' => false));
     self::assertEquals($expectedNodeID, $res['SearchResult'][0]->attribute('node_id'), 'Result from Solr should holds local Node when searching with subtree_array');
 }
    /**
     * test for generateConfiguration()
     */
    public function testGenerateConfiguration()
    {
        // clean up the table beforehand
        $db = eZDB::instance();
        $rows = $db->query('TRUNCATE TABLE ezfind_elevate_configuration;');
        $solr = new eZSolr();
        # start 1
        $queryString = "test 1";
        $objectID = 1;
        $object = eZContentObject::fetch($objectID);
        $language = "eng-GB";
        $docId = $solr->guid($object, $language);
        eZFindElevateConfiguration::add($queryString, $objectID, $language);
        eZFindElevateConfigurationTester::generateConfiguration();
        $configuration1 = eZFindElevateConfigurationTester::getConfiguration();
        $expected1 = <<<ENDT
<?xml version="1.0" encoding="UTF-8"?>
<elevate><query text="test 1"><doc id="
ENDT;
        $expected1 .= $docId;
        $expected1 .= <<<ENDT
"/></query></elevate>

ENDT;
        self::assertEquals($expected1, $configuration1);
        # end 1
    }
Пример #4
0
    /**
     * Helper for solr raw searches.
     * Deals with the language, meta_installation, section and visibility filters + solr sharding if any
     * @param array $params
     * @param string $requestType
     * @param bool $useDefaultFilters
     * @return array
     */
    public static function rawSearch( $params, $requestType = 'php', $useDefaultFilters = true, $includeIsInvisible = true )
    {
        eZDebug::accumulatorStart( __CLASS__ . '::' . __FUNCTION__, 'Merck' );

        $findINI = eZINI::instance( 'ezfind.ini' );
        $solrINI = eZINI::instance( 'solr.ini' );
        $siteINI = eZINI::instance();
        $currentLanguage = $siteINI->variable( 'RegionalSettings', 'ContentObjectLocale' );

        // always use extended Dismax query handler when available
        if( isset($params['qt']) && $params['qt'] == 'ezpublish' )
            $params['defType'] = 'edismax';

        if ( $useDefaultFilters )
        {
            if ( !isset( $params['fq'] ) )
                $params['fq'] = '';
            else
                $params['fq'] .= ' AND ';
            $params['fq'] .= implode( ' AND ', array(
                'meta_installation_id_ms:' . eZSolr::installationID(),
                '(attr_offline_date_dt:"1970-01-01T01:00:00Z" OR attr_offline_date_dt:[NOW TO *])',
                '( meta_section_id_si:1 OR meta_section_id_si:3 )',
            ) );
            if ($includeIsInvisible) {
                $params['fq'] .= ' AND ' . 'attr_is_invisible_' . ClusterTool::clusterIdentifier() . '_b:false';
            }
        }

        if ( $findINI->variable( 'LanguageSearch', 'MultiCore' ) == 'enabled' )
        {
            $languageMapping = $findINI->variable( 'LanguageSearch', 'LanguagesCoresMap' );
            $shardMapping = $solrINI->variable( 'SolrBase', 'Shards' );
            $fullSolrURI = $shardMapping[$languageMapping[$currentLanguage]];
        }
        else
        {
            $fullSolrURI = $solrINI->variable( 'SolrBase', 'SearchServerURI' );
            // Autocomplete search should be done in current language and fallback languages
            $validLanguages = array_unique(
                array_merge(
                    LocaleTool::languageList(),
                    array( $currentLanguage )
                )
            );
            if( $useDefaultFilters )
                $params['fq'] .= ' AND meta_language_code_ms:(' . implode( ' OR ', $validLanguages ) . ')';
        }

        solrTool::solrStopWordsFilter( $params );    //excluding stopwords
        self::parseBooleanOperators( $params );      // translations for bookean operators
        $solrBase = new eZSolrBase( $fullSolrURI );
        $result = $solrBase->rawSolrRequest( '/select', $params, $requestType );
        if ( !$result )
            self::addNoCacheHeaders();
        
        eZDebug::accumulatorStop( __CLASS__ . '::' . __FUNCTION__ );

        return $result;
    }
 /**
  * Modifies SolR query params according to filter parameters
  * @param array $queryParams
  * @param array $filterParams
  * @return array $queryParams
  */
 public function filterQueryParams(array $queryParams, array $filterParams)
 {
     try {
         if (!isset($filterParams['field'])) {
             throw new Exception('Missing filter parameter "field"');
         }
         if (!isset($filterParams['latitude'])) {
             throw new Exception('Missing filter parameter "latitude"');
         }
         if (!isset($filterParams['longitude'])) {
             throw new Exception('Missing filter parameter "longitude"');
         }
         $fieldName = eZSolr::getFieldName($filterParams['field']);
         //geodist custom parameters
         $queryParams['sfield'] = $fieldName;
         $queryParams['pt'] = $filterParams['latitude'] . ',' . $filterParams['longitude'];
         //sort by geodist
         $queryParams['sort'] = 'geodist() asc,' . $queryParams['sort'];
         //exclude unlocated documents
         $queryParams['fq'][] = $fieldName . ':[-90,-90 TO 90,90]';
     } catch (Exception $e) {
         eZDebug::writeWarning($e->getMessage(), __CLASS__);
     }
     return $queryParams;
 }
 protected static function getChildrenClasses($parentNodeId)
 {
     $childrenClassTypes = array();
     if ($parentNode = self::getNode($parentNodeId)) {
         // ricavo gli identifiers delle classi e le classi
         $childrenClassTypes = array();
         $childrenClassesParamers = array('SearchSubTreeArray' => array($parentNode->attribute('node_id')), 'SearchLimit' => 1, 'Filter' => array('-meta_id_si:' . $parentNode->attribute('contentobject_id')), 'AsObjects' => false, 'Facet' => array(array('field' => 'meta_class_identifier_ms', 'name' => 'class_identifier', 'limit' => 200)));
         $solr = new eZSolr();
         $search = $solr->search('', $childrenClassesParamers);
         if ($search['SearchCount'] > 0) {
             $facets = $search['SearchExtras']->attribute('facet_fields');
             $childrenClassTypes = $facets[0]['nameList'];
         }
         if (!empty($childrenClassTypes)) {
             $childrenClassTypes = (array) eZContentClass::fetchList(0, true, false, null, null, $childrenClassTypes);
         }
     }
     return $childrenClassTypes;
 }
Пример #7
0
 /**
  * Provides suggestion results when adding tags to object
  *
  * @static
  *
  * @param array $args
  *
  * @return array
  */
 public static function suggest($args)
 {
     $http = eZHTTPTool::instance();
     $searchEngine = eZINI::instance()->variable('SearchSettings', 'SearchEngine');
     if (!class_exists('eZSolr') || $searchEngine != 'ezsolr') {
         return array('status' => 'success', 'message' => '', 'tags' => array());
     }
     $tagIDs = $http->postVariable('tag_ids', '');
     if (empty($tagIDs)) {
         return array('status' => 'success', 'message' => '', 'tags' => array());
     }
     $tagIDs = array_values(array_unique(explode('|#', $tagIDs)));
     $solrSearch = new eZSolr();
     $params = array('SearchOffset' => 0, 'SearchLimit' => 0, 'Facet' => array(array('field' => 'ezf_df_tag_ids', 'limit' => 5 + count($tagIDs), 'mincount' => 1)), 'Filter' => array('ezf_df_tag_ids' => implode(' OR ', $tagIDs)), 'QueryHandler' => 'ezpublish', 'AsObjects' => false);
     $searchResult = $solrSearch->search('', $params);
     if (!isset($searchResult['SearchExtras']) || !$searchResult['SearchExtras'] instanceof ezfSearchResultInfo) {
         eZDebug::writeWarning('There was an error fetching tag suggestions from Solr. Maybe server is not running or using unpatched schema?', __METHOD__);
         return array('status' => 'success', 'message' => '', 'tags' => array());
     }
     $facetResult = $searchResult['SearchExtras']->attribute('facet_fields');
     if (!is_array($facetResult) || !is_array($facetResult[0]['nameList'])) {
         eZDebug::writeWarning('There was an error fetching tag suggestions from Solr. Maybe server is not running or using unpatched schema?', __METHOD__);
         return array('status' => 'success', 'message' => '', 'tags' => array());
     }
     $facetResult = array_values($facetResult[0]['nameList']);
     $tagsToSuggest = array();
     foreach ($facetResult as $result) {
         if (!in_array($result, $tagIDs)) {
             $tagsToSuggest[] = $result;
         }
     }
     if (empty($tagsToSuggest)) {
         return array('status' => 'success', 'message' => '', 'tags' => array());
     }
     return self::generateOutput(array('id' => array($tagsToSuggest)), 0, false, $http->postVariable('locale', ''));
 }
Пример #8
0
 /**
  * Returns search results based on given params
  *
  * @param mixed $args
  * @return array
  * @deprecated Use ezjsc::search instead (in ezjscore)
  */
 public static function search($args)
 {
     $http = eZHTTPTool::instance();
     if ($http->hasPostVariable('SearchStr')) {
         $searchStr = trim($http->postVariable('SearchStr'));
     }
     $searchOffset = 0;
     if ($http->hasPostVariable('SearchOffset')) {
         $searchOffset = (int) $http->postVariable('SearchOffset');
     }
     $searchLimit = 10;
     if ($http->hasPostVariable('SearchLimit')) {
         $searchLimit = (int) $http->postVariable('SearchLimit');
     }
     if ($searchLimit > 30) {
         $searchLimit = 30;
     }
     if ($http->hasPostVariable('SearchSubTreeArray') && $http->postVariable('SearchSubTreeArray')) {
         $search_sub_tree_array = explode(',', $http->postVariable('SearchSubTreeArray'));
     }
     //Prepare the search params
     $param = array('SearchOffset' => $searchOffset, 'SearchLimit' => $searchLimit + 1, 'SortArray' => array('score', 0), 'SearchSubTreeArray' => $search_sub_tree_array);
     if ($http->hasPostVariable('enable-spellcheck') and $http->postVariable('enable-spellcheck') == 1) {
         $param['SpellCheck'] = array(true);
     }
     if ($http->hasPostVariable('show-facets') and $http->postVariable('show-facets') == 1) {
         $defaultFacetFields = eZFunctionHandler::execute('ezfind', 'getDefaultSearchFacets', array());
         $param['facet'] = $defaultFacetFields;
     }
     $solr = new eZSolr();
     $searchList = $solr->search($searchStr, $param);
     $result = array();
     $result['SearchResult'] = eZFlowAjaxContent::nodeEncode($searchList['SearchResult'], array(), false);
     $result['SearchCount'] = $searchList['SearchCount'];
     $result['SearchOffset'] = $searchOffset;
     $result['SearchLimit'] = $searchLimit;
     $result['SearchExtras'] = array();
     if (isset($param['SpellCheck'])) {
         $result['SearchExtras']['spellcheck'] = $searchList['SearchExtras']->attribute('spellcheck');
     }
     if (isset($param['facet'])) {
         $facetInfo = array();
         $retrievedFacets = $searchList['SearchExtras']->attribute('facet_fields');
         $baseSearchUrl = "/content/search/";
         eZURI::transformURI($baseSearchUrl, false, 'full');
         foreach ($defaultFacetFields as $key => $defaultFacet) {
             $facetData = $retrievedFacets[$key];
             $facetInfo[$key] = array();
             $facetInfo[$key][] = $defaultFacet['name'];
             if ($facetData != null) {
                 foreach ($facetData['nameList'] as $key2 => $facetName) {
                     $tmp = array();
                     if ($key2 != '') {
                         $tmp[] = $baseSearchUrl . '?SearchText=' . $searchStr . '&filter[]=' . $facetData['queryLimit'][$key2] . '&activeFacets[' . $defaultFacet['field'] . ':' . $defaultFacet['name'] . ']=' . $facetName;
                         $tmp[] = $facetName;
                         $tmp[] = "(" . $facetData['countList'][$key2] . ")";
                         $facetInfo[$key][] = $tmp;
                     }
                 }
             }
         }
         $result['SearchExtras']['facets'] = $facetInfo;
     }
     return $result;
 }
Пример #9
0
 /**
  * Clean all indices in current Solr core, regardless of installation id's
  * Only clean-up if --clean-all is set
  */
 protected function cleanUpAll()
 {
     if ($this->Options['clean-all']) {
         $this->CLI->output("eZSearchEngine: Cleaning up search data for all installations");
         $searchEngine = new eZSolr();
         // The essence of teh All suffix
         $allInstallations = true;
         // Optimize: sets all indexes to minimal file size too
         $optimize = true;
         $searchEngine->cleanup($allInstallations, $optimize);
     }
 }
Пример #10
0
$wrong_path = array();



if ( !$top_node_id )
{
    $cli->error('Please provide a top node id');
    $script->shutdown(1);
}

$script->initialize();

$cli->output('Getting solr results for ' . $top_node_id);

/* @var $solr eZSolr */
$solr = new eZSolr();
$solrBase = new eZSolrBase();

$params = array(
    'indent'       => 'on',
    'q'            => '',
    'fq'           => 'meta_installation_id_ms:' . eZSolr::installationID() . ' AND meta_path_si:' . $top_node_id,
    'start'        => 0,
    'rows'         => 0,
    'fl'           => 'meta_main_url_alias_ms,meta_main_node_id_si,meta_name_t,meta_guid_ms,meta_language_code_ms',
    'qt'           => 'ezpublish',
    'explainOther' => '',
    'hl.fl'        => '',
);

$r = $solrBase->rawSolrRequest('/select', $params);
Пример #11
0
function solrFilter ($publisherNode)
{
	$pathString = $publisherNode->attribute('path_string');
	$filters = array(
            "meta_class_identifier_ms:article",
			"main_node_meta_path_string_ms:$pathString*",
			'meta_installation_id_ms:' . eZSolr::installationID(),
	);
	
	return implode(' AND ', $filters);
}
Пример #12
0
 /**
  * Returns the tag cloud for specified parameters using eZ Find
  *
  * @param array $params
  *
  * @return array
  */
 private function solrTagCloud($params)
 {
     $offset = 0;
     if (isset($params['offset']) && is_numeric($params['offset'])) {
         $offset = (int) $params['offset'];
     }
     // It seems that Solr doesn't like PHP_INT_MAX constant on 64bit operating systems
     $limit = 1000000;
     if (isset($params['limit']) && is_numeric($params['limit'])) {
         $limit = (int) $params['limit'];
     }
     $searchFilter = array();
     if (isset($params['class_identifier'])) {
         if (!is_array($params['class_identifier'])) {
             $params['class_identifier'] = array($params['class_identifier']);
         }
         if (!empty($params['class_identifier'])) {
             $searchFilter['meta_class_identifier_ms'] = '(' . implode(' OR ', $params['class_identifier']) . ')';
         }
     }
     if (isset($params['parent_node_id'])) {
         $searchFilter['meta_path_si'] = (int) $params['parent_node_id'];
     }
     $solrSearch = new eZSolr();
     $solrParams = array('SearchOffset' => 0, 'SearchLimit' => 1000000, 'Facet' => array(array('field' => 'ezf_df_tag_ids', 'limit' => 1000000)), 'Filter' => $searchFilter, 'QueryHandler' => 'ezpublish', 'AsObjects' => false);
     $searchResult = $solrSearch->search('*:*', $solrParams);
     if (!isset($searchResult['SearchExtras']) || !$searchResult['SearchExtras'] instanceof ezfSearchResultInfo) {
         return array();
     }
     $facetResult = $searchResult['SearchExtras']->attribute('facet_fields');
     if (!is_array($facetResult) || empty($facetResult[0]['countList'])) {
         return array();
     }
     $tagsCountList = $facetResult[0]['countList'];
     /** @var eZTagsObject[] $tags */
     $tags = eZTagsObject::fetchList(array('id' => array(array_keys($tagsCountList))));
     if (!is_array($tags) || empty($tags)) {
         return array();
     }
     $tagSortArray = array();
     $tagKeywords = array();
     $tagCounts = array();
     foreach ($tags as $tag) {
         $tagKeyword = $tag->attribute('keyword');
         $tagCount = $tagsCountList[(int) $tag->attribute('id')];
         $tagSortArray[] = array('keyword' => $tagKeyword, 'count' => $tagCount, 'tag' => $tag);
         $tagKeywords[] = $tagKeyword;
         $tagCounts[] = $tagCount;
     }
     // calling call_user_func_array requires all arguments to be references
     // this is the reason for $sortFlags array and $sortArgs[] = &....
     $sortArgs = array();
     $sortFlags = array(SORT_ASC, SORT_DESC, SORT_LOCALE_STRING, SORT_NUMERIC);
     if (isset($params['sort_by']) && is_array($params['sort_by']) && !empty($params['sort_by'])) {
         $params['sort_by'] = is_string($params['sort_by'][0]) ? array($params['sort_by']) : $params['sort_by'];
         foreach ($params['sort_by'] as $sortItem) {
             if (is_array($sortItem) && !empty($sortItem)) {
                 switch ($sortItem[0]) {
                     case 'keyword':
                         $sortArgs[] =& $tagKeywords;
                         if (isset($sortItem[1]) && $sortItem[1]) {
                             $sortArgs[] =& $sortFlags[0];
                         } else {
                             $sortArgs[] =& $sortFlags[1];
                         }
                         $sortArgs[] =& $sortFlags[2];
                         break;
                     case 'count':
                         $sortArgs[] =& $tagCounts;
                         if (isset($sortItem[1]) && $sortItem[1]) {
                             $sortArgs[] =& $sortFlags[0];
                         } else {
                             $sortArgs[] =& $sortFlags[1];
                         }
                         $sortArgs[] =& $sortFlags[3];
                         break;
                 }
             }
         }
     }
     if (empty($sortArgs)) {
         $sortArgs[] =& $tagKeywords;
         $sortArgs[] =& $sortFlags[0];
     }
     $sortArgs[] =& $tagSortArray;
     call_user_func_array('array_multisort', $sortArgs);
     $tagSortArray = array_slice($tagSortArray, $offset, $limit);
     if (empty($tagSortArray)) {
         return array();
     }
     $tagKeywords = array_slice($tagKeywords, $offset, $limit);
     $tagCounts = array_slice($tagCounts, $offset, $limit);
     if (isset($params['post_sort_by'])) {
         if ($params['post_sort_by'] === 'keyword') {
             array_multisort($tagKeywords, SORT_ASC, SORT_LOCALE_STRING, $tagSortArray);
         } else {
             if ($params['post_sort_by'] === 'keyword_reverse') {
                 array_multisort($tagKeywords, SORT_DESC, SORT_LOCALE_STRING, $tagSortArray);
             } else {
                 if ($params['post_sort_by'] === 'count') {
                     array_multisort($tagCounts, SORT_ASC, SORT_NUMERIC, $tagSortArray);
                 } else {
                     if ($params['post_sort_by'] === 'count_reverse') {
                         array_multisort($tagCounts, SORT_DESC, SORT_NUMERIC, $tagSortArray);
                     }
                 }
             }
         }
     }
     $this->normalizeTagCounts($tagSortArray, $tagCounts);
     return $tagSortArray;
 }
Пример #13
0
 private function eject($objectId)
 {
     $object = eZContentObject::fetch($objectId);
     if ($object) {
         $engine = new eZSolr();
         $engine->removeObjectById($objectId);
     } else {
         echo "invalid object id\n";
     }
 }
Пример #14
0
 /**
  * Get attribute value
  *
  * @param string Attribute name
  *
  * @return mixed Attribute value. null if attribute does not exist.
  */
 public function attribute($attr)
 {
     switch ($attr) {
         case 'responseHeader':
             return $this->ResultArray['responseHeader'];
             break;
         case 'hasError':
             return !empty($this->ResultArray['error']);
             break;
         case 'error':
             if (!empty($this->ResultArray['error'])) {
                 return $this->ResultArray['error'];
             }
             break;
         case 'facet_queries':
             if (!empty($this->FacetQueries)) {
                 return $this->FacetQueries;
             }
             // If the facets count is empty, an error has occured.
             if (empty($this->ResultArray['facet_counts'])) {
                 return null;
             }
             $facetArray = array();
             foreach ($this->ResultArray['facet_counts']['facet_queries'] as $query => $count) {
                 list($field, $fieldValue) = explode(':', $query);
                 $fieldInfo = array('field' => $field, 'count' => $count, 'queryLimit' => $query, 'fieldValue' => $fieldValue);
                 $facetArray[] = $fieldInfo;
             }
             $this->FacetQueries = $facetArray;
             return $this->FacetQueries;
             break;
         case 'facet_fields':
             if (!empty($this->FacetFields)) {
                 return $this->FacetFields;
             }
             // If the facets count is empty, an error has occured.
             if (empty($this->ResultArray['facet_counts'])) {
                 return null;
             }
             $facetArray = array();
             foreach ($this->ResultArray['facet_counts']['facet_fields'] as $field => $facetField) {
                 switch ($field) {
                     // class facet field
                     case eZSolr::getMetaFieldName('contentclass_id'):
                         $fieldInfo = array('field' => 'class', 'count' => count($facetField), 'nameList' => array(), 'queryLimit' => array(), 'fieldList' => array(), 'countList' => array());
                         foreach ($facetField as $contentClassID => $count) {
                             if ($contentClass = eZContentClass::fetch($contentClassID)) {
                                 $fieldInfo['nameList'][$contentClassID] = $contentClass->attribute('name');
                                 $fieldInfo['queryLimit'][$contentClassID] = 'contentclass_id:' . $contentClassID;
                                 $fieldInfo['countList'][$contentClassID] = $count;
                                 $fieldInfo['fieldList'][$contentClassID] = 'contentclass_id';
                             } else {
                                 eZDebug::writeWarning('Could not fetch eZContentClass: ' . $contentClassID, __METHOD__);
                             }
                         }
                         $facetArray[] = $fieldInfo;
                         break;
                         // instalaltion facet field
                     // instalaltion facet field
                     case eZSolr::getMetaFieldName('installation_id'):
                         $findINI = eZINI::instance('ezfind.ini');
                         $siteNameMapList = $findINI->variable('FacetSettings', 'SiteNameList');
                         $fieldInfo = array('field' => 'installation', 'count' => count($facetField), 'nameList' => array(), 'queryLimit' => array(), 'fieldList' => array(), 'countList' => array());
                         foreach ($facetField as $installationID => $count) {
                             $fieldInfo['nameList'][$installationID] = isset($siteNameMapList[$installationID]) ? $siteNameMapList[$installationID] : $installationID;
                             $fieldInfo['queryLimit'][$installationID] = 'installation_id:' . $installationID;
                             $fieldInfo['countList'][$installationID] = $count;
                             $fieldInfo['fieldList'][$installationID] = 'installation_id';
                         }
                         $facetArray[] = $fieldInfo;
                         break;
                         // author facet field
                     // author facet field
                     case eZSolr::getMetaFieldName('owner_id'):
                         $fieldInfo = array('field' => 'author', 'count' => count($facetField), 'nameList' => array(), 'queryLimit' => array(), 'fieldList' => array(), 'countList' => array());
                         foreach ($facetField as $ownerID => $count) {
                             if ($owner = eZContentObject::fetch($ownerID)) {
                                 $fieldInfo['nameList'][$ownerID] = $owner->attribute('name');
                                 $fieldInfo['queryLimit'][$ownerID] = 'owner_id:' . $ownerID;
                                 $fieldInfo['countList'][$ownerID] = $count;
                                 $fieldInfo['fieldList'][$ownerID] = 'owner_id';
                             } else {
                                 eZDebug::writeWarning('Could not fetch owner ( eZContentObject ): ' . $ownerID, __METHOD__);
                             }
                         }
                         $facetArray[] = $fieldInfo;
                         break;
                         // translation facet field
                     // translation facet field
                     case eZSolr::getMetaFieldName('language_code'):
                         $fieldInfo = array('field' => 'translation', 'count' => count($facetField), 'nameList' => array(), 'queryLimit' => array(), 'fieldList' => array(), 'countList' => array());
                         foreach ($facetField as $languageCode => $count) {
                             $fieldInfo['nameList'][$languageCode] = $languageCode;
                             $fieldInfo['queryLimit'][$languageCode] = 'language_code:' . $languageCode;
                             $fieldInfo['fieldList'][$languageCode] = 'language_code';
                             $fieldInfo['countList'][$languageCode] = $count;
                         }
                         $facetArray[] = $fieldInfo;
                         break;
                     default:
                         $fieldInfo = array('field' => $attr, 'count' => count($facetField), 'queryLimit' => array(), 'fieldList' => array(), 'nameList' => array(), 'countList' => array());
                         foreach ($facetField as $value => $count) {
                             $fieldInfo['nameList'][$value] = $value;
                             $fieldInfo['fieldList'][$value] = $field;
                             $fieldInfo['queryLimit'][$value] = $field . ':' . $value;
                             $fieldInfo['countList'][$value] = $count;
                         }
                         $facetArray[] = $fieldInfo;
                         break;
                 }
             }
             $this->FacetFields = $facetArray;
             return $this->FacetFields;
             break;
         case 'engine':
             return eZSolr::engineText();
             break;
             //may or may not be active, so returns false if not present
         //may or may not be active, so returns false if not present
         case 'spellcheck':
             if (isset($this->ResultArray['spellcheck']) && $this->ResultArray['spellcheck']['suggestions'] > 0) {
                 return $this->ResultArray['spellcheck']['suggestions'];
             } else {
                 return false;
             }
             break;
         case 'spellcheck_collation':
             if (isset($this->ResultArray['spellcheck']['suggestions']['collation'])) {
                 // work around border case if 'collation' is searched for but does not exist in the spell check index
                 // the collation string is the last element of the suggestions array
                 return end($this->ResultArray['spellcheck']['suggestions']);
             } else {
                 return false;
             }
             break;
             //only relevant for MoreLikeThis queries
         //only relevant for MoreLikeThis queries
         case 'interestingTerms':
             if (isset($this->ResultArray['interestingTerms'])) {
                 return $this->ResultArray['interestingTerms'];
             } else {
                 return false;
             }
             break;
         case 'facet_dates':
             if (isset($this->ResultArray['facet_dates'])) {
                 return $this->ResultArray['facet_dates'];
             } else {
                 return false;
             }
             break;
         case 'facet_ranges':
             if (isset($this->ResultArray['facet_counts']['facet_ranges'])) {
                 return $this->ResultArray['facet_counts']['facet_ranges'];
             } else {
                 return false;
             }
             break;
         case 'clusters':
             if (isset($this->ResultArray['clusters'])) {
                 return $this->ResultArray['clusters'];
             } else {
                 return false;
             }
             break;
         default:
             break;
     }
     return null;
 }
 /**
  * Generates the full Solr field name for a metadata subattribute.
  * Helper method to be used, if needed, by datatype-specific handlers.
  * Used particularly when indexing metadata of a related object.
  *
  * @param string $baseName
  * @param eZContentClassAttribute $classAttribute
  * @return string
  *
  * @example
  *      If $baseName equals 'main_url_alias', and $classAttribute
  *      has as identifier 'dummy', the return value will be :
  *      'submeta_dummy-main_url_alias_s'
  *
  * @see ezfSolrDocumentFieldObjectRelation
  */
 public static function generateSubmetaFieldName($baseName, eZContentClassAttribute $classAttribute)
 {
     return self::$DocumentFieldName->lookupSchemaName(self::SUBMETA_FIELD_PREFIX . $classAttribute->attribute('identifier') . self::SUBATTR_FIELD_SEPARATOR . $baseName, eZSolr::getMetaAttributeType($baseName));
 }
Пример #16
0
 /**
  * @dataProvider providerTestGetMetaAttributesForObject
  **/
 public function testGetMetaAttributesForObject($expected, $contentObject)
 {
     self::assertEquals($expected, eZSolr::getMetaAttributesForObject($contentObject));
 }
Пример #17
0
    /**
     * Returns the eZ publish installation ID, used by eZ find to identify sites
     * @return string installaiton ID.
     */
    static function installationID()
    {
        if ( !empty( self::$InstallationID ) )
        {
            return self::$InstallationID;
        }
        $db = eZDB::instance();

        $resultSet = $db->arrayQuery( 'SELECT value FROM ezsite_data WHERE name=\'ezfind_site_id\'' );

        if ( count( $resultSet ) >= 1 )
        {
            self::$InstallationID = $resultSet[0]['value'];
        }
        else
        {
            self::$InstallationID = md5( time() . '-' . mt_rand() );
            $db->query( 'INSERT INTO ezsite_data ( name, value ) values( \'ezfind_site_id\', \'' . self::$InstallationID . '\' )' );
        }

        return self::$InstallationID;
    }
Пример #18
0
<?php

/* @type $cli eZCli */
/* @type $script eZScript */

$clusters        = ClusterTool::globCluster();
$solrLimit       = 200;
$globalObjectIds = array();
$solrStart       = 0;
$orFilters       = array();
$filters         = array(
    'meta_installation_id_ms:' . eZSolr::installationID(),
    "meta_class_identifier_ms:article",
);
$rawSolrParams = array(
    'indent'        => 'on',
    'q'             => '',
    'fl'            => "meta_id_si",
    'rows'          => $solrLimit,
    'qt'            => 'ezpublish',
);

foreach ( $clusters as $cluster )
{
    $orFilters[] = "attr_{$cluster}_url_s:full/*";
}
$filters[] = "( " . implode(' OR ', $orFilters ) . " )";

$rawSolrParams['fq'] = implode(' AND ', $filters);

while (true)
    /**
     * @return array
     */
    public function getResponseSolr()
    {
        $applicationDictionaryRows = $this->prepareConfig();

        $forbiddenWords = NodeVisibilityCheck::getForbiddenWordsArray( $this->_cluster_identifier );
        $queryTerm = count($forbiddenWords) ? implode(' ', $forbiddenWords) : '*:*';

        foreach ( $applicationDictionaryRows as $applicationDictionaryRow )
        {
            // Get application node_id
            $applicationId = $applicationDictionaryRow['application_id'];

            /** @var ApplicationLocalized[] $_localApplication */
            $this->_localApplications[$applicationId] = CacheApplicationTool::buildLocalizedApplicationByApplication( $applicationId );

            $appLocalizedIsProper = ( $this->_localApplications[$applicationId] instanceof ApplicationLocalized );

            if ( !$appLocalizedIsProper )
            {
                eZDebug::writeError( sprintf( 'Cannot fetch localized application %s for cluster %s', $applicationId, $this->_cluster_identifier ), __FILE__ . '::' . __LINE__ );
                continue;
            }

            /* @type $validLanguages array */
            $newsletterStyle = $applicationDictionaryRow['newsletter_style'];
            $clusterSiteIni  = eZINI::fetchFromFile( "extension/{$this->_cluster_identifier}/settings/site.ini.append.php" );
            $validLanguages  = $clusterSiteIni->variable( 'RegionalSettings', 'SiteLanguageList' );

            // Common
            $fq = array(
                'meta_class_identifier_ms:"article"',
                '(attr_archive_date_dt:"1970-01-01T01:00:00Z" OR attr_archive_date_dt:[NOW TO *])',
                'meta_installation_id_ms:'.eZSolr::installationID(),
                'attr_is_invisible_' . $this->_cluster_identifier . '_b:false',
                'meta_language_code_ms:(' . implode( ' OR ', $validLanguages ) . ')',
            );
            
            $taxonomyList = json_decode( $applicationDictionaryRow['taxonomy_filter'], true );

            if(count($taxonomyList) > 0){
                foreach ($taxonomyList as $row) {
                    foreach($row as $taxonomyCategory => $taxonomies){
                        $taxonomies = array_map(function($value) { return '"' . $value . '"'; }, $taxonomies);
                        $fq[] = "subattr_{$taxonomyCategory}___source_id____s: (" . implode(',', $taxonomies) . ')';
                    }
                }
            }

            // NO SDK
            $publisherNodeIds = $this->_localApplications[$applicationId]->publisherNodeIds();
            if(count($publisherNodeIds) == 1 )
            {
                $newsletterStyle = $applicationDictionaryRow['newsletter_style'];

                $fq = array_merge($fq, array(
                    'meta_path_si:' . $publisherNodeIds[0],
                ));
            }
            elseif (count($publisherNodeIds) > 1 )
            {
                $publisherFilter = implode(' OR ', $publisherNodeIds);
                $newsletterStyle = $applicationDictionaryRow['newsletter_style'];

                $fq = array_merge($fq, array(
                        "meta_path_si:($publisherFilter)",
                    ));
            }
            /**
             * SDK Specific treatment; dead code for now
             *
                if ( $this->_localApplications[$applicationId] instanceof SDKApplication )
                {
                    // SDK application
                    $fq = array_merge($fq, array(
                        'subattr_local_application___source_id____s:' . $applicationId,
                        'is_sdk_b:true AND is_newsletter_b:true'
                    ));
                }
             *
             */

            // Solr query parameters
            $rows = 100000;
            $queryParams = array(
                'indent' => 'on',
                'q' => $queryTerm,
                'start' => 0,
                'rows' => $rows,
                'fq' => $fq,
                'fl' => array(
                    'attr_has_image_' . $this->_cluster_identifier . '_bst',
                    'meta_remote_id_ms',
                    'meta_node_id_si',
                    'meta_main_node_id_si',
                    'attr_featured_content_b',
                    'attr_date_dt',
                    'meta_path_string_ms',
                    'meta_language_code_ms',
                    'attr_view_counter_' . $this->_cluster_identifier . '_i',
                    'subattr_speciality___source_id____s',
                    'subattr_customer_type___source_id____s',
                    'meta_current_version_si',
                    'attr_promo_description_t',
                    'attr_author_t',
                    'attr_source_t',
                    'attr_online_date_dt',
                    'attr_headline_s',
                    'subattr_publisher_folder___source_id____s',
                    'attr_promo_headline_s',
                    'attr_'.$this->_cluster_identifier.'_remote_s',
                    'attr_'.$this->_cluster_identifier.'_node_remote_s',
                    //'attr_media_content_image_'.$this->_cluster_identifier.'____ms',
                    //'attr_promo_image_'.$this->_cluster_identifier.'_s',
                    'is_sdk_b',
                    'meta_url_alias_ms',
                    'attr_promo_headline_t',
                    'subattr_publisher_folder___source_id____s',
                    'meta_id_si',
                    'attr_media_content_types_' . ClusterTool::clusterIdentifier() . '_bst',
                    'attr_' . ClusterTool::clusterIdentifier() . '_url_s',
                    'attr_core_content_t',
                    'subattr_download_ressource___expiration_date____dt',
                    'attr_node_remote_s',
                    'attr_media_content_quiz_replies_' . $this->_cluster_identifier . '____ms',
                    'attr_media_content_quiz_points_' . $this->_cluster_identifier . '_i',
                    'attr_media_content_quiz_question_' . $this->_cluster_identifier . '_ms',
                ),
                'qt' => '',
                'explainOther' => '',
                'hl.fl' => '',
                'sort' => $this->_configuration['sort']
            );
            $publisherFilters = $this->_localApplications[$applicationId]->getPublishersFilter();
            if ( $publisherFilters )
            {
                $queryParams['fq'][] = $publisherFilters;
            }

            if ( !empty($this->_customerType) )
            {
                $customerTypeCondition = implode(',', $this->stringArrayToFilterQueryParam($this->_customerType));
                $queryParams['fq'][] = sprintf( 'subattr_customer_type___source_id____s:(%s)', $customerTypeCondition );
            }
            if ( !empty($this->_specialty) )
            {
                $specialtyCondition = implode(',', $this->stringArrayToFilterQueryParam($this->_specialty));
                $queryParams['fq'][] = sprintf( 'subattr_speciality___source_id____s:(%s)', $specialtyCondition );
            }
            if ( $applicationDictionaryRow["publisher"] )
            {
                $queryParams['fq'][] = sprintf( 'subattr_publisher_folder___source_id____s:(%s)', $applicationDictionaryRow["publisher"] );
            }

            if ( $newsletterStyle == 'PICL' )
            {
                $queryParams['fq'][] = 'subattr_media_type___source_id____s:107.2';
            }

            //taxonomies
            $taxonomies = $this->getApplicationTaxonomies($applicationDictionaryRow['feed_id']);
            $firstCategory = reset(array_keys($taxonomies));
            $queryTaxonomies = '';
            foreach($taxonomies as $categorie=>$taxonomie)
            {
                if($categorie != $firstCategory)
                {
                    $queryTaxonomies .= ' AND ';
                }
                $queryTaxonomies .= 'subattr_' . $categorie . '___source_id____s:(' . $taxonomie . ')';
            }

            if($queryTaxonomies != '')
            {
                $queryParams['fq'][] = $queryTaxonomies;
            }

            $queryParamsFqFallback = $queryParams['fq'];
            $rowValueKey           = '';

            // different sort and filters by mechanism
            switch ($applicationDictionaryRow["mechanism"]) {
                case 1:
                    $rowValueKey = 'number_article_list';
                    $queryParams['sort'] = implode( ', ', $queryParams['sort'] );

                    //if begin/end date is set
                    if(!empty($this->_beginDate) && !empty($this->_endDate))
                    {
                        $queryParams['fq'][] = 'attr_online_date_dt:[' . $this->_beginDate . ' TO ' . $this->_endDate . ']';
                    }
                    else
                    {
                        $queryParams['fq'][] = sprintf( 'attr_online_date_dt:[NOW-%sDAY TO *]', $this->_configuration['days'] );
                    }
                    break;
                case 2:
                    $rowValueKey = 'number_article_random';
                    $oneHourRandom = floor(time() / 3600);
                    $queryParams['sort'] = 'attr_' . $oneHourRandom . '_random asc';
                    break;
                case 4:
                    $rowValueKey = 'number_article_last_x';
                    $queryParams['sort'] = "attr_online_date_dt desc";
                    $queryParams['fq'][] = 'attr_online_date_dt:[NOW-7DAY TO *]';

                    //if begin/end date is set
                    if(!empty($this->_beginDate) && !empty($this->_endDate))
                    {
                        $queryParams['fq'][] = 'attr_online_date_dt:[' . $this->_beginDate . ' TO ' . $this->_endDate . ']';
                    }
                    else
                    {
                        $queryParams['fq'][] = sprintf( 'attr_online_date_dt:[NOW-%sDAY TO *]', $this->_configuration['days'] );
                    }
                    break;
                case 5:
                    $rowValueKey = 'number_article_list';
                    if(!empty($this->_beginDate) && !empty($this->_endDate))
                    {
                        $queryParams['fq'][] = 'attr_online_date_dt:[' . $this->_beginDate . ' TO ' . $this->_endDate . ']';
                    }
                    $queryParams['sort'] = implode( ', ', $queryParams['sort'] );
                    if( $applicationDictionaryRow['number_article_ns'] )
                    {  
                        $queryParams['rows'] = (int)$applicationDictionaryRow['number_article_ns'];
                    }
                    else
                    {
                         $queryParams['rows'] = 100;
                    }
                    break;
            }

            if ( (int) $applicationDictionaryRow[$rowValueKey] >= 0 )
            {
                $queryParams['rows'] = (int) $applicationDictionaryRow[$rowValueKey];
            }

            $queryParams['fl'] = implode( ',', $queryParams['fl'] );
            $queryParams['fq'] = implode( ' AND ', $queryParams['fq'] );

            // main fetch solr
            $result = SolrTool::rawSearch( $queryParams, 'php', false );
            if ( !isset( $result['response']['docs'] ) )
            {
                eZDebug::writeError( 'Error from Solr for query : ' . $result['params']['fq'], __FILE__ . '::' . __LINE__ );
                if( php_sapi_name() != 'cli' )
                {
                    header( 'HTTP/1.x 500 Internal Server Error' );
                    eZExecution::cleanExit();
                }
            }
            if ( count($result['response']['docs']) == 0 && $applicationDictionaryRow['mechanism'] == 5)
            {
                $queryParams['fq'] = $queryParamsFqFallback;
                $queryParams['sort'] = array(
                    'attr_featured_content_b desc',
                    'attr_online_date_dt desc',
                );

                $queryParams['sort'] = implode( ', ', $queryParams['sort'] );

                //if begin/end date is set
                if(!empty($this->_beginDate) && !empty($this->_endDate))
                {
                    $queryParams['fq'][] = 'attr_online_date_dt:[' . $this->_beginDate . ' TO ' . $this->_endDate . ']';
                }
                $queryParams['fq'] = implode( ' AND ', $queryParams['fq'] );
                $result = SolrTool::rawSearch( $queryParams, 'php', false );
            }

            // if no result fallback for mechanism 3
            if ( count( $result['response']['docs'] ) == 0 && $applicationDictionaryRow["mechanism"] == 3 )
            {
                $queryParams['fq'] = $queryParamsFqFallback;
                $queryParams['fq'] = implode( ' AND ', $queryParams['fq'] );
                if ( (int) $applicationDictionaryRow['number_article_random'] >= 0 )
                {
                    $queryParams['rows'] = (int) $applicationDictionaryRow['number_article_random'];
                }
                else
                {
                    $queryParams['rows'] = $rows;
                }
                $oneHourRandom = floor(time() / 3600);
                $queryParams['sort'] = 'attr_' . $oneHourRandom . '_random asc';

                $result = SolrTool::rawSearch( $queryParams, 'php', false );
                if ( !isset( $result['response']['docs'] ) )
                {
                    eZDebug::writeError( 'Error from Solr for query : ' . $result['params']['fq'], __FILE__ . '::' . __LINE__ );
                    if( php_sapi_name() != 'cli' )
                    {
                        header( 'HTTP/1.x 500 Internal Server Error' );
                        eZExecution::cleanExit();
                    }
                }
            }

            $articles = $result['response']['docs'];

            // if mechanism 4, we need to have articles also from previous week
            if($applicationDictionaryRow["mechanism"] == 4)
            {
                $queryParams['fq'] = $queryParamsFqFallback;
                $queryParams['fq'][] = 'attr_online_date_dt:[NOW-14DAY TO NOW-7DAY]';
                $oneHourRandom = floor(time());
                $queryParams['sort'] = 'attr_' . $oneHourRandom . '_random asc';

                $queryParams['fq'] = implode( ' AND ', $queryParams['fq'] );
                $queryParams['rows'] = (int) $applicationDictionaryRow['number_article_random_y'];

                $resultRandom = SolrTool::rawSearch( $queryParams, 'php', false );
                if ( !isset( $resultRandom['response']['docs'] ) )
                {
                    eZDebug::writeError( 'Error from Solr for query : ' . $result['params']['fq'], __FILE__ . '::' . __LINE__ );
                    if( php_sapi_name() != 'cli' )
                    {
                        header( 'HTTP/1.x 500 Internal Server Error' );
                        eZExecution::cleanExit();
                    }
                }

                if(count($resultRandom['response']['docs'])) {
                    $articles = array_merge($articles, $resultRandom['response']['docs']);
                }
            }

            $this->_applicationsData[$applicationId][] = array(
                'articles'                    => $articles,
                'applicationDictionaryRow'    => $applicationDictionaryRow
            );
        }

        return $this->_applicationsData;
    }
 public function fetch($limit = 10, $offset = 0)
 {
     $fieldsToReturn = array();
     foreach (ITNewsletterPost::fields() as $field) {
         $fieldsToReturn[] = $field['solr_identifier'];
     }
     $solrFetchParams = array('SearchOffset' => $offset, 'SearchLimit' => $limit, 'Facet' => $this->facets, 'SortBy' => array('published' => 'desc'), 'Filter' => $this->filters, 'SearchContentClassID' => array(ITNewsletterPost::CLASS_IDENTIFIER), 'SearchSectionID' => null, 'SearchSubTreeArray' => array(eZINI::instance('content.ini')->variable('NodeSettings', 'RootNode')), 'AsObjects' => false, 'SpellCheck' => null, 'IgnoreVisibility' => null, 'Limitation' => null, 'BoostFunctions' => null, 'QueryHandler' => 'ezpublish', 'EnableElevation' => true, 'ForceElevation' => true, 'SearchDate' => null, 'DistributedSearch' => null, 'FieldsToReturn' => $fieldsToReturn, 'SearchResultClustering' => null, 'ExtendedAttributeFilter' => array());
     $solrSearch = new eZSolr();
     $tmp = $solrSearch->search($this->query, $solrFetchParams);
     return $tmp;
 }
 public function buildFetch(OCClassSearchFormFetcher $fetcher, $requestValue, &$filters)
 {
     $bounds = OCClassSearchFormPublishedFieldBounds::fromString($this->attributes['value']);
     $filters[] = eZSolr::getMetaFieldName('published') . ':[' . $bounds->attribute('start_solr') . ' TO ' . $bounds->attribute('end_solr') . ']';
     $fetcher->addFetchField(array('name' => $this->attributes['label'], 'value' => $bounds->humanString(), 'remove_view_parameters' => $fetcher->getViewParametersString(array('publish_date'))));
 }
Пример #22
0
    $fuzzyFilter = false;

    if ( $http->hasPostVariable( 'ezfind-searchelevateconfigurations-fuzzy' ) )
        $fuzzyFilter = true;
    elseif ( $Params['FuzzyFilter'] !== false )
        $fuzzyFilter = true;

    // Pass the fuzzy filter on to the template, search will occur there.
    if ( $fuzzyFilter )
        $viewParameters = array_merge( $viewParameters, array( 'fuzzy_filter' => $fuzzyFilter ) );
}

// Synchronise Elevate configuration with Solr :
else if ( $http->hasPostVariable( 'ezfind-elevate-synchronise' ) )
{
    $solr = new eZSolr();
    //if ( eZFindElevateConfiguration::synchronizeWithSolr() )
    if ( $solr->pushElevateConfiguration() )
    {
        $feedback['synchronisation_ok'] = true;
    }
    else
    {
        $feedback['synchronisation_fail'] = true;
        //TODO: aggregate error messages from multiple shards in eZSolr->pushElevateConfiguration()
        //then change here accordingly
        $feedback['synchronisation_fail_message'] = eZFindElevateConfiguration::$lastSynchronizationError;
    }
}

$viewParameters = array_merge( $viewParameters, array( 'offset' => ( isset( $Params['Offset'] ) and is_numeric( $Params['Offset'] ) ) ? $Params['Offset'] : 0 ) );
// Ultimo giorno (Default)
if (!isset($days)) {
    $days = 1;
}
// Tutte le tematiche in OR
$tag_filters = array('or');
foreach ($tematiche as $tag) {
    $tag_filters[] = 'attr_tematica_lk: "' . $tag . '"';
}
// Data inizio è di $days giorni indietro
$_startDate = new DateTime();
$_endDate = new DateTime();
$_startDate->modify("-" . $days . " day");
$startDate = ezfSolrDocumentFieldBase::preProcessValue($_startDate->format('U'), 'date');
$endDate = ezfSolrDocumentFieldBase::preProcessValue($_endDate->format('U'), 'date');
// Composizione del filtro
$filters = array('and', 'meta_published_dt:[' . $startDate . ' TO ' . $endDate . ']', $tag_filters);
$params = array('SortBy' => array('meta_published_dt' => 'desc'), 'Filter' => $filters, 'SearchContentClassID' => array($class_id), 'SearchSubTreeArray' => array(eZINI::instance('content.ini')->variable('NodeSettings', 'RootNode')));
// Esecuzione query Solr
$solrSearch = new eZSolr();
$result = $solrSearch->search('', $params);
// Estrazione del NodeID
$node_ids = array();
foreach ($result['SearchResult'] as $object) {
    $node_ids[] = $object->ContentObject->mainNodeID();
}
// Output in JSON
header('Content-Type: application/json');
echo json_encode($node_ids);
// echo json_encode( $result['SearchResult'] ); // DEBUG
eZExecution::cleanExit();
 /**
  * Extracts the configuration stored in the DB and turns it into a Solr-compliant XML string.
  * Stores the result string in the local property $configurationXML
  *
  * @see $configurationXML
  * @return boolean true if the generation run correctly, false otherwise.
  *
  */
 protected static function generateConfiguration()
 {
     $db = eZDB::instance();
     $def = self::definition();
     $query = "SELECT DISTINCT search_query FROM " . $def['name'];
     $limit = 50;
     $offset = 0;
     $solr = new eZSolr();
     $xml = new SimpleXMLElement(self::XML_SKELETON);
     self::$configurationXML = $xml->asXML();
     while (true) {
         // fetch distinct search queries
         $rows = $db->arrayQuery($query, array('limit' => $limit, 'offset' => $offset));
         if (empty($rows)) {
             break;
         }
         // For each query string, generate the corresponding bloc in elevate.xml
         // Looks like this :
         //
         // <query text="foo bar">
         //    <doc id="1" />
         //    <doc id="2" />
         //    <doc id="3" />
         // </query>
         $xml = new SimpleXMLElement(self::$configurationXML);
         foreach ($rows as $row) {
             $searchQuery = $xml->addChild('query');
             $searchQuery->addAttribute('text', $row['search_query']);
             $results = self::fetchObjectsForQueryString($row['search_query']);
             foreach ($results as $languageCode => $objects) {
                 foreach ($objects as $object) {
                     if ($languageCode === self::WILDCARD) {
                         $currentVersion = $object->currentVersion();
                         foreach ($currentVersion->translationList(false, false) as $lang) {
                             $guid = $solr->guid($object, $lang);
                             $doc = $searchQuery->addChild('doc');
                             $doc->addAttribute('id', $guid);
                         }
                     } else {
                         $guid = $solr->guid($object, $languageCode);
                         $doc = $searchQuery->addChild('doc');
                         $doc->addAttribute('id', $guid);
                     }
                 }
             }
         }
         $offset += $limit;
         self::$configurationXML = $xml->asXML();
     }
     return true;
 }
    /**
     * @see ezfSolrDocumentFieldBase::getData()
     */
    public function getData()
    {
        $contentClassAttribute = $this->ContentObjectAttribute->attribute( 'contentclass_attribute' );

        switch ( $contentClassAttribute->attribute( 'data_type_string' ) )
        {
            case 'ezobjectrelation' :
                $returnArray = array();

                $defaultFieldName = parent::generateAttributeFieldName( $contentClassAttribute,
                                                                        self::$subattributesDefinition[self::DEFAULT_SUBATTRIBUTE] );
                $returnArray[$defaultFieldName] = $this->getPlainTextRepresentation();
                $relatedObject = $this->ContentObjectAttribute->content();

                if ( $relatedObject && $relatedObject->attribute( 'status' ) == eZContentObject::STATUS_PUBLISHED )
                {
                    // 1st, add content fields of the related object.
                    $baseList = $this->getBaseList( $relatedObject->attribute( 'current' ) );

                    foreach ( $baseList as $field )
                    {
                        $tmpClassAttribute = $field->ContentObjectAttribute->attribute( 'contentclass_attribute' );
                        $fieldName = $field->ContentObjectAttribute->attribute( 'contentclass_attribute_identifier' );
                        $fieldName = parent::generateSubattributeFieldName( $contentClassAttribute,
                                                                            $fieldName,
                                                                            self::getClassAttributeType( $tmpClassAttribute ) );

                        $finalValue = '';
                        if ( $tmpClassAttribute->attribute( 'data_type_string' ) == 'ezobjectrelation' or
                             $tmpClassAttribute->attribute( 'data_type_string' ) == 'ezobjectrelationlist' )
                        {
                            // The subattribute is in turn an object relation. Stop recursion and get full text representation.
                            $finalValue = $field->getPlainTextRepresentation();
                        }
                        else
                        {
                            $values = array_values( $field->getData() );
                            foreach ( $values as $value )
                            {
                                if ( is_array( $value ) )
                                {
                                    $finalValue .= implode( ' ', $value );
                                }
                                else
                                {
                                    $finalValue .= ' ' . $value;
                                }
                            }
                        }

                        $returnArray[$fieldName] = trim( $finalValue, "\t\r\n " );
                    }

                    // 2ndly, add meta fields of the related object.
                    $metaAttributeValues = eZSolr::getMetaAttributesForObject( $relatedObject );
                    foreach ( $metaAttributeValues as $metaInfo )
                    {
                        $returnArray[ezfSolrDocumentFieldBase::generateSubmetaFieldName( $metaInfo['name'], $contentClassAttribute )] = ezfSolrDocumentFieldBase::preProcessValue( $metaInfo['value'], $metaInfo['fieldType'] );
                    }

                    return $returnArray;
                }
                break;
            case 'ezobjectrelationlist' :
            {
                $returnArray = array();
                $content = $this->ContentObjectAttribute->content();

                foreach ( $content['relation_list'] as $relationItem )
                {
                    $subObjectID = $relationItem['contentobject_id'];
                    if ( !$subObjectID )
                        continue;
                    $subObject = eZContentObjectVersion::fetchVersion( $relationItem['contentobject_version'], $subObjectID );
                    if ( !$subObject || $relationItem['in_trash'] )
                        continue;

                    // 1st create aggregated metadata fields
                    $metaAttributeValues = eZSolr::getMetaAttributesForObject( $subObject->attribute( 'contentobject' ) );
                    foreach ( $metaAttributeValues as $metaInfo )
                    {
                        $submetaFieldName = ezfSolrDocumentFieldBase::generateSubmetaFieldName( $metaInfo['name'], $contentClassAttribute );
                        if ( isset( $returnArray[$submetaFieldName] ) )
                        {
                            $returnArray[$submetaFieldName] = array_merge( $returnArray[$submetaFieldName], array( ezfSolrDocumentFieldBase::preProcessValue( $metaInfo['value'], $metaInfo['fieldType'] ) ) );
                        }
                        else
                        {
                            $returnArray[$submetaFieldName] = array( ezfSolrDocumentFieldBase::preProcessValue( $metaInfo['value'], $metaInfo['fieldType'] ) );
                        }
                    }
                }

                $defaultFieldName = parent::generateAttributeFieldName( $contentClassAttribute,
                                                                        self::$subattributesDefinition[self::DEFAULT_SUBATTRIBUTE] );
                $returnArray[$defaultFieldName] = $this->getPlainTextRepresentation();
                return $returnArray;
            }
                break;
            default:
            {
            } break;
        }
    }
 /**
  * return all news objects since the date
  *
  * @param $date
  * @return mixed
  */
 private function getLastObjects($date)
 {
     $locales = array('eng-');
     foreach( glob('extension/cluster_*/settings/site.ini*') as $f )
     {
         $ini = eZINI::fetchFromFile( $f );
         foreach( $ini->variable('RegionalSettings', 'SiteLanguageList') as $locale )
         {
             if( !in_array(substr($locale, 0, 4), $locales) )
                 $locales[] = substr($locale, 0, 4);
         }
     }
     
     $filters = array(
         "meta_modified_dt:[$date TO NOW]",
         '('.implode(' OR ', SolrTool::solrLanguageFilter($locales)).')',
         'meta_class_identifier_ms:article',
         'meta_installation_id_ms:'.eZSolr::installationID()
     );
     
     $locale = 'eng';
     
     $continue = true;
     $offset = 0;
     while($continue)
     {
         $params = array(
             'indent'        => 'on',
             'start'         => $offset,
             'rows'          => 2000,
             'q'             => '',
             'fq'            => implode( ' AND ', $filters ),
             'fl'            => 'meta_id_si, meta_name_t, meta_modified_dt',
             'qt'            => 'ezpublish',
             'explainOther'  => '',
             'hl.fl'         => '',
             'sort'          => 'meta_modified_dt asc'
         );
 
         $raw        = SolrTool::rawSearch($params, 'php', false);
         
         $continue = count($raw['response']['docs']);
         $offset += 2000;
         
         foreach($raw['response']['docs'] as $result)
         {
             fputcsv( $this->csvFile(), array($result['meta_id_si'], str_replace( array("\n", "\r"), array(' ', ''), $result['meta_name_t'] )) );
             if(!isset($lastDate) || $result['meta_modified_dt'] > $lastDate)
             {
                 $lastDate = $result['meta_modified_dt'];
             }
         }
     }
     
     // security overlap to to avoid delayed indexing gap
     $overlap = eZINI::instance('merck.ini')->variable( 'AnalyticsExportSettings', 'LastDateOverlap' );
     $d = gmdate( 'Y-m-d\TH:i:s\Z', strtotime( $lastDate ) - $overlap );
     $this->saveNewLastDate($d);
     
     return $raw['response']['numFound'];
 }
Пример #27
0
 /**
  * Create policy limitation query.
  *
  * @param array $limitation Override the limitation of the user. Same format as the return of eZUser::hasAccessTo()
  * @param boolean $ignoreVisibility Set to true for the visibility to be ignored
  * @return string Lucene/Solr query string which can be used as filter query for Solr
  */
 protected function policyLimitationFilterQuery($limitation = null, $ignoreVisibility = null)
 {
     $eZFindIni = eZINI::instance('ezfind.ini');
     $filterQuery = false;
     $policies = array();
     $pathFieldName = $ignoreVisibility ? eZSolr::getMetaFieldName('path') : eZSolr::getMetaFieldName('visible_path');
     if (is_array($limitation)) {
         if (empty($limitation)) {
             $limitation['accessWord'] = 'yes';
         }
     } else {
         $limitation = eZUser::currentUser()->hasAccessTo('content', 'read');
     }
     if (isset($limitation['accessWord'])) {
         switch ($limitation['accessWord']) {
             case 'limited':
                 if (isset($limitation['policies'])) {
                     $policies = $limitation['policies'];
                     break;
                 }
                 // break omitted, "limited" without policies == "no"
             // break omitted, "limited" without policies == "no"
             case 'no':
                 return ' NOT *:* ';
             case 'yes':
                 break;
             default:
                 return false;
         }
     }
     // Add limitations for filter query based on local permissions.
     $limitationHash = array('Class' => eZSolr::getMetaFieldName('contentclass_id'), 'Section' => eZSolr::getMetaFieldName('section_id'), 'User_Section' => eZSolr::getMetaFieldName('section_id'), 'Subtree' => eZSolr::getMetaFieldName('path_string'), 'User_Subtree' => eZSolr::getMetaFieldName('path_string'), 'Node' => eZSolr::getMetaFieldName('main_node_id'), 'Owner' => eZSolr::getMetaFieldName('owner_id'), 'Group' => eZSolr::getMetaFieldName('owner_group_id'), 'ObjectStates' => eZSolr::getMetaFieldName('object_states'));
     $filterQueryPolicies = array();
     // policies are concatenated with OR
     foreach ($policies as $limitationList) {
         // policy limitations are concatenated with AND
         // except for locations policity limitations, concatenated with OR
         $filterQueryPolicyLimitations = array();
         $policyLimitationsOnLocations = array();
         foreach ($limitationList as $limitationType => $limitationValues) {
             // limitation values of one type in a policy are concatenated with OR
             $filterQueryPolicyLimitationParts = array();
             switch ($limitationType) {
                 case 'User_Subtree':
                 case 'Subtree':
                     foreach ($limitationValues as $limitationValue) {
                         $pathString = trim($limitationValue, '/');
                         $pathArray = explode('/', $pathString);
                         // we only take the last node ID in the path identification string
                         $subtreeNodeID = array_pop($pathArray);
                         $policyLimitationsOnLocations[] = $pathFieldName . ':' . $subtreeNodeID;
                         if (isset($this->searchPluginInstance->postSearchProcessingData['subtree_limitations'])) {
                             $this->searchPluginInstance->postSearchProcessingData['subtree_limitations'][] = $subtreeNodeID;
                         } else {
                             $this->searchPluginInstance->postSearchProcessingData['subtree_limitations'] = array($subtreeNodeID);
                         }
                     }
                     break;
                 case 'Node':
                     foreach ($limitationValues as $limitationValue) {
                         $pathString = trim($limitationValue, '/');
                         $pathArray = explode('/', $pathString);
                         // we only take the last node ID in the path identification string
                         $nodeID = array_pop($pathArray);
                         $policyLimitationsOnLocations[] = $limitationHash[$limitationType] . ':' . $nodeID;
                         if (isset($this->searchPluginInstance->postSearchProcessingData['subtree_limitations'])) {
                             $this->searchPluginInstance->postSearchProcessingData['subtree_limitations'][] = $nodeID;
                         } else {
                             $this->searchPluginInstance->postSearchProcessingData['subtree_limitations'] = array($nodeID);
                         }
                     }
                     break;
                 case 'Group':
                     foreach (eZUser::currentUser()->attribute('contentobject')->attribute('parent_nodes') as $groupID) {
                         $filterQueryPolicyLimitationParts[] = $limitationHash[$limitationType] . ':' . $groupID;
                     }
                     break;
                 case 'Owner':
                     $filterQueryPolicyLimitationParts[] = $limitationHash[$limitationType] . ':' . eZUser::currentUser()->attribute('contentobject_id');
                     break;
                 case 'Class':
                 case 'Section':
                 case 'User_Section':
                     foreach ($limitationValues as $limitationValue) {
                         $filterQueryPolicyLimitationParts[] = $limitationHash[$limitationType] . ':' . $limitationValue;
                     }
                     break;
                 default:
                     //hacky, object state limitations reference the state group name in their
                     //limitation
                     //hence the following match on substring
                     if (strpos($limitationType, 'StateGroup') !== false) {
                         foreach ($limitationValues as $limitationValue) {
                             $filterQueryPolicyLimitationParts[] = $limitationHash['ObjectStates'] . ':' . $limitationValue;
                         }
                     } else {
                         eZDebug::writeDebug($limitationType, __METHOD__ . ' unknown limitation type: ' . $limitationType);
                         continue;
                     }
             }
             if (!empty($filterQueryPolicyLimitationParts)) {
                 $filterQueryPolicyLimitations[] = '( ' . implode(' OR ', $filterQueryPolicyLimitationParts) . ' )';
             }
         }
         // Policy limitations on locations (node and/or subtree) need to be concatenated with OR
         // unlike the other types of limitation
         if (!empty($policyLimitationsOnLocations)) {
             $filterQueryPolicyLimitations[] = '( ' . implode(' OR ', $policyLimitationsOnLocations) . ')';
         }
         if (!empty($filterQueryPolicyLimitations)) {
             $filterQueryPolicies[] = '( ' . implode(' AND ', $filterQueryPolicyLimitations) . ')';
         }
     }
     if (!empty($filterQueryPolicies)) {
         $filterQuery = implode(' OR ', $filterQueryPolicies);
     }
     // Add limitations for allowing search of other installations.
     $anonymousPart = '';
     if ($eZFindIni->variable('SiteSettings', 'SearchOtherInstallations') == 'enabled') {
         $anonymousPart = ' OR ' . eZSolr::getMetaFieldName('anon_access') . ':true ';
     }
     if (!empty($filterQuery)) {
         $filterQuery = '((' . eZSolr::getMetaFieldName('installation_id') . ':' . eZSolr::installationID() . ' AND (' . $filterQuery . ')) ' . $anonymousPart . ' )';
     } else {
         $filterQuery = '(' . eZSolr::getMetaFieldName('installation_id') . ':' . eZSolr::installationID() . $anonymousPart . ')';
     }
     // Add ignore visibility condition, either explicitely set to boolean false or not specified
     if ($ignoreVisibility === false || $ignoreVisibility === null) {
         $filterQuery .= ' AND ' . eZSolr::getMetaFieldName('is_invisible') . ':false';
     }
     eZDebugSetting::writeDebug('extension-ezfind-query', $filterQuery, __METHOD__);
     return $filterQuery;
 }
 protected function searchInFront()
 {
     $filters = array(
         '(attr_archive_date_dt:"1970-01-01T01:00:00Z" OR attr_archive_date_dt:[NOW TO *])',
         'meta_class_identifier_ms:article',
         'meta_installation_id_ms:' . eZSolr::installationID(),
         'attr_is_invisible_' . ClusterTool::clusterIdentifier() . '_b:false'
     );
     $results = SolrTool::rawSearch( array(
         'indent'       => 'on',
         'q'            => $this->keyword,
         'fq'           => implode( ' AND ', $filters ),
         'start'        => 0,
         'rows'         => 10,
         'fl'           => 'attr_headline_s',
         'qt'           => 'ezpublish',
         'explainOther' => '',
         'hl.fl'        => '',
         'sort'         => "score desc"
     ) );
     if( $results['response']['numFound'] > 0 )
     {
         foreach( $results['response']['docs'] as $doc )
         {
             if( trim( $doc['attr_headline_s'] ) == $this->keyword )
             {
                 $this->article->setAttribute( 'date_front', time() );
                 if( !is_null( $this->article->attribute( 'date_newsletter' ) ) )
                 {
                     $this->article->setAttribute( 'new_relic_report', 1 );
                     $this->reportToNewRelic( $this->newRelicMetricName, 0 );
                 }
                 $this->article->store();
                 break;
             }
         }
     }
 }
Пример #29
0
    /**
     * moreLikeThis function
     * @todo document the solrconfig.xml required setting for remote streaming to be true
     *       if $queryType 'url' is to be used
     * @todo consider adding limitation and visibility parameters
     *
     * @param string $queryType string ( 'nid' | 'oid' | 'text' | 'url' )
     * @param string $query value for QueryType
     * @param int Offset
     * @param int Limit
     * @param array Facet definition
     * @param array Filter parameters
     * @param array Sort by parameters
     * @param mixed Content class ID or list of content class IDs
     * @param array list of subtree limitation node IDs
     * @param boolean asObjects return regular eZPublish objects if true, stored Solr content if false
     * @param string|null $queryInstallationID the eZ Find installation id to
     *        use when looking for the reference document in Solr
     *
     * @return array result as a PHP array
     */
    public function moreLikeThis( $queryType, $query, $offset = 0, $limit = 10, $facets = null,
                                  $filters = null, $sortBy = null, $classID = null, $sectionID = null,
                                  $subtreeArray = null, $asObjects = true, $queryInstallationID = null )

    {
        $solrSearch = new eZSolr();
        $params = array( 'SearchOffset' => $offset,
                         'SearchLimit' => $limit,
                         'Facet' => $facets,
                         'SortBy' => $sortBy,
                         'Filter' => $filters,
                         'SearchContentClassID' => $classID,
                         'SearchSectionID' => $sectionID,
                         'SearchSubTreeArray' => $subtreeArray,
                         'QueryInstallationID' => $queryInstallationID,
                         'AsObjects' => $asObjects);
        return array( 'result' => $solrSearch->moreLikeThis( $queryType, $query, $params ) );


    }
 /**
  * @see ezfSolrDocumentFieldBase::getData()
  */
 public function getData()
 {
     /** @var eZContentClassAttribute $contentClassAttribute */
     $contentClassAttribute = $this->ContentObjectAttribute->attribute('contentclass_attribute');
     switch ($contentClassAttribute->attribute('data_type_string')) {
         case 'ezobjectrelation':
             $returnArray = array();
             /** @var eZContentObject $relatedObject */
             $relatedObject = $this->ContentObjectAttribute->content();
             if ($relatedObject) {
                 $returnArray = $this->getArrayRelatedObject($relatedObject, $contentClassAttribute);
                 eZContentObject::clearCache(array($relatedObject->attribute('id')));
             }
             return $returnArray;
             break;
         case 'ezobjectrelationlist':
             $returnArray = array();
             $returnArrayRelatedObject = array();
             $content = $this->ContentObjectAttribute->content();
             $relationCount = count($content['relation_list']);
             foreach ($content['relation_list'] as $relationItem) {
                 $subObjectID = $relationItem['contentobject_id'];
                 if (!$subObjectID) {
                     continue;
                 }
                 /** @var eZContentObjectVersion $subObject */
                 $subObject = eZContentObjectVersion::fetchVersion($relationItem['contentobject_version'], $subObjectID);
                 if (!$subObject instanceof eZContentObjectVersion) {
                     $subObjectWrapper = eZContentObject::fetch($subObjectID);
                     if ($subObjectWrapper instanceof eZContentObject) {
                         $subObject = $subObjectWrapper->currentVersion();
                     } else {
                         continue;
                     }
                 }
                 /** @var eZContentObject $subContentObject */
                 $subContentObject = $subObject->attribute('contentobject');
                 if (intval($subContentObject->attribute('main_node_id')) == 0) {
                     continue;
                 }
                 $metaAttributeValues = eZSolr::getMetaAttributesForObject($subContentObject);
                 foreach ($metaAttributeValues as $metaInfo) {
                     $submetaFieldName = ezfSolrDocumentFieldBase::generateSubmetaFieldName($metaInfo['name'], $contentClassAttribute);
                     if (isset($returnArray[$submetaFieldName])) {
                         $returnArray[$submetaFieldName] = array_merge($returnArray[$submetaFieldName], array(ezfSolrDocumentFieldBase::preProcessValue($metaInfo['value'], $metaInfo['fieldType'])));
                     } else {
                         $returnArray[$submetaFieldName] = array(ezfSolrDocumentFieldBase::preProcessValue($metaInfo['value'], $metaInfo['fieldType']));
                     }
                 }
                 $nodeAttributeValues = array();
                 $nodePathArray = array();
                 /** @var eZContentObjectTreeNode $contentNode */
                 foreach ($subContentObject->attribute('assigned_nodes') as $contentNode) {
                     foreach (eZSolr::nodeAttributes() as $attributeName => $fieldType) {
                         $nodeAttributeValues[] = array('name' => $attributeName, 'value' => $contentNode->attribute($attributeName), 'fieldType' => $fieldType);
                     }
                     $nodePathArray[] = $contentNode->attribute('path_array');
                 }
                 //@todo questo non va... occorre correggere schema.xml?
                 //foreach ( $nodeAttributeValues as $metaInfo )
                 //{
                 //    $submetaFieldName = ezfSolrDocumentFieldBase::generateSubmetaFieldName( $metaInfo['name'], $contentClassAttribute );
                 //    if ( isset( $returnArray[$submetaFieldName] ) )
                 //    {
                 //        $returnArray[$submetaFieldName] = array_merge( $returnArray[$submetaFieldName],
                 //                                                       array( ezfSolrDocumentFieldBase::preProcessValue( $metaInfo['value'], $metaInfo['fieldType'] ) ) );
                 //    }
                 //    else
                 //    {
                 //        $returnArray[$submetaFieldName] = array( ezfSolrDocumentFieldBase::preProcessValue( $metaInfo['value'], $metaInfo['fieldType'] ) );
                 //    }
                 //}
                 foreach ($nodePathArray as $pathArray) {
                     $submetaFieldName = ezfSolrDocumentFieldBase::generateSubmetaFieldName('path', $contentClassAttribute);
                     foreach ($pathArray as $pathNodeID) {
                         if (isset($returnArray[$submetaFieldName])) {
                             $returnArray[$submetaFieldName] = array_merge($returnArray[$submetaFieldName], array($pathNodeID));
                         } else {
                             $returnArray[$submetaFieldName] = array($pathNodeID);
                         }
                     }
                 }
                 if ($relationCount < 200) {
                     $returnArrayRelatedObject = $this->getArrayRelatedObject($subContentObject, $contentClassAttribute, $returnArrayRelatedObject);
                 } else {
                     $objectName = $subContentObject->name(false, $this->ContentObjectAttribute->attribute('language_code'));
                     $fieldName = parent::generateSubattributeFieldName($contentClassAttribute, 'name', self::DEFAULT_SUBATTRIBUTE_TYPE);
                     if (isset($returnArrayRelatedObject[$fieldName])) {
                         $returnArrayRelatedObject[$fieldName][] = $objectName;
                     } else {
                         $returnArrayRelatedObject[$fieldName] = array($objectName);
                     }
                 }
                 $returnArray = array_merge_recursive($returnArray, $returnArrayRelatedObject);
                 eZContentObject::clearCache(array($subContentObject->attribute('id')));
             }
             $defaultFieldName = parent::generateAttributeFieldName($contentClassAttribute, self::$subattributesDefinition[self::DEFAULT_SUBATTRIBUTE]);
             $stringFieldName = parent::generateAttributeFieldName($contentClassAttribute, 'string');
             $returnArray[$defaultFieldName] = $this->getPlainTextRepresentation();
             $returnArray[$stringFieldName] = $this->getPlainTextRepresentation();
             $result = array();
             foreach ($returnArray as $key => $value) {
                 if (is_array($value)) {
                     $value = array_unique($value);
                 }
                 $result[$key] = $value;
             }
             return $result;
             break;
     }
     return array();
 }