Reputation: 4641
I want to make a bust for latest data while indexing my content. For example Content from now to 6 months past should have boost = 10 and Content from 6 month past to 12 month past should have boost = 5 Older content should have boost = 0
my date is saved as timestamp so the only problem is to get current date while indexing
I can get date of content from row that is a param in my function but I don't know how to get current date and compare it. should it be something like this ?
and one more question
is there some way to check the boost ? I mean can i monitor what is boosted how ? Cause using result list with couple thousands articles is hard to mesure
// EDIT ANSWER
GOT IT
The script should look like this (this is for one 1 year past and older
<script>
<![CDATA[
function s1(row) {
var curTime = parseInt(new Date().getTime()/1000);
var itemDate = row.get('publication_date');
if(itemDate >= (curTime - 31104000)) {
row.put('$docBoost', 40);
} else {
row.put('$docBoost', 20);
}
return row;
}
]]>
</script>
Upvotes: 1
Views: 113
Reputation: 106
I would recommend using query/search time boosting instead for your use case. The main advantage is that you don't need to reindex your documents periodically to adjust boosts. See Date Boosting and "How can I boost the score of newer documents" wiki tips
Upvotes: 3