Copied to clipboard

Flag this post as spam?

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


  • richard rowles 18 posts 118 karma points notactivated
    Nov 29, 2018 @ 12:17
    richard rowles
    0

    Examine working not sorting

    Hi,

    Version 7.10.3

    I'm Trying out Examine the performance is amazing, but when I apply an OrderBy the results are not sorted.

    I've added to examineIndex config...

     <add Name="albumCode"  EnableSorting="true" Type="String"/>
    

    The code for doing the search is

    var xq = _serachCriteria.Field(fieldName,fieldValue).And().OrderByDescending(new SortableField(orderByField,SortType.String)).Compile();
    _searchResults = _searchEngine.Search(xq);
    

    It returns all the results it should based on fieldName and Value but if I add SortBy or SortByDecending I get the following example results for the product code which is the same as not adding SortBy...

    WGS416CD, WGS422CD, WGS353CD

    This is the order of the product pages as they are listed under the "products" page in Umbraco.

    I'm sure I'm doing something stupid but can't see what, any help totally appreciated.

    Cheers Rich

  • Marc Goodson 2133 posts 14273 karma points MVP 8x c-trib
    Nov 29, 2018 @ 20:51
    Marc Goodson
    100

    Hi Rich

    Have you rebuilt your index after adding the EnableSort setting??

     <add Name="albumCode"  EnableSorting="true" Type="String"/>
    

    it's kind of counter intuitive as you are just changing the sort order of what's there, but you need to rebuild them from the examine developer dashboard to have this kind of change picked up.

    If you have rebuilt, or rebuilding doesn't fix it then I'm wondering if

    var xq = _serachCriteria.Field(fieldName,fieldValue).And().OrderByDescending("albumCode").Compile();
    

    works, eg having set the EnableSorting to be true, (and rebuilt indexes) then I think you should just be able to pass the name of the field via string... although your SortableField implementation looks fine (as long as orderByField = "albumCode" !!!)

    regards

    Marc

  • richard rowles 18 posts 118 karma points notactivated
    Dec 01, 2018 @ 07:37
    richard rowles
    0

    All working now Marc, I rebooted the server. But I had rebuilt the index before as enable sorting was "true" under user fields.

    Anyway thanks.

Please Sign in or register to post replies

Write your reply to:

Draft