• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Apache_Solr_Document类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: 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


示例2: getMockDocument

 protected function getMockDocument($id)
 {
     $document = new Apache_Solr_Document();
     $document->setField('id', $id);
     $document->setField('title', "Item {$id}");
     return $document;
 }
开发者ID:helpfulrobot,项目名称:silverstripe-fulltextsearch,代码行数:7,代码来源:Solr4ServiceTest.php


示例3: addDocument

 public function addDocument($data)
 {
     $document = new Apache_Solr_Document();
     foreach ($data as $key => $value) {
         if (is_array($value)) {
             foreach ($value as $datum) {
                 if (is_numeric($datum)) {
                     number_format($datum);
                 }
                 $document->setMultiValue($key, $datum);
             }
         } else {
             if (is_numeric($value)) {
                 number_format($value);
             }
             $document->{$key} = $value;
         }
     }
     try {
         $rs = $this->_solrService->addDocument($document);
         // asynchronous commit
         // $this->_solrService->commit(true);
         return $rs;
     } catch (Exception $e) {
         return $e->getMessage();
     }
 }
开发者ID:ubriela,项目名称:solr-websearch,代码行数:27,代码来源:Services.php


示例4: pushDocuments

 /**
  * 
  * @param Apache_Solr_Document or Array $parts
  * 
  * @return SP_Controller_Action_Helper_Solr
  */
 public function pushDocuments($parts)
 {
     $this->_setSolrService();
     if ($parts instanceof Apache_Solr_Document) {
         $this->documents[] = $parts;
     } else {
         if (is_array($parts)) {
             foreach ($parts as $item => $fields) {
                 if ($fields instanceof Apache_Solr_Document) {
                     $this->documents[] = $fields;
                 } else {
                     $part = new Apache_Solr_Document();
                     foreach ($fields as $key => $value) {
                         if (is_array($value)) {
                             foreach ($value as $datum) {
                                 $part->setMultiValue($key, $datum);
                             }
                         } else {
                             $part->setField($key, $value);
                         }
                     }
                     $this->documents[] = $part;
                 }
             }
         } else {
             trigger_error("the paramter \$part must be an object of Apache_Solr_Document or an array");
         }
     }
     return $this;
 }
开发者ID:victorli,项目名称:ShrimpProject,代码行数:36,代码来源:Solr.php


示例5: addDocuments

 public function addDocuments($datas)
 {
     $documents = array();
     foreach ($datas as $item => $fields) {
         $part = new Apache_Solr_Document();
         foreach ($fields as $key => $value) {
             if (is_array($value)) {
                 foreach ($value as $datum) {
                     $part->setMultiValue($key, $datum);
                 }
             } else {
                 $part->{$key} = $value;
             }
         }
         $documents[] = $part;
     }
     try {
         $rs = $this->_solrService->addDocuments($documents);
         // asynchronous commit
         //$this->_solrService->commit(true);
         return $rs;
     } catch (Exception $e) {
         return $e->getMessage();
     }
 }
开发者ID:ubriela,项目名称:solr-websearch,代码行数:25,代码来源:Services.php


示例6: processDocument

 /**
  * modifies a document according to the given configuration
  *
  * @param	Apache_Solr_Document	$document
  * @param	array	$processingConfiguration
  */
 public function processDocument(Apache_Solr_Document $document, array $processingConfiguration)
 {
     foreach ($processingConfiguration as $fieldName => $instruction) {
         $fieldInformation = $document->getField($fieldName);
         $isSingleValueField = FALSE;
         if ($fieldInformation !== FALSE) {
             $fieldValue = $fieldInformation['value'];
             if (!is_array($fieldValue)) {
                 // turn single value field into multi value field
                 $fieldValue = array($fieldValue);
                 $isSingleValueField = TRUE;
             }
             switch ($instruction) {
                 case 'timestampToIsoDate':
                     $processor = t3lib_div::makeInstance('tx_solr_fieldprocessor_TimestampToIsoDate');
                     $fieldValue = $processor->process($fieldValue);
                     break;
                 case 'uppercase':
                     $fieldValue = array_map('strtoupper', $fieldValue);
                     break;
             }
             if ($isSingleValueField) {
                 // turn multi value field back into single value field
                 $fieldValue = $fieldValue[0];
             }
             $document->setField($fieldName, $fieldValue);
         }
     }
 }
开发者ID:hkremer,项目名称:Publieke-Omroep-Typo3,代码行数:35,代码来源:class.tx_solr_fieldprocessor_service.php


示例7: 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


示例8: 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


示例9: itemToDocument

 /**
  * This takes an Omeka_Record instance and returns a populated
  * Apache_Solr_Document.
  *
  * @param Omeka_Record $item The record to index.
  *
  * @return Apache_Solr_Document
  * @author Eric Rochester <[email protected]>
  **/
 public static function itemToDocument($item)
 {
     $fields = get_db()->getTable('SolrSearchField');
     $doc = new Apache_Solr_Document();
     $doc->setField('id', "Item_{$item->id}");
     $doc->setField('resulttype', 'Item');
     $doc->setField('model', 'Item');
     $doc->setField('modelid', $item->id);
     // extend $doc to to include and items public / private status
     $doc->setField('public', $item->public);
     // Title:
     $title = metadata($item, array('Dublin Core', 'Title'));
     $doc->setField('title', $title);
     // Elements:
     self::indexItem($fields, $item, $doc);
     // Tags:
     foreach ($item->getTags() as $tag) {
         $doc->setMultiValue('tag', $tag->name);
     }
     // Collection:
     if ($collection = $item->getCollection()) {
         $doc->collection = metadata($collection, array('Dublin Core', 'Title'));
     }
     // Item type:
     if ($itemType = $item->getItemType()) {
         $doc->itemtype = $itemType->name;
     }
     $doc->featured = (bool) $item->featured;
     // File metadata
     foreach ($item->getFiles() as $file) {
         self::indexItem($fields, $file, $doc);
     }
     return $doc;
 }
开发者ID:AdrienneSerra,项目名称:Digitalsc,代码行数:43,代码来源:SolrSearch_Helpers_Index.php


示例10: buildDocument

 /**
  * Builds an Apache_Solr_Document to pass to Apache_Solr_Service
  **/
 public function buildDocument(array $document)
 {
     $doc = new Apache_Solr_Document();
     foreach ($document as $fieldName => $field) {
         $value = $field['value'];
         // Apache_Solr_Document always expect arrays
         if (!is_array($value)) {
             $value = array($value);
         }
         if (isset($field['boost'])) {
             $doc->setField($fieldName, $value, $field['boost']);
         } else {
             $doc->setField($fieldName, $value);
         }
     }
     return $doc;
 }
开发者ID:joericochuyt,项目名称:tjSolrDoctrineBehaviorPlugin,代码行数:20,代码来源:Solr.php


示例11: cromSolar

 public function cromSolar($id, $caso = null)
 {
     $adapter = $this->tableGateway->getAdapter();
     $sql = new Sql($adapter);
     $selecttot = $sql->select()->from('ta_plato')->join(array('c' => 'ta_comentario'), 'c.ta_plato_in_id=ta_plato.in_id', array('cantidad' => new \Zend\Db\Sql\Expression('COUNT(c.in_id)')), 'left')->join('ta_tipo_plato', 'ta_plato.ta_tipo_plato_in_id=ta_tipo_plato.in_id ', array('tipo_plato_nombre' => 'va_nombre'), 'left')->join(array('pl' => 'ta_plato_has_ta_local'), 'pl.Ta_plato_in_id = ta_plato.in_id', array(), 'left')->join(array('tl' => 'ta_local'), 'tl.in_id = pl.Ta_local_in_id', array('latitud' => 'de_latitud', 'longitud' => 'de_longitud', 'direccion' => 'va_direccion', 'telefono' => 'va_telefono'), 'left')->join(array('tr' => 'ta_restaurante'), 'tr.in_id = tl.ta_restaurante_in_id', array('restaurant_nombre' => 'va_nombre', 'restaurant_estado' => 'en_estado'), 'left')->join(array('tc' => 'ta_tipo_comida'), 'tc.in_id = tr.Ta_tipo_comida_in_id', array('nombre_tipo_comida' => 'va_nombre_tipo'), 'left')->join(array('tu' => 'ta_ubigeo'), 'tu.in_id = tl.ta_ubigeo_in_id', array('distrito' => 'ch_distrito', 'departamento' => 'ch_departamento'), 'left')->where(array('ta_plato.in_id' => $id));
     $selecttot->group('ta_plato.in_id');
     $selectString = $sql->getSqlStringForSqlObject($selecttot);
     $results = $adapter->query($selectString, $adapter::QUERY_MODE_EXECUTE);
     $plato = $results->toArray();
     $selectto = $sql->select()->from('ta_plato')->join(array('tpt' => 'ta_plato_has_ta_tag'), 'tpt.Ta_plato_in_id = ta_plato.in_id', array('tag_id' => 'ta_tag_in_id'), 'left')->join(array('tt' => 'ta_tag'), 'tt.in_id =tpt.ta_tag_in_id', array('tag' => 'va_nombre'), 'left')->where(array('ta_plato.in_id' => $id));
     $selectStrin = $sql->getSqlStringForSqlObject($selectto);
     $result = $adapter->query($selectStrin, $adapter::QUERY_MODE_EXECUTE);
     $tag = $result->toArray();
     $solr = \Classes\Solr::getInstance()->getSolr();
     if ($solr->ping()) {
         if ($caso !== 1) {
             $solr->deleteByQuery('id:' . $id);
         }
         $document = new \Apache_Solr_Document();
         $document->id = $id;
         $document->name = $plato[0]['va_nombre'];
         $document->tx_descripcion = $plato[0]['tx_descripcion'];
         $document->va_precio = $plato[0]['va_precio'];
         $document->en_estado = $plato[0]['en_estado'];
         $document->plato_tipo = $plato[0]['tipo_plato_nombre'];
         $document->va_direccion = $plato[0]['direccion'];
         $document->restaurante = $plato[0]['restaurant_nombre'];
         $document->tipo_comida = $plato[0]['nombre_tipo_comida'];
         $document->en_destaque = $plato[0]['en_destaque'];
         $document->va_telefono = $plato[0]['telefono'];
         $document->latitud = $plato[0]['latitud'];
         $document->longitud = $plato[0]['longitud'];
         $document->departamento = $plato[0]['departamento'];
         foreach ($tag as $resultado) {
             $document->setMultiValue('tag', $resultado['tag']);
         }
         $document->distrito = $plato[0]['distrito'];
         $document->va_imagen = $plato[0]['va_imagen'];
         $document->comentarios = $plato[0]['cantidad'];
         $document->restaurant_estado = $plato[0]['restaurant_estado'];
         $document->puntuacion = $plato[0]['Ta_puntaje_in_id'];
         $solr->addDocument($document);
         $solr->commit();
     }
 }
开发者ID:kevcast,项目名称:lsrefactoring,代码行数:45,代码来源:ComentariosTable.php


示例12: processDocument

 /**
  * modifies a document according to the given configuration
  *
  * @param Apache_Solr_Document $document
  * @param array $processingConfiguration
  */
 public function processDocument(Apache_Solr_Document $document, array $processingConfiguration)
 {
     foreach ($processingConfiguration as $fieldName => $instruction) {
         $fieldInformation = $document->getField($fieldName);
         $isSingleValueField = FALSE;
         if ($fieldInformation !== FALSE) {
             $fieldValue = $fieldInformation['value'];
             if (!is_array($fieldValue)) {
                 // turn single value field into multi value field
                 $fieldValue = array($fieldValue);
                 $isSingleValueField = TRUE;
             }
             switch ($instruction) {
                 case 'timestampToUtcIsoDate':
                     $processor = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('Tx_Solr_FieldProcessor_TimestampToUtcIsoDate');
                     $fieldValue = $processor->process($fieldValue);
                     break;
                 case 'timestampToIsoDate':
                     $processor = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('Tx_Solr_FieldProcessor_TimestampToIsoDate');
                     $fieldValue = $processor->process($fieldValue);
                     break;
                 case 'pathToHierarchy':
                     $processor = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('Tx_Solr_FieldProcessor_PathToHierarchy');
                     $fieldValue = $processor->process($fieldValue);
                     break;
                 case 'pageUidToHierarchy':
                     $processor = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('Tx_Solr_FieldProcessor_PageUidToHierarchy');
                     $fieldValue = $processor->process($fieldValue);
                     break;
                 case 'categoryUidToHierarchy':
                     $processor = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('Tx_Solr_FieldProcessor_CategoryUidToHierarchy');
                     $fieldValue = $processor->process($fieldValue);
                     break;
                 case 'uppercase':
                     $fieldValue = array_map('strtoupper', $fieldValue);
                     break;
             }
             if ($isSingleValueField) {
                 // turn multi value field back into single value field
                 $fieldValue = $fieldValue[0];
             }
             $document->setField($fieldName, $fieldValue);
         }
     }
 }
开发者ID:romaincanon,项目名称:ext-solr,代码行数:51,代码来源:Service.php


示例13: processDocument

 /**
  * modifies a document according to the given configuration
  *
  * @param \Apache_Solr_Document $document
  * @param array $processingConfiguration
  */
 public function processDocument(\Apache_Solr_Document $document, array $processingConfiguration)
 {
     foreach ($processingConfiguration as $fieldName => $instruction) {
         $fieldInformation = $document->getField($fieldName);
         $isSingleValueField = false;
         if ($fieldInformation !== false) {
             $fieldValue = $fieldInformation['value'];
             if (!is_array($fieldValue)) {
                 // turn single value field into multi value field
                 $fieldValue = array($fieldValue);
                 $isSingleValueField = true;
             }
             switch ($instruction) {
                 case 'timestampToUtcIsoDate':
                     $processor = GeneralUtility::makeInstance('ApacheSolrForTypo3\\Solr\\FieldProcessor\\TimestampToUtcIsoDate');
                     $fieldValue = $processor->process($fieldValue);
                     break;
                 case 'timestampToIsoDate':
                     $processor = GeneralUtility::makeInstance('ApacheSolrForTypo3\\Solr\\FieldProcessor\\TimestampToIsoDate');
                     $fieldValue = $processor->process($fieldValue);
                     break;
                 case 'pathToHierarchy':
                     $processor = GeneralUtility::makeInstance('ApacheSolrForTypo3\\Solr\\FieldProcessor\\PathToHierarchy');
                     $fieldValue = $processor->process($fieldValue);
                     break;
                 case 'pageUidToHierarchy':
                     $processor = GeneralUtility::makeInstance('ApacheSolrForTypo3\\Solr\\FieldProcessor\\PageUidToHierarchy');
                     $fieldValue = $processor->process($fieldValue);
                     break;
                 case 'categoryUidToHierarchy':
                     $processor = GeneralUtility::makeInstance('ApacheSolrForTypo3\\Solr\\FieldProcessor\\CategoryUidToHierarchy');
                     $fieldValue = $processor->process($fieldValue);
                     break;
                 case 'uppercase':
                     $fieldValue = array_map('strtoupper', $fieldValue);
                     break;
             }
             if ($isSingleValueField) {
                 // turn multi value field back into single value field
                 $fieldValue = $fieldValue[0];
             }
             $document->setField($fieldName, $fieldValue);
         }
     }
 }
开发者ID:Gregor-Agnes,项目名称:ext-solr,代码行数:51,代码来源:Service.php


示例14: 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


示例15: _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


示例16: buildFileDocument

 /**
  * Build a Solr document for a specific file
  *
  * @param integer $storeId Store ID the file belongs to/where it is linked on a page
  * @param Asm_Solr_Model_Indexqueue_File $file The file to index
  * @return Apache_Solr_Document
  */
 protected function buildFileDocument($storeId, Asm_Solr_Model_Indexqueue_File $file)
 {
     $helper = Mage::helper('solr');
     $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', 'solr/indexqueue_file');
     $document->setField('id', $helper->getFileDocumentId($file->getId()));
     $document->setField('site', $host);
     $document->setField('siteHash', $helper->getSiteHashForDomain($host));
     $document->setField('storeId', $storeId);
     $document->setField('changed', $helper->dateToIso($file->getFileLastChangedTime()));
     $document->setField('productId', 0);
     $document->setField('sku', 'solr/indexqueue_file');
     $document->setField('title', $file->getName());
     $document->setField('content', $file->getContent());
     $document->setField('url', $file->getUrl());
     return $document;
 }
开发者ID:brethash,项目名称:magento-MagSolr,代码行数:27,代码来源:File.php


示例17: _documentToXmlFragment

 /**
  * Create an XML fragment from a {@link Apache_Solr_Document} instance appropriate for use inside a Solr add call
  *
  * @return string
  */
 protected function _documentToXmlFragment(Apache_Solr_Document $document)
 {
     $xml = '<doc';
     if ($document->getBoost() !== false) {
         $xml .= ' boost="' . $document->getBoost() . '"';
     }
     $xml .= '>';
     foreach ($document as $key => $value) {
         $key = htmlspecialchars($key, ENT_QUOTES, 'UTF-8');
         $fieldBoost = $document->getFieldBoost($key);
         if ($key) {
             if (is_array($value)) {
                 foreach ($value as $multivalue) {
                     $xml .= '<field name="' . $key . '"';
                     if ($fieldBoost !== false) {
                         $xml .= ' boost="' . $fieldBoost . '"';
                         // only set the boost for the first field in the set
                         $fieldBoost = false;
                     }
                     if (!mb_check_encoding($multivalue, 'UTF-8')) {
                         $multivalue = utf8_encode($multivalue);
                     }
                     $multivalue = htmlspecialchars($multivalue, ENT_NOQUOTES, 'UTF-8');
                     $xml .= '>' . $multivalue . '</field>';
                 }
             } else {
                 $xml .= '<field name="' . $key . '"';
                 if ($fieldBoost !== false) {
                     $xml .= ' boost="' . $fieldBoost . '"';
                 }
                 if (!mb_check_encoding($value, 'UTF-8')) {
                     $value = utf8_encode($value);
                 }
                 $value = htmlspecialchars($value, ENT_NOQUOTES, 'UTF-8');
                 $xml .= '>' . $value . '</field>';
             }
         }
     }
     $xml .= '</doc>';
     return $xml;
 }
开发者ID:hfroese,项目名称:mediawiki-extensions-BlueSpiceExtensions,代码行数:46,代码来源:Service.php


示例18: reference_authors_to_text_string

     			{
     				$authors[] = $a->forename . ' ' . $a->surname;
     			}
     			$item['authors'] = $authors;
     			$item['citation'] = reference_authors_to_text_string($reference)
     				. ' ' . $reference->year 
     				. ' ' . $reference->title
     				. ' ' . reference_to_citation_text_string($reference);
     */
     print_r($item);
     $parts[] = $item;
 }
 print_r($parts);
 $documents = array();
 foreach ($parts as $item => $fields) {
     $part = new Apache_Solr_Document();
     foreach ($fields as $key => $value) {
         if (is_array($value)) {
             foreach ($value as $datum) {
                 $part->setMultiValue($key, $datum);
             }
         } else {
             $part->{$key} = $value;
         }
     }
     $documents[] = $part;
 }
 //
 //
 // Load the documents into the index
 //
开发者ID:rdmpage,项目名称:bioguid,代码行数:31,代码来源:solr_bulk_load.php


示例19: _documentToXmlFragment

 /**
  * Create an XML fragment from a {@link Apache_Solr_Document} instance appropriate for use inside a Solr add call
  *
  * @return string
  */
 protected function _documentToXmlFragment(Apache_Solr_Document $document)
 {
     $xml = '<doc';
     if ($document->getBoost() !== false) {
         $xml .= ' boost="' . $document->getBoost() . '"';
     }
     $xml .= '>';
     foreach ($document as $key => $value) {
         $key = htmlspecialchars($key, ENT_QUOTES, 'UTF-8');
         $fieldBoost = $document->getFieldBoost($key);
         if (is_array($value)) {
             foreach ($value as $multivalue) {
                 $xml .= '<field name="' . $key . '"';
                 if ($fieldBoost !== false) {
                     $xml .= ' boost="' . $fieldBoost . '"';
                     // only set the boost for the first field in the set
                     $fieldBoost = false;
                 }
                 $multivalue = htmlspecialchars($multivalue, ENT_NOQUOTES, 'UTF-8');
                 $xml .= '>' . $multivalue . '</field>';
             }
         } else {
             $xml .= '<field name="' . $key . '"';
             if ($fieldBoost !== false) {
                 $xml .= ' boost="' . $fieldBoost . '"';
             }
             $value = htmlspecialchars($value, ENT_NOQUOTES, 'UTF-8');
             $xml .= '>' . $value . '</field>';
         }
     }
     $xml .= '</doc>';
     // replace any control characters to avoid Solr XML parser exception
     return $this->_stripCtrlChars($xml);
 }
开发者ID:austinvernsonger,项目名称:casebox,代码行数:39,代码来源:Service.php


示例20: buildPageDocument

 /**
  * Build a Solr document for a given page
  *
  * @param integer $storeId Store ID
  * @param Mage_Cms_Model_Page $page Page instance
  * @return Apache_Solr_Document
  */
 protected function buildPageDocument($storeId, $page)
 {
     $helper = Mage::helper('solr');
     $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', 'cms/page');
     $document->setField('id', $helper->getPageDocumentId($page->getId()));
     $document->setField('site', $host);
     $document->setField('siteHash', $helper->getSiteHashForDomain($host));
     $document->setField('storeId', $storeId);
     $document->setField('created', $helper->dateToIso($page->getCreationTime()));
     $document->setField('changed', $helper->dateToIso($page->getUpdateTime()));
     $document->setField('sku', 'cms/page');
     $document->setField('productId', 0);
     $document->setField('pageId', $page->getId());
     $document->setField('title', $page->getTitle());
     $document->setField('content', Mage::helper('solr/contentExtractor')->getIndexableContent($page->getContent()));
     $document->setField('keywords', $helper->trimExplode(',', $page->getMetaKeywords(), true));
     $document->setField('url', Mage::helper('cms/page')->getPageUrl($page->getId()));
     return $document;
 }
开发者ID:VadzimBelski-ScienceSoft,项目名称:magento-MagSolr,代码行数:30,代码来源:Cms.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Apache_Solr_Response类代码示例发布时间:2022-05-23
下一篇:
PHP Answer类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap