Developer forum

Forum » Ecommerce - Standard features » Wrong sorting of custom fields

Wrong sorting of custom fields

Peter Gustafsson
Reply
When we try to get a product listing sorted on a custom field like this:

Heretehe
SearchQuery q = new SearchQuery(new CriteriaGroup(new Criteria("groupshierarchy", "1.01.1-at-SHOP1")), new LimitCriteria(1125, 50), new OrderByCriteria("productfield_field17", SortDirection.Ascending));
SearchResult<ProductIndexEntry> result = IndexManager.Current.QueryIndex<ProductIndexEntry>("Products", q);





 the results are sorted in a wrong way: they do seem to take the right field into the account (so we know that productfield_field17 is the right one), but it seems to first sort on the second word. The values that only consist of one word are sorted correctly. But the values that have more words are sorted on the second word somehow. Here is the example list:

1027310-Tyg Peru 10 bianco 0533
1027361-Tyg Peru 61 chardonnay 1758
1006117-Tyg Ella Plain 17 grey
1006116-Tyg Ella Plain 16 beige
1006104-Tyg Ella Plain 4 black
1008010-Tyg Eternity Plain 10 Off white 810 (enfärgad)
1008006-Tyg Eternity Plain 6 Brown 607 (enfärgad)
1008005-Tyg Eternity Plain 5 Gold 866 (enfärgad)
1008003-Tyg Eternity Plain 3 Green 867 (enfärgad)
1008002-Tyg Eternity Plain 2 Blue 869 (enfärgad)
1008001-Tyg Eternity Plain 1 Rouge 520 (enfärgad)
1008000-Eternity Plain provkollektion C
1026917-Tyg Pollin 17 grey A09
1026916-Tyg Pollin 16 sand A03


The actual names we are sorting on are the "eternity  plain", "pollin", "ella plain", "peru", etc. 
You can see that Ella plain comes after Peru, and after that comes Pollin. This is exact wrong behavior that we have described. 
Naturally, this wrong order appears in the product list as well, since it is using the similar way of selecting products.

Replies

 
Pavel Volgarev
Reply
This post has been marked as an answer
Hi Peter,

You're trying to order results by a value of a tokenized field. This is not possible and actually should give you an error... Anyway, I've create a new item in our backlog for this (#8830 "Make it possible to sort by any product field when querying search index."). This functionality will be available in Dynamicweb 8.2.

-- Pavel

 
Votes for this answer: 0
 
Peter Gustafsson
Reply
I see, thanks, looking forward this feature.
Also please don't make the way it works now break (and give error as it should?) in a next hotfix/any upcoming versions before 8.2, because we rely on this feature. For now we have made an extra field and removed all spaces from it, and the sorting seems to work fine. 
 
Pavel Volgarev
Reply
Hi Peter,

#8830 has now been resolved. You will need to prepend the name of the field with "sort_" in order to use untokenized version.

-- Pavel

 

You must be logged in to post in the forum