What are the available options for the ezselection that is always empty? Is it in the same class as the other ezselection?
Certified eZ publish developer with over 9 years of eZ publish experience. Available for challenging eZ publish projects as a technical consultant, project manager, trouble shooter or strategic advisor.
Matthieu Sévère
Wednesday 10 March 2010 7:10:00 am
on a first selection (the one not working) I have :
Have you tried with only 'Salarie' instead of 'Salarie dune structure'? The spaces in the option seem to be the only difference between both selections. And both selections are in the same class?
Certified eZ publish developer with over 9 years of eZ publish experience. Available for challenging eZ publish projects as a technical consultant, project manager, trouble shooter or strategic advisor.
<?php
/**
* Helper class to index multiple-choice-selection attributes
* We want to
* - allow the end users to be able to search using the names of selection items
* - have a working faceting schema even if selection items contains spaces (eg: english spoken)
*
* @author
* @version $Id$
* @copyright (C) 2011
*/
class ezfSolrDocumentFieldSelection extends ezfSolrDocumentFieldBase
{
/**
* Use a specific field name to allow faceting: a string that does not tokenize
*/
public static function getFieldName( eZContentClassAttribute $classAttribute, $subAttribute = null, $context = 'search' )
{
if ( $context == 'facet' )
{
return self::ATTR_FIELD_PREFIX . $classAttribute->attribute( 'identifier' ) . '____ms';
}
return self::ATTR_FIELD_PREFIX . $classAttribute->attribute( 'identifier' ) . '_s';
}
/**
* Index data twice: once in a facetable filed, one in a searchable field
*/
public function getData()
{
//logic taken from eZSelectionType::toString
$contentClassAttribute = $this->ContentObjectAttribute->attribute( 'contentclass_attribute' );
$field = self::getFieldName( $contentClassAttribute );
$ffield = self::getFieldName( $contentClassAttribute, 'null', 'facet' );
$selected = ezSelectiontype::objectAttributeContent( $this->ContentObjectAttribute );
if ( count( $selected ) )
{
$returnData = array();
$classContent = ezSelectiontype::classAttributeContent( $this->ContentObjectAttribute->attribute( 'contentclass_attribute' ) );
$optionArray = $classContent['options'];
foreach ( $selected as $id )
{
foreach ( $optionArray as $option )
{
$optionID = $option['id'];
if ( $optionID == $id )
{
$returnData[] = $option['name'];
break;
}
}
/// @todo add warning if any unknown ids left
}
return array( $ffield => $returnData, $field => implode( $returnData, ' ' ) );
}
return array( $field => '', $ffield => array() );
}
}
?>
Principal Consultant International Business
Member of the Community Project Board
Sander van den Akker
Thursday 16 June 2011 12:50:23 am
Thanks alot Gaetano, you just saved me a lot of time!
But filter doesn't work for me. What is the syntax ?
I try
filter, array('my_class/my_attr:massage' ),
or
filter, array('my_class/my_attr/massage' ),
Thanks
Gaetano Giunta
Monday 04 July 2011 9:22:44 am
@fabien when you use custom names for your indexed fields (such as the case here, the name ends in __ms to get the proper non-split-non-stemmed string type in solr), you pass to the fetch filter the name of the field directly as it is in solr
Principal Consultant International Business
Member of the Community Project Board
You must be logged in to post messages in this topic!