Using MySQL, I am trying to replicate ElasticSearch attenuation estimation functions. I am looking to compensate for the relevance of transactions depending on their age. The older the transaction, the less appropriate they are. However, due to the fact that people do not visit the site on a daily basis, I want to enable the offset so that everything that has been added over the past 5 days is considered new . For simplicity, call 5 as n .
Based on this page ( https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-function-score-query.html#score-functions ), we can see that the score is calculated as
S(doc) = exp(max(0,|value-origin|-offset)**2)/(2*SD**2)
Where
SD**2 = -scale**2/(2*log*decay)
My question is: give the createDate date field , how can I create a function in MySQL to use this function and order my results based on it?

source
share