Quantcast
Channel: Customized Commerce 13 and earlier versions
Viewing all articles
Browse latest Browse all 9642

Lucene Sorting

$
0
0

Hi,

I've added a field to products for sorting in lucene based product search:

[Display(
            GroupName = SystemTabNames.Settings,
            Order = 100,
            Name = "Product Sort Order",
            Description = "The sort order value")]
[Editable(true)]
[DefaultValue(0)]
[IncludeValuesInSearchResults]
[Searchable]
public virtual int ProductSortOrder { get; set; }

The code for building the search criteria includes setting the sort order like:

SearchSortField[] sNew =
                            {
                                new SearchSortField(Constants.LuceneConstants.LUCENE_INTERNAL_NEW_FIELD, true),
                                new SearchSortField(Constants.LuceneConstants.LUCENE_INTERNAL_PRODUCT_SORTORDER_FIELD, false)
                            };
                    _catalogCriteria.Sort = new SearchSort(sNew);

However, it seems to be sorting based on the string representation of the value so coming out as 1, 10, 4, and 5 rather than 1, 4, 5, 10.

Any ideas on how to fix this would be appreciated.


Viewing all articles
Browse latest Browse all 9642

Trending Articles