Copied to clipboard

Flag this post as spam?

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

  • Jules 216 posts 463 karma points
    Feb 28, 2013 @ 22:20

    Definitive way to Sort Examine Search Results

    There seems to be a couple of different ways that people have implemented sorting in Examine.

    It seems you can either set the sort on your Search Criteria like this:

    Method 1

    var searcher = ExamineManager.Instance.SearchProviderCollection["MySearcher"]
    var searchCriteria - searcher.CreateSearchCriteria();
    searchCriteria.OrderBy(new[] {"__Sort_nodeName"});

    Or you can get the results first and then sort on those with:

    Method 2

    IEnumerable searchResults = searcher.Search(query).OrderBy(r => r.Fields["__Sort_nodeName"]);

    In a current project I have tested both methods.  However with Method 1 above, the results seem to be inconsistent - some of the items end up out of order.

    Don't know if it has anything to do with the way I build the query - I am building it up from a number of different parts using the Fluent API

    query = searchCriteria.Field("Item1",MyVar)

    The query could in fact end up with many different parts (up to about 40).

    Does anybody know what might be going wrong with Method 1 (not sure if I have provided enough code - didn't want to just dump it)

    Also which method of sorting is favoured?




  • Jules 216 posts 463 karma points
    Mar 02, 2013 @ 18:49

    Is this question too difficult or worded badly?  No response after 2 days...??? Nobody???

    I'm off to StackOF...



  • Karl Kopp 121 posts 227 karma points
    May 07, 2014 @ 05:51
    Karl Kopp

    Did u ever work this out???

Please Sign in or register to post replies

Write your reply to: