Custom Ranking of Search Results
Custom Ranking of Search Results
By editing the file
.wgrankhits.cfg
in the archive directory (usually something like /usr/local/wg2/archives/1 ) you have complete control over how search results are ranked. By judicious weighting of variables, you can make all the results from a specified directory appear first, favor title hits over body text, ensure that the most recent results are always on top, or any other ranking formula that makes sense on your site.
This is pretty powerful stuff, and you can often do it with just one line of perl code.
The default ranking formula is
$TITLE * 10 + $N + $LinkPop + 5/($Days + 1)
This means, the score of a search result is equal to the number of title hits times 10, plus the total number of body hits, plus a link popularity score, plus a 'freshness' quotient. You can change this formula or use any of the following variables instead:
# Available variables are:
#
# $N # of times the word appears in the record
# $LineNo Where in the file the word appears
# $TITLE # of times the word appears in the TITLE tag
# $FILE # of times the word appears in the file path
# $Days Date (how many days old the file is)
# $META Total # of times the word appears in any META tag
# $LinkPop Link popularity in the site
# %MetaHash Hash with the # of times the word appears in each META tag,
# indexed by the NAME= parameter of the meta tag.
# $LinkString actual url of link
# $QueryRegExp a simplified version of the original query
Experiment with it live, you do not need to reindex each time you change it - the changes should take effect on your next search.
If you decide you would like help tweaking your site, hourly support is available at a reduced rate for licensees and nonprofits, just use the contact link on the left.
Enjoy!
|