Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • David Challener 80 posts 444 karma points c-trib
    Jan 27, 2019 @ 21:26
    David Challener
    0

    Sortable Examine results

    Hi,

    This is more for me to find again in the future than a question as I've got stuck on this issue twice now!

    When searching using Examine and sorting results by a field that is not a string (in my case an integer) you need to tell the query the field is an integer, and don't rely on the ExamineIndex.config definition being enough. Without this it will sort by the field but the string representation of the numbers. The new SortableField is what is required here.

    var query = searchCriteria
                    .Field("nodeTypeAlias", "workdetail")
                    .Not().Field("umbracoNaviHide", 1.ToString())
                    .And().OrderBy(new SortableField("sortOrder", SortType.Int));
    
Please Sign in or register to post replies

Write your reply to:

Draft