From 3800fb1ab0302545f3e5b69d27a724a3b782af23 Mon Sep 17 00:00:00 2001 From: Jack Robison Date: Mon, 30 Aug 2021 13:36:24 -0400 Subject: [PATCH] make app backward compatible with `trending_score` -update trending decay function to zero out low trending score values faster --- lbry/wallet/server/db/elasticsearch/constants.py | 1 + lbry/wallet/server/db/elasticsearch/search.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/lbry/wallet/server/db/elasticsearch/constants.py b/lbry/wallet/server/db/elasticsearch/constants.py index 8461c6ab7..1d93ba025 100644 --- a/lbry/wallet/server/db/elasticsearch/constants.py +++ b/lbry/wallet/server/db/elasticsearch/constants.py @@ -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', diff --git a/lbry/wallet/server/db/elasticsearch/search.py b/lbry/wallet/server/db/elasticsearch/search.py index ec8677d44..de1f6b59b 100644 --- a/lbry/wallet/server/db/elasticsearch/search.py +++ b/lbry/wallet/server/db/elasticsearch/search.py @@ -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;