Facets and ezselection

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 :

  • Bovin
  • Ovin
  • Caprin
  • Porc

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

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 29 2025 23:50:12
Script start
Timing: Jan 29 2025 23:50:12
Module start 'layout'
Timing: Jan 29 2025 23:50:12
Module start 'content'
Timing: Jan 29 2025 23:50:12
Module end 'content'
Timing: Jan 29 2025 23:50:12
Script end

Main resources:

Total runtime0.0137 sec
Peak memory usage2,048.0000 KB
Database Queries3

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0042 588.1563151.2109
Module start 'layout' 0.00420.0030 739.367236.6484
Module start 'content' 0.00730.0052 776.0156107.8438
Module end 'content' 0.01240.0012 883.859449.9922
Script end 0.0137  933.8516 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.002115.2660140.0001
Check MTime0.00096.8169140.0001
Mysql Total
Database connection0.00053.285210.0005
Mysqli_queries0.002921.280730.0010
Looping result0.00000.086810.0000
Template Total0.00107.010.0010
Template load0.00074.938210.0007
Template processing0.00032.024610.0003
Override
Cache load0.00053.349410.0005
General
dbfile0.00021.710380.0000
String conversion0.00000.052140.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs