本文整理汇总了PHP中Apache_Solr_Document::getField方法的典型用法代码示例。如果您正苦于以下问题:PHP Apache_Solr_Document::getField方法的具体用法?PHP Apache_Solr_Document::getField怎么用?PHP Apache_Solr_Document::getField使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Apache_Solr_Document
的用法示例。
在下文中一共展示了Apache_Solr_Document::getField方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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);
}
}
}
示例2: 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');
}
示例3: testMagicSetForFieldValues
public function testMagicSetForFieldValues()
{
$field = 'field';
$value = 'value';
// set field value with magic __set
$this->_fixture->{$field} = $value;
$fieldArray = $this->_fixture->getField($field);
// set values
$this->assertEquals($field, $fieldArray['name']);
$this->assertEquals($value, $fieldArray['value']);
$this->assertTrue($fieldArray['boost'] === false);
}
示例4: 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);
}
}
}
示例5: 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);
}
}
}
示例6: 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');