本文整理汇总了PHP中eZSolr::getFieldName方法的典型用法代码示例。如果您正苦于以下问题:PHP eZSolr::getFieldName方法的具体用法?PHP eZSolr::getFieldName怎么用?PHP eZSolr::getFieldName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eZSolr
的用法示例。
在下文中一共展示了eZSolr::getFieldName方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: filterQueryParams
/**
* Modifies SolR query params according to filter parameters
* @param array $queryParams
* @param array $filterParams
* @return array $queryParams
*/
public function filterQueryParams(array $queryParams, array $filterParams)
{
try {
if (!isset($filterParams['field'])) {
throw new Exception('Missing filter parameter "field"');
}
if (!isset($filterParams['latitude'])) {
throw new Exception('Missing filter parameter "latitude"');
}
if (!isset($filterParams['longitude'])) {
throw new Exception('Missing filter parameter "longitude"');
}
$fieldName = eZSolr::getFieldName($filterParams['field']);
//geodist custom parameters
$queryParams['sfield'] = $fieldName;
$queryParams['pt'] = $filterParams['latitude'] . ',' . $filterParams['longitude'];
//sort by geodist
$queryParams['sort'] = 'geodist() asc,' . $queryParams['sort'];
//exclude unlocated documents
$queryParams['fq'][] = $fieldName . ':[-90,-90 TO 90,90]';
} catch (Exception $e) {
eZDebug::writeWarning($e->getMessage(), __CLASS__);
}
return $queryParams;
}
示例2: buildFacetQueryParamList
/**
* Build facet parameter list. This function extracts the facet parameter from
* the ezfeZPSolrQueryBuilder::search( ...,$params parameter.
*
* @todo specify dedicated facet fields (may be mapped to sort fields)
*
* @param array Parameter list array
*
* @return array List of Facet query parameter. The facet parameter corrosponds to
* the parameters defined here : http://wiki.apache.org/solr/SimpleFacetParameters
*/
protected function buildFacetQueryParamList($parameterList)
{
$parameterList = array_change_key_case($parameterList, CASE_LOWER);
$queryParamList = array();
if (empty($parameterList['facet'])) {
return $queryParamList;
}
// Loop through facet definitions, and build facet query.
foreach ($parameterList['facet'] as $facetDefinition) {
if (empty($facetDefinition['field']) and empty($facetDefinition['query']) and empty($facetDefinition['date']) and empty($facetDefinition['range']) and empty($facetDefinition['prefix'])) {
eZDebug::writeDebug('No facet field or query provided.', __METHOD__);
continue;
}
$queryPart = array();
if (!empty($facetDefinition['field'])) {
switch ($facetDefinition['field']) {
case 'author':
$queryPart['field'] = eZSolr::getMetaFieldName('owner_id', 'facet');
break;
case 'class':
$queryPart['field'] = eZSolr::getMetaFieldName('contentclass_id', 'facet');
break;
case 'installation':
$queryPart['field'] = eZSolr::getMetaFieldName('installation_id', 'facet');
break;
case 'translation':
$queryPart['field'] = eZSolr::getMetaFieldName('language_code', 'facet');
break;
default:
$fieldName = eZSolr::getFieldName($facetDefinition['field'], false, 'facet');
if (!$fieldName and empty($facetDefinition['date'])) {
eZDebug::writeNotice('Facet field does not exist in local installation, but may still be valid: ' . $facetDefinition['field'], __METHOD__);
continue;
}
$queryPart['field'] = $fieldName;
break;
}
}
// Get query part.
if (!empty($facetDefinition['query'])) {
list($field, $query) = explode(':', $facetDefinition['query'], 2);
$field = eZSolr::getFieldName($field, false, 'facet');
if (!$field) {
eZDebug::writeNotice('Invalid query field provided: ' . $facetDefinition['query'], __METHOD__);
continue;
}
$queryPart['query'] = $field . ':' . $query;
}
// Get prefix.
// TODO: make this per mandatory per field in order to construct f.<fieldname>.facet.prefix queries
if (!empty($facetDefinition['prefix'])) {
$queryPart['prefix'] = $facetDefinition['prefix'];
}
// range facets: fill the $queryParamList array directly
if (!empty($facetDefinition['range']) && !empty($facetDefinition['range']['field']) && !empty($facetDefinition['range']['start']) && !empty($facetDefinition['range']['end']) && !empty($facetDefinition['range']['gap'])) {
$fieldName = '';
switch ($facetDefinition['range']['field']) {
case 'published':
$fieldName = eZSolr::getMetaFieldName('published', 'facet');
break;
case 'modified':
$fieldName = eZSolr::getMetaFieldName('modified', 'facet');
break;
default:
$fieldName = eZSolr::getFieldName($facetDefinition['field'], false, 'facet');
}
$perFieldRangePrefix = 'f.' . $fieldName . '.facet.range';
$queryParamList['facet.range'] = $fieldName;
$queryParamList[$perFieldRangePrefix . '.start'] = $facetDefinition['range']['start'];
$queryParamList[$perFieldRangePrefix . '.end'] = $facetDefinition['range']['end'];
$queryParamList[$perFieldRangePrefix . '.gap'] = $facetDefinition['range']['gap'];
if (!empty($facetDefinition['range']['hardend'])) {
$queryParamList[$perFieldRangePrefix . '.hardend'] = $facetDefinition['range']['hardend'];
}
if (!empty($facetDefinition['range']['include'])) {
$queryParamList[$perFieldRangePrefix . '.include'] = $facetDefinition['range']['include'];
}
if (!empty($facetDefinition['range']['other'])) {
$queryParamList[$perFieldRangePrefix . '.other'] = $facetDefinition['range']['other'];
}
}
// Get sort option.
if (!empty($facetDefinition['sort'])) {
switch (strtolower($facetDefinition['sort'])) {
case 'count':
$queryPart['sort'] = 'true';
break;
case 'alpha':
$queryPart['sort'] = 'false';
//.........这里部分代码省略.........
示例3: testGetFieldName
/**
* @dataProvider providerTestGetFieldName
**/
public function testGetFieldName($expected, $baseName, $includingClassID = false)
{
self::assertEquals($expected, eZSolr::getFieldName($baseName, $includingClassID));
}