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 2157 posts 14431 karma points MVP 9x 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?

  • Jcr 20 posts 130 karma points
    Jun 16, 2021 @ 16:23
    Jcr
    0

    Hi Nilesh

    The score is calculated by the number of times the search term has been found in the field(s) you're searching against.

    For example, let's say you're searching on the keyword "crow" and you're searching for the keyword in 3 different fields, i.e. Name, SEO Title, SEO Description.

    If a result has the keyword "crow" once in the Name, SEO Title and SEO Description fields will produce the same score as another result with the keyword once in Name, 3 times in SEO Title and 8 times in SEO Description; HOWEVER, will be a higher score than a result that has the keyword once in Name and 5 times in SEO Title and not mentioned once in SEO Description.

    I hope that makes sense.

    Regards

    Joshua

  • Dan Diplo 1554 posts 6205 karma points MVP 6x c-trib
    Jun 16, 2021 @ 18:13
    Dan Diplo
    0

    Scoring is quite complex - you can read about how Lucene (which sits behind Examine) calculates the score:

    http://www.lucenetutorial.com/advanced-topics/scoring.html

    Note you can boost terms to increase their "weight" if you wish.

Please Sign in or register to post replies

Write your reply to:

Draft