Time Decay
For a search index where you want to give more weight to newer content, you may want to use the time decay feature. This feature allows you to adjust the relevance score of search results based on their age.
How It Works
Given a date field, Searchcraft will calculate the number of days since the document was created or last updated. Using that it will apply an exponential decay function to the relevance score based on the number of days since publish. As time passes, the score for the document will decrease, giving more weight to newer content.
Example
A document from today: decay ≈ 1.0 (full score)
A document 30 days old: decay ≈ 0.74 (74% of original score)
A document 365 days old: decay ≈ 0.026 (2.6% of original score)
This helps prioritize newer content in search results while still allowing older content to appear, just with reduced prominence.
When To Use
For applications where newer content should have more precendence given equal relevance matching such as news websites, social media, etc.
When Not To Use
Applications where the relevance score should not be affected by the age of the content such as a knowledge base or a product catalog.
How To Configure
See schema configuration reference for details on how to configure the time decay feature.