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?