Forums / Extensions / eZ Find / Problems using sort_by

Problems using sort_by

Author Message

Tuomo Syvänperä

Friday 26 June 2009 5:05:50 am

There seems to be something strange going on with the sort_by parameter of the search fetch function. I'm trying to sort users by last name and last names that have a '-' in them sometimes get sorted wrong.. For example John Test-Doe would sometimes get sorted according to the 'Test' - part of the last name (the correct way) and sometimes it gets sorted according to the 'Doe' - part... There seems to be no consistent way of reproducing this problem. It just sometimes happens. And when it does, even though I try to change the last name to for example JohnDoe (without '-'), it will still get sorted wrong.. But if I change it to something completely different without '-', it magically gets sorted correctly..

Tuomo Syvänperä

Monday 29 June 2009 2:28:28 am

Okay, more problems... It seems that ä and ö (scandinavian characters) also get sorted wrong. If the word starts with ä, it will get sorted as a. Don't know if it has something to do with transliteration and transformations. I have mapped ä to a and not ae as it is by default. But the search index should not index it as transformed, it should use the untransformed version of the name..

Tuomo Syvänperä

Wednesday 01 July 2009 5:03:11 am

Here's a quick way to reproduce the problem I have with sorting.. If anyone can confirm this, I'll file it in the issue tracker.
In default ezwebin - installation, create a few Product - class objects under for example Products/Software - node.
Use for example the following names for the products (or something similar)
aaaaaa
aa-bb
aa-cc
ba-ab
bbbbb
ccccccccc
ffffffffffffffff
ff gg
gaga
gg ff
gggggg
OS Type I
Test-Product

The OS Type I is one of the default objects..
Now if you use the following ezfind fetch:

{def $srch=fetch('ezfind', 'search', hash(
            'query', '',
            'limit', 20,
            'subtree_array', array(70),
            'class_id', 'product',
            'sort_by', hash('product/name', 'asc')
            ))}

{foreach $srch.SearchResult as $s}
    {$s.name}<br />
{/foreach}

70 is the node id for products/software in default ezwebin install.
What you end up with is a list of products which are certainly not ordered correctly.. What I get is this:
aaaaaa
ba-ab
aa-bb
bbbbb
aa-cc
ccccccccc
ffffffffffffffff
gaga
ff gg
gg ff
gggggg
Test-Product
OS Type I

What you will get may vary.. It seems there's absolutely no logic to the sorting. Sometimes names with dashes and or whitespaces get ordered correctly and sometimes the get ordered according to the string after the dash or whitespace..

Can anyone confirm this as a bug?

eZ debug

Timing: Jan 18 2025 03:07:05
Script start
Timing: Jan 18 2025 03:07:05
Module start 'content'
Timing: Jan 18 2025 03:07:05
Module end 'content'
Timing: Jan 18 2025 03:07:05
Script end

Main resources:

Total runtime0.5093 sec
Peak memory usage4,096.0000 KB
Database Queries194

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0082 587.7344180.7891
Module start 'content' 0.00820.3735 768.5234491.7266
Module end 'content' 0.38170.1275 1,260.2500337.0625
Script end 0.5092  1,597.3125 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00390.7603210.0002
Check MTime0.00140.2796210.0001
Mysql Total
Database connection0.00150.295510.0015
Mysqli_queries0.433885.17121940.0022
Looping result0.00190.38061920.0000
Template Total0.481394.520.2406
Template load0.00200.386620.0010
Template processing0.479394.115820.2397
Template load and register function0.00010.022410.0001
states
state_id_array0.00070.140610.0007
state_identifier_array0.00080.166720.0004
Override
Cache load0.00180.3450460.0000
Sytem overhead
Fetch class attribute can translate value0.00160.317920.0008
Fetch class attribute name0.00110.209740.0003
XML
Image XML parsing0.00080.161220.0004
class_abstraction
Instantiating content class attribute0.00000.003660.0000
General
dbfile0.00310.6082260.0001
String conversion0.00000.001630.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
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
3content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
3content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
5content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
3content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 17
 Number of unique templates used: 7

Time used to render debug report: 0.0002 secs