Forums / Extensions / eZ Find / Facets and ezselection

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

eZ debug

Timing: Jan 17 2025 23:42:32
Script start
Timing: Jan 17 2025 23:42:32
Module start 'content'
Timing: Jan 17 2025 23:42:32
Module end 'content'
Timing: Jan 17 2025 23:42:32
Script end

Main resources:

Total runtime0.1512 sec
Peak memory usage4,096.0000 KB
Database Queries141

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0054 587.7344180.7891
Module start 'content' 0.00540.0044 768.5234111.5703
Module end 'content' 0.00980.1413 880.0938540.2969
Script end 0.1511  1,420.3906 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00362.4020200.0002
Check MTime0.00151.0091200.0001
Mysql Total
Database connection0.00060.381110.0006
Mysqli_queries0.109672.51971410.0008
Looping result0.00130.83141390.0000
Template Total0.141093.310.1410
Template load0.00100.680010.0010
Template processing0.139992.568210.1399
Override
Cache load0.00070.492910.0007
Sytem overhead
Fetch class attribute can translate value0.00070.479010.0007
XML
Image XML parsing0.00030.166110.0003
General
dbfile0.00261.7299200.0001
String conversion0.00000.002730.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/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