Copied to clipboard

Flag this post as spam?

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


  • Jules 276 posts 588 karma points
    Feb 28, 2013 @ 22:20
    Jules
    1

    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)
    query.And().Field("Item2",MyOtherVar)
    query.And().Field("Item3",etcVar)
    query.And().Field("Item3",etcEtcVar)

    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?

    J

     

     

  • Jules 276 posts 588 karma points
    Mar 02, 2013 @ 18:49
    Jules
    0

    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
    0

    Did u ever work this out???

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies