Assign score based on the age of record

Hi,

How to assign score based on the age of a record?

We are writing a feed for our app and Algolia is providing the backend infrastructure for it. We use Firebase and have written cloud functions to move the data from Firebase to Algolia.

We are using facets in Algolia which are then used in the search query to assign score. For example, we have facets type1 and type2. We also have a unixTimeStamp on each record.

So when we query, we want to assign score when there is a match for type1 or type2 e.g. type1:‘abc’<score=8> or type2:‘cdf’<score=9>. In-addition to this, we also want to assign a score based on the age of a record. For example - If something is 1 day old, a score of 9, 2 weeks old a score of 7, 6 months old a score of 1.

What is the best way to achieve this?

Also, are facets the best way to filter for string fields and assign scores?