Developer forum

Forum » PIM » Sorting on text in queries doesn't seem to work

Sorting on text in queries doesn't seem to work

Helene Kjærbøl
Reply

Hi PIm Forum,

We are trying to sort our products alphabetically on the productname in a query. But this doesn't seem to work:


Replies

 
Nuno Aguiar Dynamicweb Employee
Nuno Aguiar
Reply

Hi Helene,

 

The "Product name" field is analyzed by default, meaning it will not work as you expected. To get it to work, you need to create a new field in the index where the source is the "ProductName" but not make it analyzed. We usually create a field called "Product name sortable" so it stands out. Then just sort by it.

https://www.screencast.com/t/YHgBmk1UNujm

 

Best Regards,

Nuno Aguiar

 
Helene Kjærbøl
Reply

Hi Nuno,

Thank you for the quick reply. Looks like this setup as part of the default schema extender, but I still see no effect - is it because this filed is not stored? Can I change this on the already defined field "Product Name (sort)"?

 

 
Nuno Aguiar Dynamicweb Employee
Nuno Aguiar
Reply

Hi Helene,

 

I can see you are using Rapido, and that said the field should be "Stored", although I am not sure it will matter in the backend. Have you tried making it "Stored" and rebuilding the index to test?

I am also assuming the product list you are showing is not being sorted by a different column in the backend.

 

Best Regards,

Nuno Aguiar

 
Steffen Kruse Hansen Dynamicweb Employee
Steffen Kruse Hansen
Reply

Hi Helene,

Your last screenshot of the list looks almost correctly sorted. I would expect that you would have the following order

 - {Products without name}

 - {Products starting with a number}

 - {Products starting with [a-z]}

And that is almost what you got... So I'm thinking if product names of the products '383593' and '283886' could start with a space in the database? Because then it would make sense why they are sorted in that order.

Does the rest of the pages look like they are sorted alphabetically?

Best regards,

Steffen

 
Helene Kjærbøl
Reply

Hi Steffen and Nuno,

I think Steffen is right, it is only products '383593' and '283886' that confuses the list - but how do I fix this. I see no space and I have tried retyping the name manually - without result...?

Thank you for the quick answers.

BR Helene

 
Steffen Kruse Hansen Dynamicweb Employee
Steffen Kruse Hansen
Reply

Hi Helene,

Can you try to ZIP the content of 'Files/System/Indexes' and sent it to Support?. Then I can try to see what's actually in the index, and maybe that can give us some pointers to what is going wrong.

Best regards,

Steffen

 

You must be logged in to post in the forum