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


PHP Apache_Solr_Document::addField方法代码示例

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


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

示例1: createEntryDocument

 public function createEntryDocument(entry $entry)
 {
     $document = new Apache_Solr_Document();
     $document->plugins_data = '';
     foreach (self::$solrFields as $solrField) {
         $fieldType = $solrField['type'];
         $func_name = "get" . $solrField['phpName'];
         if ($fieldType == "date") {
             $value = call_user_func(array($entry, $func_name), "%Y-%m-%dT%H:%M:%SZ");
         } else {
             $value = call_user_func(array($entry, $func_name));
         }
         //$value = $entry->getByName($solrField['phpName']);
         $solrName = $solrField['solrName'];
         switch ($solrField['type']) {
             case "array":
                 if ($value != '') {
                     $values = explode(",", $value);
                     foreach ($vals as $value) {
                         $document->addField($solrName, $value);
                     }
                 }
                 break;
             default:
                 $document->addField($solrName, $value);
         }
     }
     return $document;
 }
开发者ID:richhl,项目名称:kalturaCE,代码行数:29,代码来源:kSolrSearchManager.php

示例2: addDocument

 /**
  * add a document
  * @param array
  */
 public function addDocument($doc)
 {
     $document = new Apache_Solr_Document();
     foreach ($doc as $key => $val) {
         if (is_array($val)) {
             foreach ($val as $_val) {
                 $document->addField($key, $_val);
             }
         } else {
             $document->addField($key, $val);
         }
     }
     $this->service->addDocument($document);
 }
开发者ID:emilymwang8,项目名称:ibug,代码行数:18,代码来源:Solr.php

示例3: addDocumentFieldsFromTyposcript

 /**
  * Adds fields to the document as defined in $indexingConfiguration
  *
  * @param \Apache_Solr_Document $document base document to add fields to
  * @param array $indexingConfiguration Indexing configuration / mapping
  * @param array $data Record data
  * @return \Apache_Solr_Document Modified document with added fields
  */
 protected function addDocumentFieldsFromTyposcript(\Apache_Solr_Document $document, array $indexingConfiguration, array $data)
 {
     // mapping of record fields => solr document fields, resolving cObj
     foreach ($indexingConfiguration as $solrFieldName => $recordFieldName) {
         if (is_array($recordFieldName)) {
             // configuration for a content object, skipping
             continue;
         }
         if (!self::isAllowedToOverrideField($solrFieldName)) {
             throw new InvalidFieldNameException('Must not overwrite field .' . $solrFieldName, 1435441863);
         }
         $fieldValue = $this->resolveFieldValue($indexingConfiguration, $solrFieldName, $data);
         if (is_array($fieldValue)) {
             // multi value
             foreach ($fieldValue as $multiValue) {
                 $document->addField($solrFieldName, $multiValue);
             }
         } else {
             if ($fieldValue !== '' && $fieldValue !== null) {
                 $document->setField($solrFieldName, $fieldValue);
             }
         }
     }
     return $document;
 }
开发者ID:sitegeist,项目名称:ext-solr,代码行数:33,代码来源:AbstractIndexer.php

示例4: _addAs

 /**
  * Method for adding an object from the database into the index.
  *
  * @param DataObject
  * @param string
  * @param array
  */
 protected function _addAs($object, $base, $options)
 {
     $includeSubs = $options['include_children'];
     $doc = new Apache_Solr_Document();
     // Always present fields
     $doc->setField('_documentid', $this->getDocumentID($object, $base, $includeSubs));
     $doc->setField('ID', $object->ID);
     $doc->setField('ClassName', $object->ClassName);
     foreach (SearchIntrospection::hierarchy(get_class($object), false) as $class) {
         $doc->addField('ClassHierarchy', $class);
     }
     // Add the user-specified fields
     foreach ($this->getFieldsIterator() as $name => $field) {
         if ($field['base'] == $base) {
             $this->_addField($doc, $object, $field);
         }
     }
     // CUSTOM Duplicate index combined fields ("Title" rather than
     // "SiteTree_Title").
     //
     // This allows us to sort on these fields without deeper architectural
     // changes to the fulltextsearch module. Note: We can't use <copyField>
     // for this purpose because it only writes into multiValue=true
     // fields, and those can't be (reliably) sorted on.
     $this->_addField($doc, $object, $this->getCustomPropertyFieldData('Title', $object));
     $this->_addField($doc, $object, $this->getCustomPropertyFieldData('LastEdited', $object, 'SSDatetime'));
     $this->getService()->addDocument($doc);
     return $doc;
 }
开发者ID:helpfulrobot,项目名称:dnadesign-silverstripe-fulltextsearchdefault,代码行数:36,代码来源:FulltextSearchDefaultIndex.php

示例5: transformsUnixTimestampToIsoDateOnMultiValuedField

 /**
  * @test
  */
 public function transformsUnixTimestampToIsoDateOnMultiValuedField()
 {
     $this->documentMock->addField('dateField', '1262343600');
     // 2010-01-01 12:00
     $this->documentMock->addField('dateField', '1262343601');
     // 2010-01-01 12:01
     $configuration = array('dateField' => 'timestampToIsoDate');
     $this->service->processDocument($this->documentMock, $configuration);
     $value = $this->documentMock->getField('dateField');
     $this->assertEquals($value['value'], array('2010-01-01T12:00:00Z', '2010-01-01T12:00:01Z'), 'field was not processed with timestampToIsoDate');
 }
开发者ID:raimundlandig,项目名称:winkel.de-DEV,代码行数:14,代码来源:ServiceTest.php

示例6: testAddFieldWithBoostMultipliesWithAPreexistingBoost

 public function testAddFieldWithBoostMultipliesWithAPreexistingBoost()
 {
     $field = 'field';
     $boost = 0.5;
     // set a field with a boost
     $this->_fixture->setField($field, 'value1', $boost);
     // now add another value with the same boost
     $this->_fixture->addField($field, 'value2', $boost);
     // new boost should be $boost * $boost
     $this->assertEquals($boost * $boost, $this->_fixture->getFieldBoost($field));
 }
开发者ID:rande,项目名称:sfSolrPlugin,代码行数:11,代码来源:DocumentTest.php

示例7: addDocumentFieldsFromTyposcript

 /**
  * Adds fields to the document as defined in $indexingConfiguration
  *
  * @param Apache_Solr_Document $document base document to add fields to
  * @param array $indexingConfiguration Indexing configuration / mapping
  * @param array $data Record data
  * @return Apache_Solr_Document Modified document with added fields
  */
 protected function addDocumentFieldsFromTyposcript(Apache_Solr_Document $document, array $indexingConfiguration, array $data)
 {
     // mapping of record fields => solr document fields, resolving cObj
     foreach ($indexingConfiguration as $solrFieldName => $recordFieldName) {
         if (is_array($recordFieldName)) {
             // configuration for a content object, skipping
             continue;
         }
         $fieldValue = $this->resolveFieldValue($indexingConfiguration, $solrFieldName, $data);
         if (is_array($fieldValue)) {
             // multi value
             foreach ($fieldValue as $multiValue) {
                 $document->addField($solrFieldName, $multiValue);
             }
         } else {
             $document->setField($solrFieldName, $fieldValue);
         }
     }
     return $document;
 }
开发者ID:punktDe,项目名称:solr,代码行数:28,代码来源:AbstractIndexer.php

示例8: dirname

<?php

require dirname(__FILE__) . '/../../bootstrap/unit.php';
$t = new limeade_test(2, limeade_output::get());
$t->diag('document format a document');
$document = new Apache_Solr_Document();
$document->setBoost(10);
$document->setField('sfl_guid', 'GUID_1234');
$document->setField('name', 'Thomas Rabaix', 1);
$document->setMultiValue('skills', 'php');
$document->setMultiValue('skills', 'symfony');
$document->addField('skills', 'objective-c');
$expected = array('name' => 'skills', 'value' => array(0 => 'php', 1 => 'symfony', 2 => 'objective-c'), 'boost' => false);
$t->cmp_ok($document->getField('skills'), '==', $expected, '::getField test multivalue setter');
$expected = array('name' => 'name', 'value' => 'Thomas Rabaix', 'boost' => 1);
$t->cmp_ok($document->getField('name'), '==', $expected, '::getField test setter');
开发者ID:rande,项目名称:sfSolrPlugin,代码行数:16,代码来源:apache_solr_document.php

示例9: addResource

 public function addResource($resource)
 {
     if (!is_array($resource)) {
         return false;
     }
     $fields = array('id' => $resource['Resource']['id'], 'sha' => $resource['Resource']['sha'], 'user' => $resource['User']['name'], 'filetype' => $resource['Resource']['mime_type'], 'filename' => $resource['Resource']['file_name'], 'type' => $resource['Resource']['type'], 'title' => $resource['Resource']['title'], 'public' => $resource['Resource']['public'], 'modified' => $this->_formatDate($resource['Resource']['modified']), 'created' => $this->_formatDate($resource['Resource']['created']), 'comment' => \_\pluck($resource['Comment'], 'content'), 'annotation' => \_\pluck($resource['Annotation'], 'caption'), 'keyword' => \_\pluck($resource['Keyword'], 'keyword'), 'collection' => $resource['Collection'] ?: array());
     $document = new \Apache_Solr_Document();
     foreach ($fields as $key => $val) {
         if (is_array($val)) {
             foreach ($val as $subval) {
                 $document->addField($key, $subval);
             }
         } else {
             $document->{$key} = $val;
         }
     }
     foreach ($resource['Metadatum'] as $m) {
         $document->addField($m['attribute'] . '_t', $m['value']);
     }
     $this->solr->addDocument($document);
     $this->solr->commit();
     $this->solr->optimize();
 }
开发者ID:ndreynolds,项目名称:arcs,代码行数:23,代码来源:Solr.php

示例10: indexPage

 public function indexPage(Kwf_Component_Data $page, $debugOutput = false)
 {
     if (Kwc_Abstract::getFlag($page->componentClass, 'skipFulltext')) {
         return;
     }
     //performance
     //echo "checking for childComponents\n";
     $fulltextComponents = $this->getFulltextComponents($page);
     if ($fulltextComponents) {
         if ($debugOutput) {
             echo " *** indexing {$page->componentId} {$page->url}...";
         }
         $contents = $this->getFulltextContentForPage($page, $fulltextComponents);
         unset($fulltextComponents);
         if (!$contents) {
             if ($debugOutput) {
                 echo " [no content]\n";
             }
             return false;
         }
         if ($debugOutput) {
             echo " [" . implode(' ', array_keys($contents)) . "]\n";
         }
         $doc = new Apache_Solr_Document();
         foreach ($contents as $field => $text) {
             if ($text instanceof Kwf_DateTime) {
                 $text = gmdate('Y-m-d\\TH:i:s\\Z', $text->getTimestamp());
             }
             $doc->addField($field, $text);
         }
         $doc->addField('componentId', $page->componentId);
         $response = $this->_getSolrService($page)->addDocument($doc);
         if ($response->getHttpStatus() != 200) {
             throw new Kwf_Exception("addDocument failed");
         }
         $this->_getSolrService($page)->commit();
         $this->_afterIndex($page);
         return true;
     }
     return false;
 }
开发者ID:nsams,项目名称:koala-framework,代码行数:41,代码来源:Solr.php

示例11: indexFolder

 /** Build the solr lucene index for folders */
 public function indexFolder($args)
 {
     $folder = $args['folder'];
     try {
         $index = $this->ModuleComponent->Solr->getSolrIndex();
     } catch (Exception $e) {
         $this->getLogger()->warn($e->getMessage() . ' - Could not index folder (' . $folder->getKey() . ')');
         return;
     }
     $progress = array_key_exists('progress', $args) ? $args['progress'] : null;
     if ($progress) {
         $message = 'Indexing folder ' . ($progress->getCurrent() + 1) . ' / ' . $progress->getMaximum();
         $this->Progress->updateProgress($progress, $progress->getCurrent() + 1, $message);
     }
     try {
         $response = $index->search('id: folder_' . $folder->getKey(), 0, 99999);
         foreach ($response->response->docs as $doc) {
             $index->deleteById($doc->id);
         }
         if ($response->response->numFound > 0) {
             $index->commit();
         }
         $doc = new Apache_Solr_Document();
         $doc->addField('id', 'folder_' . $folder->getKey());
         $doc->addField('key', $folder->getKey());
         $doc->addField('name', $folder->getName(), 3.0);
         // boost factor of 3 for name
         $doc->addField('description', $folder->getDescription(), 2.0);
         // boost factor of 2 for description
         $index->addDocument($doc);
         $index->commit();
     } catch (Exception $e) {
         $this->getLogger()->warn('Error saving folder (' . $folder->getKey() . ') to Solr index: ' . $e->getMessage());
     }
 }
开发者ID:josephsnyder,项目名称:Midas,代码行数:36,代码来源:Notification.php

示例12: _addAs

 protected function _addAs($object, $base, $options)
 {
     $includeSubs = $options['include_children'];
     $doc = new Apache_Solr_Document();
     // Always present fields
     $doc->setField('_documentid', $this->getDocumentID($object, $base, $includeSubs));
     $doc->setField('ID', $object->ID);
     $doc->setField('ClassName', $object->ClassName);
     foreach (SearchIntrospection::hierarchy(get_class($object), false) as $class) {
         $doc->addField('ClassHierarchy', $class);
     }
     // Add the user-specified fields
     foreach ($this->getFieldsIterator() as $name => $field) {
         if ($field['base'] == $base) {
             $this->_addField($doc, $object, $field);
         }
     }
     try {
         $this->getService()->addDocument($doc);
     } catch (Exception $e) {
         SS_Log::log($e, SS_Log::WARN);
         return false;
     }
     return $doc;
 }
开发者ID:helpfulrobot,项目名称:silverstripe-fulltextsearch,代码行数:25,代码来源:SolrIndex.php

示例13: buildProductDocument

 protected function buildProductDocument($storeId, $productId, $indexableAttributes)
 {
     $helper = Mage::helper('solr');
     $indexableAttributes = Mage::helper('solr/attribute')->getNamedProductAttributes($indexableAttributes);
     $product = Mage::getModel('catalog/product')->setStoreId($storeId)->load($productId);
     /** @var Mage_Catalog_Model_Product $product */
     $baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
     $host = parse_url($baseUrl, PHP_URL_HOST);
     $document = new Apache_Solr_Document();
     $document->setField('appKey', 'Asm_Solr');
     $document->setField('type', 'catalog/product');
     $document->setField('id', $helper->getProductDocumentId($product->getEntityId()));
     $document->setField('site', $host);
     $document->setField('siteHash', $helper->getSiteHashForDomain($host));
     $document->setField('storeId', $storeId);
     $document->setField('created', $helper->dateToIso($product->getCreatedAt()));
     $document->setField('changed', $helper->dateToIso($product->getUpdatedAt()));
     $document->setField('sku', $product->getSku());
     $document->setField('productId', $product->getEntityId());
     $categoryIds = $product->getCategoryIds();
     foreach ($categoryIds as $categoryId) {
         $document->addField('categoryId', $categoryId);
     }
     $document->setField('isSalable', $product->isSalable());
     $document->setField('inStock', $product->isInStock());
     $document->setField('isVisible', $product->getStatus());
     $document->setField('isVisibleInCatalog', $product->isVisibleInCatalog());
     $document->setField('title', $product->getName());
     $document->setField('content', $product->getDescription());
     $document->setField('keywords', $helper->trimExplode(',', $product->getMetaKeyword(), true));
     $document->setField('url', $product->getProductUrl());
     $document->setField('price', $product->getPrice());
     if ($product->getManufacturer()) {
         $document->setField('manufacturer', $product->getAttributeText('manufacturer'));
     }
     $document->setField('image_stringS', $product->getImage());
     $document->setField('small_image_stringS', $product->getSmallImage());
     $document->setField('thumbnail_stringS', $product->getThumbnail());
     $productType = $product->getTypeId();
     $document->setField('type_id_stringS', $productType);
     if ($productType == 'configurable') {
         $childProductAttributes = $this->getConfigurableProductChildProductAttributes($storeId, $product);
         $indexableAttributes = array_merge($indexableAttributes, $childProductAttributes);
     }
     $fieldProcessorFactory = Mage::getResourceModel('solr/indexer_fieldprocessor_factory');
     // add other searchable attributes as dynamic fields
     foreach ($indexableAttributes as $attributeCode => $attributeValue) {
         if (empty($attributeValue) || in_array($attributeCode, $this->fixedSchemaFieldAttributes)) {
             // don't add fixed schema fields twice
             continue;
         }
         $fieldProcessor = $fieldProcessorFactory->getFieldProcessor($attributeCode, $attributeValue);
         $document->setField($fieldProcessor->getFieldName(), $fieldProcessor->getFieldValue());
     }
     return $document;
 }
开发者ID:VadzimBelski-ScienceSoft,项目名称:magento-MagSolr,代码行数:56,代码来源:Catalog.php

示例14: convertObjectToDocument

 public function convertObjectToDocument($dataObject, $stage = null, $fieldBoost = array())
 {
     $document = new Apache_Solr_Document();
     $fieldsToIndex = array();
     $object = null;
     // whether the original item is an object or array.
     // determines how we treat the object later when checking all the fields
     $sourceObject = true;
     $id = 0;
     if (is_object($dataObject)) {
         if ($dataObject->hasMethod('hasField') && $dataObject->hasField('ShowInSearch') && !$dataObject->ShowInSearch) {
             return;
         }
         $fieldsToIndex = $this->getSearchableFieldsFor($dataObject);
         // $dataObject->searchableFields();
         $object = $this->objectToFields($dataObject);
         $id = $dataObject->ID;
     } else {
         $object = $dataObject;
         $id = isset($dataObject['ID']) ? $dataObject['ID'] : 0;
         $fieldsToIndex = isset($object['index_fields']) ? $object['index_fields'] : array_flip(array_keys($object));
         $sourceObject = false;
     }
     $fieldsToIndex['SS_URL'] = true;
     $fieldsToIndex['SS_ID'] = true;
     $fieldsToIndex['LastEdited'] = true;
     $fieldsToIndex['Created'] = true;
     $fieldsToIndex['ClassName'] = true;
     $fieldsToIndex['ClassNameHierarchy'] = true;
     $fieldsToIndex['ParentsHierarchy'] = true;
     // the stage we're on when we write this doc to the index.
     // this is used for versioned AND non-versioned objects; we just cheat and
     // set it BOTH stages if it's non-versioned object
     $fieldsToIndex['SS_Stage'] = true;
     // if it's a versioned object, just save ONE stage value.
     if ($stage) {
         $object['SS_Stage'] = array('Type' => 'Enum', 'Value' => $stage);
         $id = $id . '_' . $stage;
     } else {
         $object['SS_Stage'] = array('Type' => 'Enum', 'Value' => array('Stage', 'Live'));
     }
     if (!$id) {
         return false;
     }
     // specially handle the subsite module - this has serious implications for our search
     // @TODO we want to genercise this later for other modules to hook into it!
     if (ClassInfo::exists('Subsite')) {
         $fieldsToIndex['SubsiteID'] = true;
         if (is_object($dataObject)) {
             $object['SubsiteID'] = array('Type' => 'Int', 'Value' => $dataObject->SubsiteID);
         }
     }
     $classType = isset($object['ClassName']) ? $object['ClassName']['Value'] : null;
     // we're not indexing the ID field because it conflicts with Solr's internal ID
     unset($object['ID']);
     // a special type hierarchy
     if ($classType) {
         $classes = array_values(ClassInfo::ancestry($classType));
         $object['ClassNameHierarchy'] = array('Type' => 'MultiValueField', 'Value' => $classes);
         $object['ParentsHierarchy'] = $this->getParentsHierarchyField($dataObject);
     }
     foreach ($object as $field => $valueDesc) {
         if (!$valueDesc) {
             continue;
         }
         if (!is_array($valueDesc) || !isset($valueDesc['Type'])) {
             // if we're indexing an object and there's no valueDesc, just skip this field
             if ($sourceObject) {
                 continue;
             }
             $valueDesc = array('Value' => $valueDesc, 'Type' => $this->mapper->mapValueToType($field, $valueDesc));
         }
         $type = $valueDesc['Type'];
         $value = $valueDesc['Value'];
         // this should have already been taken care of, but just in case...
         if ($type == 'MultiValueField' && $value instanceof MultiValueField) {
             $value = $value->getValues();
         }
         if (!isset($fieldsToIndex[$field])) {
             continue;
         }
         $fieldName = $this->mapper->mapFieldNameFromType($field, $type, $fieldsToIndex[$field]);
         if (!$fieldName) {
             continue;
         }
         $value = $this->mapper->convertValue($value, $type);
         if (is_array($value)) {
             foreach ($value as $v) {
                 $document->addField($fieldName, $v);
             }
         } else {
             $boost = false;
             if (isset($fieldBoost["{$fieldName}:{$value}"])) {
                 $boost = $fieldBoost["{$fieldName}:{$value}"];
             }
             $document->setField($fieldName, $value, $boost);
             $document->{$fieldName} = $value;
         }
     }
     $document->id = $classType ? $classType . '_' . $id : SolrSearchService::RAW_DATA_KEY . $id;
//.........这里部分代码省略.........
开发者ID:helpfulrobot,项目名称:silverstripe-solr,代码行数:101,代码来源:SolrSearchService.php

示例15: s4w_build_document

function s4w_build_document($post_info, $domain = NULL, $path = NULL)
{
    global $blog_id;
    global $current_blog;
    $doc = NULL;
    $plugin_s4w_settings = s4w_get_option();
    $exclude_ids = $plugin_s4w_settings['s4w_exclude_pages'];
    $categoy_as_taxonomy = $plugin_s4w_settings['s4w_cat_as_taxo'];
    $index_comments = $plugin_s4w_settings['s4w_index_comments'];
    $index_custom_fields = $plugin_s4w_settings['s4w_index_custom_fields'];
    if ($post_info) {
        # check if we need to exclude this document
        if (is_multisite() && in_array($current_blog->domain . $post_info->ID, (array) $exclude_ids)) {
            return NULL;
        } else {
            if (!is_multisite() && in_array($post_info->ID, (array) $exclude_ids)) {
                return NULL;
            }
        }
        $doc = new Apache_Solr_Document();
        $auth_info = get_userdata($post_info->post_author);
        # wpmu specific info
        if (is_multisite()) {
            // if we get here we expect that we've "switched" what blog we're running
            // as
            if ($domain == NULL) {
                $domain = $current_blog->domain;
            }
            if ($path == NULL) {
                $path = $current_blog->path;
            }
            $blogid = get_blog_id_from_url($domain, $path);
            $doc->setField('id', $domain . $path . $post_info->ID);
            $doc->setField('permalink', get_blog_permalink($blogid, $post_info->ID));
            $doc->setField('blogid', $blogid);
            $doc->setField('blogdomain', $domain);
            $doc->setField('blogpath', $path);
            $doc->setField('wp', 'multisite');
        } else {
            $doc->setField('id', $post_info->ID);
            $doc->setField('permalink', get_permalink($post_info->ID));
            $doc->setField('wp', 'wp');
        }
        $numcomments = 0;
        if ($index_comments) {
            $comments = get_comments("status=approve&post_id={$post_info->ID}");
            foreach ($comments as $comment) {
                $doc->addField('comments', $comment->comment_content);
                $numcomments += 1;
            }
        }
        $doc->setField('title', $post_info->post_title);
        $doc->setField('content', strip_tags($post_info->post_content));
        // rawcontent strips out characters lower than 0x20
        $doc->setField('rawcontent', strip_tags(preg_replace('/[^(\\x20-\\x7F)\\x0A]*/', '', $post_info->post_content)));
        // contentnoshortcodes also strips characters below 0x20 but also strips shortcodes
        // used in WP to add images or other content, useful if you're pulling this data
        // into another system
        //
        // For example
        //   [caption id="attachment_92495" align="alignright" width="160" caption="Duane Sand"][/caption] FARGO - Republican U.S. Senate...
        //
        // Will become
        //   FARGO - Republican U.S. Senate...
        $doc->setField('contentnoshortcodes', strip_tags(preg_replace('/[^(\\x20-\\x7F)\\x0A]*/', '', strip_tags(strip_shortcodes($post_info->post_content)))));
        $doc->setField('numcomments', $numcomments);
        $doc->setField('author', $auth_info->display_name);
        $doc->setField('author_s', get_author_posts_url($auth_info->ID, $auth_info->user_nicename));
        $doc->setField('type', $post_info->post_type);
        $doc->setField('date', s4w_format_date($post_info->post_date_gmt));
        $doc->setField('tdate', s4w_format_date($post_info->post_date_gmt));
        $doc->setField('modified', s4w_format_date($post_info->post_modified_gmt));
        $doc->setField('displaydate', $post_info->post_date);
        $doc->setField('displaymodified', $post_info->post_modified);
        $categories = get_the_category($post_info->ID);
        if (!$categories == NULL) {
            foreach ($categories as $category) {
                if ($categoy_as_taxonomy) {
                    $doc->addField('categories', get_category_parents($category->cat_ID, FALSE, '^^'));
                } else {
                    $doc->addField('categories', $category->cat_name);
                }
            }
        }
        //get all the taxonomy names used by wp
        $taxonomies = (array) get_taxonomies(array('_builtin' => FALSE), 'names');
        foreach ($taxonomies as $parent) {
            $terms = get_the_terms($post_info->ID, $parent);
            if ((array) $terms === $terms) {
                //we are creating *_taxonomy as dynamic fields using our schema
                //so lets set up all our taxonomies in that format
                $parent = $parent . "_taxonomy";
                foreach ($terms as $term) {
                    $doc->addField($parent, $term->name);
                }
            }
        }
        $tags = get_the_tags($post_info->ID);
        if (!$tags == NULL) {
            foreach ($tags as $tag) {
//.........这里部分代码省略.........
开发者ID:nrcmedia,项目名称:solr-for-wordpress,代码行数:101,代码来源:solr-for-wordpress.php


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