From 101e55d9245f126096e127eb8ac568268f8ebb89 Mon Sep 17 00:00:00 2001 From: Mark Beamer Jr Date: Wed, 9 Jan 2019 21:40:10 -0500 Subject: [PATCH 1/2] added channel effective amount to the claim weight. --- server/controllers/lighthouse.js | 14 ++++++++++++-- server/utils/chainquery/index.js | 1 + 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/server/controllers/lighthouse.js b/server/controllers/lighthouse.js index 27466f1..90eed5a 100644 --- a/server/controllers/lighthouse.js +++ b/server/controllers/lighthouse.js @@ -63,7 +63,7 @@ function getResults (input) { }, }, }; - const funcScore = { // 100 LBC adds 1 point to the score + const funcScoreClaimWeight = { // 100 LBC adds 1 point to the score 'function_score': { 'script_score': { 'script': { @@ -72,6 +72,15 @@ function getResults (input) { }, }, }; + const funcScoreChannelWeight = { // 100 LBC adds 1 point to the score + 'function_score': { + 'script_score': { + 'script': { + 'source': `${effectiveFactor} * doc['certificate_amount'].value`, + }, + }, + }, + }; const matPhraseName = { // Match search text as phrase - Name 'match_phrase': { 'name': { @@ -176,7 +185,8 @@ function getResults (input) { 'bool': { 'should': [ conBoost, - funcScore, + funcScoreClaimWeight, + funcScoreChannelWeight, ], 'must': [ channelSearch, diff --git a/server/utils/chainquery/index.js b/server/utils/chainquery/index.js index d198329..4dfb7b2 100644 --- a/server/utils/chainquery/index.js +++ b/server/utils/chainquery/index.js @@ -172,6 +172,7 @@ function getClaimsSince (time, lastID, MaxClaimsInCall) { `p.name as channel,` + `c.bid_state,` + `c.effective_amount,` + + `COALESCE(p.effective_amount,0.0) as certificate_amount,` + `c.claim_id as claimId,` + `c.value_as_json as value ` + `FROM claim c ` + -- 2.45.2 From 31f47fea76cc14f7c91fd303869e1e811d98e507 Mon Sep 17 00:00:00 2001 From: Mark Beamer Jr Date: Sun, 24 Feb 2019 21:41:22 -0500 Subject: [PATCH 2/2] Converted script scores to field_value_factor scores. This allows for a missing parameter to avoid the errors. --- server/controllers/lighthouse.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/server/controllers/lighthouse.js b/server/controllers/lighthouse.js index 90eed5a..8ea704e 100644 --- a/server/controllers/lighthouse.js +++ b/server/controllers/lighthouse.js @@ -65,19 +65,19 @@ function getResults (input) { }; const funcScoreClaimWeight = { // 100 LBC adds 1 point to the score 'function_score': { - 'script_score': { - 'script': { - 'source': `${effectiveFactor} * doc['effective_amount'].value`, - }, + 'field_value_factor': { + 'field' : 'effective_amount', + 'factor' : effectiveFactor, + 'missing': 1, }, }, }; const funcScoreChannelWeight = { // 100 LBC adds 1 point to the score 'function_score': { - 'script_score': { - 'script': { - 'source': `${effectiveFactor} * doc['certificate_amount'].value`, - }, + 'field_value_factor': { + 'field' : 'certificate_amount', + 'factor' : effectiveFactor, + 'missing': 1, }, }, }; -- 2.45.2