Copied to clipboard

Flag this post as spam?

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


  • Erik 9 posts 29 karma points
    Nov 12, 2013 @ 04:33
    Erik
    0

    adjusting the sort order?

    Nice job. This one runs very well on old templates in umbraco 6 not just the MVC templates

     

    I have one question: How do you adjust the sort order of the items presented in the search results? I want to sort after a custom set parameter

  • Erik 9 posts 29 karma points
    Nov 12, 2013 @ 06:01
    Erik
    0

    I did find out how to set the sorting of search results:

    the order you define your searchfiels is the sorting you'll get

     searchFields="nodeName, sortOrderMain, metaTitle, metaDescription, metaKeywords, bodyText, description, productName, buzzWord"

     

    unless you modify the \Views\MacroPartials\ezSearch.cshtml source for example code line:

    var searchResults = model.PagedResults.OrderByDescending(r => r.Fields["sortOrderMain"]); 

     

     

    But the serachresults are inconsistently I have a searchresult in childpages in 4 different mothernodes but they do not sort accordingly to all 4 of the results. They sort in pair 2 and 2 but all 4 items are not sorted correct :(

     

    here is somebodyelse with the same problem sorting out of order:

    http://our.umbraco.org/forum/developers/api-questions/38846-Definitive-way-to-Sort-Examine-Search-Results

     

    anybody got a clue?

  • Erik 9 posts 29 karma points
    Nov 12, 2013 @ 06:44
    Erik
    0

    What I want to do with sorting is very much the same as ranking content. This code in the file  ezSearch.cshtml does some ranking so it says

           // Rank content based on positon of search terms in fields

            for (var i = 0; i < model.SearchFields.Count; i++)

            {

                foreach (var term in model.SearchTerms)

                {

                    query.AppendFormat("{0}:{1}*^{2} ", model.SearchFields[i], term, model.SearchFields.Count - i);

                }

            }

     

     

    but I dont grasp the way this code is doing the ranking. Can anyone explain how the ranking is done there?

Please Sign in or register to post replies

Write your reply to:

Draft