Skip to content
Permalink
Browse files

Adding channel_id search back in. Reworked to avoid null queries bein…

…g passed in.

Signed-off-by: Mark Beamer Jr <markbeamerjr@gmail.com>
  • Loading branch information...
tiger5226 committed Sep 23, 2019
1 parent e9598d6 commit 715ecc3d92c0a4750542c53f7c0b5b49eececcf4
Showing with 30 additions and 26 deletions.
  1. +30 −26 server/controllers/lighthouse.js
@@ -40,33 +40,38 @@ function getResults (input) {
let escapedQuery = getEscapedQuery(trimmedQuery);
let washedQuery = getEscapedQuery(getWashedQuery(trimmedQuery));
let effectiveFactor = '0.00000000001';
// Search is split up into different parts, all search parts goes under this line.
let channelidSearch;
if (input.channel_id !== undefined) {
channelidSearch = { // If we got a channel_id argument, lets filter out only that channel_id
'bool': {
'must': {
'query_string': {
'fields': ['channel_id'],
'query' : getEscapedQuery(input.channel_id.trim()),
const dynamicFilters = () => {
let queries = [];
// Search is split up into different parts, all search parts goes under this line.
if (input.channel_id !== undefined) {
const channelidSearch = { // If we got a channel_id argument, lets filter out only that channel_id
'bool': {
'must': {
'query_string': {
'fields': ['channel_id'],
'query' : getEscapedQuery(input.channel_id.trim()),
},
},
},
},
};
}
let channelSearch;
if (input.channel !== undefined) { // If we got a channel argument, lets filter out only that channel
channelSearch = {
'bool': {
'must': {
'query_string': {
'fields': ['channel'],
'query' : getEscapedQuery(input.channel.trim()),
};
queries.push(channelidSearch);
}
if (input.channel !== undefined) { // If we got a channel argument, lets filter out only that channel
const channelSearch = {
'bool': {
'must': {
'query_string': {
'fields': ['channel'],
'query' : getEscapedQuery(input.channel.trim()),
},
},
},
},
};
}
};
queries.push(channelSearch);
}
return queries;
};

const conBoost = { // Controlling claims should get higher placement in search results.
'match': {
'bid_state': {
@@ -268,8 +273,7 @@ function getResults (input) {
funcScoreChannelWeight,
],
'must': [
channelSearch,
// channelidSearch, // Commented for now to prevent query error while I investigate.
...dynamicFilters(),
{
'bool': {
'should': [
@@ -292,7 +296,7 @@ function getResults (input) {
},
},
};
// console.log('QUERY: ', esQuery);
// console.log('QUERY: ', JSON.stringify(esQuery));
return eclient.search(esQuery);
}

0 comments on commit 715ecc3

Please sign in to comment.
You can’t perform that action at this time.