From 6380e8e6d6430f445693236efa1e07560695525f Mon Sep 17 00:00:00 2001 From: Mark Beamer Jr Date: Mon, 5 Nov 2018 20:42:44 -0500 Subject: [PATCH] Don't make 'Accepted' bid state claims searchable ( mempool ). Made esQuery a variable for easy debugging when needed. --- server/controllers/lighthouse.js | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/server/controllers/lighthouse.js b/server/controllers/lighthouse.js index 79423ed..65d452a 100644 --- a/server/controllers/lighthouse.js +++ b/server/controllers/lighthouse.js @@ -168,7 +168,7 @@ function getResults (input) { }, }; // End of search parts - return eclient.search({ + let esQuery = { index : 'claims', _source: ['name', 'value', 'claimId'], body : { @@ -200,7 +200,9 @@ function getResults (input) { _score: 'desc', }, }, - }); + }; + // console.log('QUERY: ', esQuery); + return eclient.search(esQuery); } function getIndex () { @@ -256,24 +258,27 @@ function getFilters (input) { // this is the best place for putting things like filtering on the type of content // Perhaps we can add search param that will filter on how people have categorized / tagged their content var filters = []; + var bidStateFilter = {'bool': {'must_not': {'match': { 'bid_state': 'Accepted' }}}}; if (input.nsfw === 'true' || input.nsfw === 'false') { const nsfwFilter = {'match': {'value.stream.metadata.nsfw': input.nsfw}}; filters.push(nsfwFilter); } if (filters.length > 0) { - const filterQuery = { - 'nested': { - 'path' : 'value', - 'query': { - 'bool': { - 'must': filters, + const filterQuery = [ + { + 'nested': { + 'path' : 'value', + 'query': { + 'bool': { + 'must': filters, + }, }, }, }, - }; + bidStateFilter]; return filterQuery; } else { - return []; + return [bidStateFilter]; } } -- 2.45.2