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


PHP Apache_Solr_Document::getFieldNames方法代码示例

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


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

示例1: testClearReturnsDocumentToDefaultState

 public function testClearReturnsDocumentToDefaultState()
 {
     // set the document boost
     $this->_fixture->setBoost(0.5);
     // set a field
     $this->_fixture->someField = "some value";
     // clear the document to remove boost and fields
     $this->_fixture->clear();
     // document boost should now be false
     $this->assertFalse($this->_fixture->getBoost());
     // document fields should now be empty
     $this->assertEquals(0, count($this->_fixture->getFieldNames()));
     $this->assertEquals(0, count($this->_fixture->getFieldValues()));
     $this->assertEquals(0, count($this->_fixture->getFieldBoosts()));
     // document iterator should now be empty
     $this->assertEquals(0, iterator_count($this->_fixture));
 }
开发者ID:rande,项目名称:sfSolrPlugin,代码行数:17,代码来源:DocumentTest.php

示例2: processDocumentFieldsToArray

 /**
  * takes a search result document and processes its fields according to the
  * instructions configured in TS. Currently available instructions are
  *    * timestamp - converts a date field into a unix timestamp
  *    * serialize - uses serialize() to encode multivalue fields which then can be put out using the MULTIVALUE view helper
  *    * skip - skips the whole field so that it is not available in the result, useful for the spell field f.e.
  * The default is to do nothing and just add the document's field to the
  * resulting array.
  *
  * @param \Apache_Solr_Document $document the Apache_Solr_Document result document
  * @return array An array with field values processed like defined in TS
  */
 protected function processDocumentFieldsToArray(\Apache_Solr_Document $document)
 {
     $processingInstructions = $this->configuration->getSearchResultsFieldProcessingInstructionsConfiguration();
     $availableFields = $document->getFieldNames();
     $result = array();
     foreach ($availableFields as $fieldName) {
         $processingInstruction = $processingInstructions[$fieldName];
         // TODO switch to field processors
         // TODO allow to have multiple (comma-separated) instructions for each field
         switch ($processingInstruction) {
             case 'timestamp':
                 $processedFieldValue = Util::isoToTimestamp($document->{$fieldName});
                 break;
             case 'serialize':
                 if (!empty($document->{$fieldName})) {
                     $processedFieldValue = serialize($document->{$fieldName});
                 } else {
                     $processedFieldValue = '';
                 }
                 break;
             case 'skip':
                 continue 2;
             default:
                 $processedFieldValue = $document->{$fieldName};
         }
         // escape markers in document fields
         // TODO remove after switching to fluid templates
         $processedFieldValue = Template::escapeMarkers($processedFieldValue);
         $result[$fieldName] = $processedFieldValue;
     }
     return $result;
 }
开发者ID:hnadler,项目名称:ext-solr,代码行数:44,代码来源:ResultsCommand.php

示例3: processDocumentFieldsToArray

 /**
  * takes a search result document and processes its fields according to the
  * instructions configured in TS. Currently available instructions are
  * 	* timestamp - converts a date field into a unix timestamp
  * 	* utf8Decode - decodes utf8
  * 	* skip - skips the whole field so that it is not available in the result, usefull for the spell field f.e.
  * The default is to do nothing and just add the document's field to the
  * resulting array.
  *
  * @param	Apache_Solr_Document	$document the Apache_Solr_Document result document
  * @return	array	An array with field values processed like defined in TS
  */
 protected function processDocumentFieldsToArray(Apache_Solr_Document $document)
 {
     $processingInstructions = $GLOBALS['TSFE']->tmpl->setup['plugin.']['tx_solr.']['search.']['results.']['fieldProcessingInstructions.'];
     $availableFields = $document->getFieldNames();
     $result = array();
     foreach ($availableFields as $fieldName) {
         $processingInstruction = $processingInstructions[$fieldName];
         // TODO switch to field processors
         // TODO allow to have multiple (commaseparated) instructions for each field
         switch ($processingInstruction) {
             case 'timestamp':
                 $parsedTime = strptime($document->{$fieldName}, '%Y-%m-%dT%H:%M:%SZ');
                 $processedFieldValue = mktime($parsedTime['tm_hour'], $parsedTime['tm_min'], $parsedTime['tm_sec'], $parsedTime['tm_mon'] + 1, $parsedTime['tm_mday'], $parsedTime['tm_year'] + 1900);
                 break;
             case 'utf8Decode':
                 $processedFieldValue = $this->utf8Decode($document->{$fieldName});
                 break;
             case 'skip':
                 continue 2;
             default:
                 $processedFieldValue = $document->{$fieldName};
         }
         $result[$fieldName] = $processedFieldValue;
     }
     return $result;
 }
开发者ID:hkremer,项目名称:Publieke-Omroep-Typo3,代码行数:38,代码来源:class.tx_solr_pi_results_resultscommand.php

示例4: processDocumentFieldsToArray

 /**
  * takes a search result document and processes its fields according to the
  * instructions configured in TS. Currently available instructions are
  * 	* timestamp - converts a date field into a unix timestamp
  * 	* serialize - uses serialize() to encode multivalue fields which then can be put out using the MULTIVALUE view helper
  * 	* skip - skips the whole field so that it is not available in the result, usefull for the spell field f.e.
  * The default is to do nothing and just add the document's field to the
  * resulting array.
  *
  * @param	Apache_Solr_Document	$document the Apache_Solr_Document result document
  * @return	array	An array with field values processed like defined in TS
  */
 protected function processDocumentFieldsToArray(Apache_Solr_Document $document)
 {
     $processingInstructions = $GLOBALS['TSFE']->tmpl->setup['plugin.']['tx_solr.']['search.']['results.']['fieldProcessingInstructions.'];
     $availableFields = $document->getFieldNames();
     $result = array();
     foreach ($availableFields as $fieldName) {
         $processingInstruction = $processingInstructions[$fieldName];
         // TODO switch to field processors
         // TODO allow to have multiple (commaseparated) instructions for each field
         switch ($processingInstruction) {
             case 'timestamp':
                 $processedFieldValue = Tx_Solr_Util::isoToTimestamp($document->{$fieldName});
                 break;
             case 'serialize':
                 if (!empty($document->{$fieldName})) {
                     $processedFieldValue = serialize($document->{$fieldName});
                 } else {
                     $processedFieldValue = '';
                 }
                 break;
             case 'skip':
                 continue 2;
             default:
                 $processedFieldValue = $document->{$fieldName};
         }
         // escape markers in document fields
         // TODO remove after switching to fluid templates
         $processedFieldValue = Tx_Solr_Template::escapeMarkers($processedFieldValue);
         $result[$fieldName] = $processedFieldValue;
     }
     return $result;
 }
开发者ID:raimundlandig,项目名称:winkel.de-DEV,代码行数:44,代码来源:ResultsCommand.php


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