Author
|
Message
|
Matthieu Sévère
|
Monday 08 March 2010 8:59:54 am
Hello, I have a search on a unique content type (user) and facets on attributes of a related object of the content type (the related object is a profile so the facets are each attributes of the profile). I have a problem with a facet that is always empty (it's a ezselection), whereas I have other facet of type ezselection that works on the same search ! The ezselection is unique and I checked the metaData() method of the datatype and it returns the value so it's okay. I don't know what else to check to debug this problem ? Any clue ? Thank you ! PS : facets on related object is awesome ! (except for ezselection :) )
--
eZ certified developer: http://ez.no/certification/verify/346216
|
Sebastiaan van der Vliet
|
Wednesday 10 March 2010 6:43:20 am
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 :
- Salarie dune structure
- Liberal
On the other one :
It is all using the native ezselection datatype
--
eZ certified developer: http://ez.no/certification/verify/346216
|
Sebastiaan van der Vliet
|
Wednesday 10 March 2010 7:16:53 am
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.
|
Matthieu Sévère
|
Wednesday 10 March 2010 8:38:33 am
yes and it makes not differences ...
--
eZ certified developer: http://ez.no/certification/verify/346216
|
Sander van den Akker
|
Tuesday 14 June 2011 11:20:42 am
How did you manage to fix this? I have a similar problem where characters are missing.
eZ Publish certified developer
http://auth.ez.no/certification/verify/392313
|
Matthieu Sévère
|
Tuesday 14 June 2011 11:47:58 am
"
How did you manage to fix this? I have a similar problem where characters are missing.
"
You should configure ez find so that ezselection is indexed as string for facet, it should do it
--
eZ certified developer: http://ez.no/certification/verify/346216
|
Gaetano Giunta
|
Wednesday 15 June 2011 7:10:22 am
You want the code? There you are:
<?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!
eZ Publish certified developer
http://auth.ez.no/certification/verify/392313
|
Fabien GALLARD
|
Monday 04 July 2011 1:47:49 am
Hello guys, I've try the Gaetano's class.Facets works fine. 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
|