当前位置: 首页>>代码示例>>PHP>>正文


PHP eZSolr::addFieldBaseToDoc方法代码示例

本文整理汇总了PHP中eZSolr::addFieldBaseToDoc方法的典型用法代码示例。如果您正苦于以下问题:PHP eZSolr::addFieldBaseToDoc方法的具体用法?PHP eZSolr::addFieldBaseToDoc怎么用?PHP eZSolr::addFieldBaseToDoc使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在eZSolr的用法示例。


在下文中一共展示了eZSolr::addFieldBaseToDoc方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: fakeAddObject


//.........这里部分代码省略.........
        $doc->addField(ezfSolrDocumentFieldBase::generateMetaFieldName('anon_access'), $anonymousAccess);
        $doc->addField(ezfSolrDocumentFieldBase::generateMetaFieldName('language_code'), $languageCode);
        $doc->addField(ezfSolrDocumentFieldBase::generateMetaFieldName('available_language_codes'), $availableLanguages);
        if ($owner = $contentObject->attribute('owner')) {
            // Set owner name
            $doc->addField(ezfSolrDocumentFieldBase::generateMetaFieldName('owner_name'), $owner->name(false, $languageCode));
            // Set owner group ID
            foreach ($owner->attribute('parent_nodes') as $groupID) {
                $doc->addField(ezfSolrDocumentFieldBase::generateMetaFieldName('owner_group_id'), $groupID);
            }
        }
        // from eZ Publish 4.1 only: object states
        // so let's check if the content object has it
        if (method_exists($contentObject, 'stateIDArray')) {
            $doc->addField(ezfSolrDocumentFieldBase::generateMetaFieldName('object_states'), $contentObject->stateIDArray());
        }
        // Set content object meta attribute values.
        foreach ($metaAttributeValues as $metaInfo) {
            $doc->addField(ezfSolrDocumentFieldBase::generateMetaFieldName($metaInfo['name']), ezfSolrDocumentFieldBase::preProcessValue($metaInfo['value'], $metaInfo['fieldType']));
        }
        // Set content node meta attribute values.
        foreach ($nodeAttributeValues as $metaInfo) {
            $doc->addField(ezfSolrDocumentFieldBase::generateMetaFieldName($metaInfo['name']), ezfSolrDocumentFieldBase::preProcessValue($metaInfo['value'], $metaInfo['fieldType']));
        }
        // Add main url_alias
        $doc->addField(ezfSolrDocumentFieldBase::generateMetaFieldName('main_url_alias'), $mainNode->attribute('url_alias'));
        // Add main path_string
        $doc->addField(ezfSolrDocumentFieldBase::generateMetaFieldName('main_path_string'), $mainNode->attribute('path_string'));
        // add nodeid of all parent nodes path elements
        foreach ($nodePathArray as $pathArray) {
            foreach ($pathArray as $pathNodeID) {
                $doc->addField(ezfSolrDocumentFieldBase::generateMetaFieldName('path'), $pathNodeID);
            }
        }
        // Since eZ Fnd 2.3
        // cannot call metafield field bame constructor as we are creating multiple fields
        foreach ($mainNodePathArray as $key => $pathNodeID) {
            $doc->addField('meta_main_path_element_' . $key . '_si', $pathNodeID);
        }
        eZContentObject::recursionProtectionStart();
        // Loop through all eZContentObjectAttributes and add them to the Solr document.
        // @since eZ Find 2.3: look for the attribute storage setting
        $doAttributeStorage = $eZSolr->FindINI->variable('IndexOptions', 'EnableSolrAttributeStorage') === 'true' ? true : false;
        if ($doAttributeStorage) {
            $allAttributeData = array();
        }
        foreach ($currentVersion->contentObjectAttributes($languageCode) as $attribute) {
            $metaDataText = '';
            $classAttribute = $attribute->contentClassAttribute();
            $attributeIdentifier = $classAttribute->attribute('identifier');
            $combinedIdentifier = $contentClassIdentifier . '/' . $attributeIdentifier;
            $boostAttribute = false;
            if (isset($boostAttributes[$attributeIdentifier]) && is_numeric($boostAttributes[$attributeIdentifier])) {
                $boostAttribute = $boostAttributes[$attributeIdentifier];
            }
            if (isset($boostAttributes[$combinedIdentifier]) && is_numeric($boostAttributes[$combinedIdentifier])) {
                $boostAttribute += $boostAttributes[$combinedIdentifier];
            }
            if ($classAttribute->attribute('is_searchable') == 1) {
                $documentFieldBase = ezfSolrDocumentFieldBase::getInstance($attribute);
                $eZSolr->addFieldBaseToDoc($documentFieldBase, $doc, $boostAttribute);
            }
            if ($doAttributeStorage) {
                $storageFieldName = ezfSolrStorage::getSolrStorageFieldName($attributeIdentifier);
                $attributeData = ezfSolrStorage::getAttributeData($attribute);
                $allAttributeData['data_map'][$attributeIdentifier] = $attributeData;
                $doc->addField($storageFieldName, ezfSolrStorage::serializeData($attributeData));
            }
        }
        eZContentObject::recursionProtectionEnd();
        if ($doAttributeStorage) {
            $doc->addField('as_all_bst', ezfSolrStorage::serializeData($allAttributeData));
        }
        $docList[$languageCode] = $doc;
        $generalPlugins = (array) eZINI::instance('ezfind.ini')->variable('IndexPlugins', 'General');
        $classPlugins = (array) eZINI::instance('ezfind.ini')->variable('IndexPlugins', 'Class');
        if (!empty($generalPlugins)) {
            foreach ($generalPlugins as $pluginClassString) {
                if (!class_exists($pluginClassString)) {
                    eZDebug::writeError("Unable to find the PHP class '{$pluginClassString}' defined for index time plugins for eZ Find", __METHOD__);
                    continue;
                }
                $plugin = new $pluginClassString();
                if ($plugin instanceof ezfIndexPlugin) {
                    $plugin->modify($contentObject, $docList);
                }
            }
        }
        if (array_key_exists($contentObject->attribute('class_identifier'), $classPlugins)) {
            $pluginClassString = $classPlugins[$contentObject->attribute('class_identifier')];
            if (class_exists($pluginClassString)) {
                $plugin = new $pluginClassString();
                if ($plugin instanceof ezfIndexPlugin) {
                    $plugin->modify($contentObject, $docList);
                }
            }
        }
    }
    return $docList;
}
开发者ID:OpencontentCoop,项目名称:ocsearchtools,代码行数:101,代码来源:object.php


注:本文中的eZSolr::addFieldBaseToDoc方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。