Copied to clipboard

Flag this post as spam?

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


  • Nilesh Macwan 9 posts 79 karma points
    Mar 10, 2017 @ 10:34
    Nilesh Macwan
    0

    Examine search result default sort order

    Hello,

    What is the default sort order when we use Examine mechanism?

    How the data will be sorted, based on ID or any text.

    can anyone guide me what will be the default order and can we customize the default result order?

  • Marc Goodson 1451 posts 9716 karma points MVP 5x c-trib
    Mar 11, 2017 @ 12:19
    Marc Goodson
    0

    Hi Nilesh

    When examine matches a document from your search term, it also calculates a 'score' indicating how well the document matches the term, and it is by this score that Examine orders the results, eg the most relevant match first.

    enter image description here

    When you are building your custom examine query you can add the OrderBy or OrderByDescending option at the end to specify the field to order by.

    eg:

    var searcher = ExamineManager.Instance.SearchProviderCollection["ExternalSearcher"];
    var criteria = searcher.CreateSearchCriteria(BooleanOperation.Or);
    var searchTerm = "fish"; //or read from form post / querystring etc
    //build other criteria for your search
    var query = criteria.Field("bodyText",searchTerm).Or().Field("title",searchTerm);
    // ordering
    query.And().OrderByDescending(new string[] {"title"});
    //compile and get results
     var results = searcher.Search(query.Compile());
    
  • Nilesh Macwan 9 posts 79 karma points
    Mar 20, 2017 @ 04:27
    Nilesh Macwan
    0

    Thanks for the reply.

    But how score is calculated?

  • 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