Copied to clipboard

Flag this post as spam?

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

  • David W. 159 posts 284 karma points c-trib
    Sep 07, 2012 @ 10:26
    David W.

    Weighting createDate in XSLTSearch

    I'm looking for a way to weigh in createDate in the search result. Ie, the later date, the higher score. Right now I have a customer complaining that "MySpecialEvent 2007" lands before "MySpecialEvent 2012" when searching for "MySpecialEvent".

    Not sure how to do this given that the date really has noting to do with the search term. I'm thinking perhaps to modify pageScoreList after it has populated by adding a value of say createdDate - DateTime.Now.

    Ideas? Comments?


  • Douglas Robar 3570 posts 4711 karma points MVP ∞ admin c-trib
    Sep 07, 2012 @ 11:18
    Douglas Robar

    Hi, David,

    What an interesting idea! The place to put in some extra logic is in the scoring algorithm itself rather than trying to re-arrange the order of the page scores themselves (though that's an option it wouldn't be my first choice).

    This is a good post to read to understand how XSLTsearch scores/weights/ranks results to give you the needed background:

    I think I'd add some logic to the 'weighting' variable in the scoreAttributes and scoreDataNodes templates to reduce the weighting a bit corresponding to the age of the document.

    <!-- the weighting to apply to hits in this search field -->

    <xsl:variable name="weighting" select="PS.XSLTsearch:power(2, number(PS.XSLTsearch:hitCount(substring-after($searchFields,string(name($item))), ','))-1)"/>

    Perhaps subtract 0.1 for each year of age of a document? (Up to a maximum of perhaps 0.5; that is, anything more than 5 years old is all lumped into 'old' and not reduced in rank further). The exact amount and calculation will take some trial and error on your part to get the effect you want in the results.


    Do post your solution for the benefit of the next fellow!


Please Sign in or register to post replies

Write your reply to: