:
public override float CustomScore(int doc, float subQueryScore, float valSrcScore)
{
float contentScore = subQueryScore;
double start = 1262307661d; //2010
if (_dateVsContentModifier == 0)
{
return base.CustomScore(doc, subQueryScore, valSrcScore);
}
long epoch = (long)(DateTime.Now - new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc)).TotalSeconds;
long docSinceStartHours = (long)Math.Ceiling((valSrcScore - start)/3600);
long nowSinceStartHours = (long)Math.Ceiling((epoch - start)/3600);
float ratio = (float)docSinceStartHours/(float)nowSinceStartHours; // Get a fraction where a document that was created this hour has a value of 1
float ageScore = (ratio * _dateVsContentModifier) + 1; // We add 1 because we dont want the bit where we square it bellow to make the value smaller
float ageScoreAdjustedSoNewerIsBetter = 1;
if (_newerContentModifier > 0)
{
// Here we square it, multiuply it and then get the square root. This serves to make newer content have an exponentially higher score than old content instead of it just being linear
ageScoreAdjustedSoNewerIsBetter = (float)Math.Sqrt((ageScore * ageScore) * _newerContentModifier);
}
return ageScoreAdjustedSoNewerIsBetter * contentScore;
}
기본적인 생각이다 연령 점수는 0 2010 년 1 일 수있는 부분이 있고 1 지금 당장. 이 십진수 값에 _dateVsContentModifier가 곱해지며 날짜는 관련성 점수보다 높을 수도 있습니다.
나이 스크롤은 제곱이며 _newerContentModifier가 곱 해져서 제곱근입니다. 이로 인해 최신 콘텐츠의 콘텐츠가 이전 콘텐츠보다 점수가 높아집니다.
조