make app backward compatible with trending_score

-update trending decay function to zero out low trending score values faster
This commit is contained in:
Jack Robison 2021-08-30 13:36:24 -04:00 committed by Victor Shyba
parent a51bf6a4fa
commit 3800fb1ab0
2 changed files with 2 additions and 1 deletions

View file

@ -73,6 +73,7 @@ RANGE_FIELDS = {
ALL_FIELDS = RANGE_FIELDS | TEXT_FIELDS | FIELDS
REPLACEMENTS = {
'trending_mixed': 'trending_score'
# 'name': 'normalized_name',
'txid': 'tx_id',
'nout': 'tx_nout',

View file

@ -183,7 +183,7 @@ class SearchIndex:
decay_factor = 2 * (2.0 ** (-1 / self._trending_half_life))
decay_script = """
if (ctx._source.trending_score == null) { ctx._source.trending_score = 0.0; }
if ((-0.000001 <= ctx._source.trending_score) && (ctx._source.trending_score <= 0.000001)) {
if ((-0.1 <= ctx._source.trending_score) && (ctx._source.trending_score <= 0.1)) {
ctx._source.trending_score = 0.0;
} else if (ctx._source.effective_amount >= %s) {
ctx._source.trending_score *= %s;