Adding channel_id search back in. Reworked to avoid null queries being passed in.
Signed-off-by: Mark Beamer Jr <markbeamerjr@gmail.com>
This commit is contained in:
parent
e9598d6b76
commit
715ecc3d92
1 changed files with 30 additions and 26 deletions
|
@ -40,10 +40,11 @@ function getResults (input) {
|
||||||
let escapedQuery = getEscapedQuery(trimmedQuery);
|
let escapedQuery = getEscapedQuery(trimmedQuery);
|
||||||
let washedQuery = getEscapedQuery(getWashedQuery(trimmedQuery));
|
let washedQuery = getEscapedQuery(getWashedQuery(trimmedQuery));
|
||||||
let effectiveFactor = '0.00000000001';
|
let effectiveFactor = '0.00000000001';
|
||||||
|
const dynamicFilters = () => {
|
||||||
|
let queries = [];
|
||||||
// Search is split up into different parts, all search parts goes under this line.
|
// Search is split up into different parts, all search parts goes under this line.
|
||||||
let channelidSearch;
|
|
||||||
if (input.channel_id !== undefined) {
|
if (input.channel_id !== undefined) {
|
||||||
channelidSearch = { // If we got a channel_id argument, lets filter out only that channel_id
|
const channelidSearch = { // If we got a channel_id argument, lets filter out only that channel_id
|
||||||
'bool': {
|
'bool': {
|
||||||
'must': {
|
'must': {
|
||||||
'query_string': {
|
'query_string': {
|
||||||
|
@ -53,10 +54,10 @@ function getResults (input) {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
queries.push(channelidSearch);
|
||||||
}
|
}
|
||||||
let channelSearch;
|
|
||||||
if (input.channel !== undefined) { // If we got a channel argument, lets filter out only that channel
|
if (input.channel !== undefined) { // If we got a channel argument, lets filter out only that channel
|
||||||
channelSearch = {
|
const channelSearch = {
|
||||||
'bool': {
|
'bool': {
|
||||||
'must': {
|
'must': {
|
||||||
'query_string': {
|
'query_string': {
|
||||||
|
@ -66,7 +67,11 @@ function getResults (input) {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
queries.push(channelSearch);
|
||||||
}
|
}
|
||||||
|
return queries;
|
||||||
|
};
|
||||||
|
|
||||||
const conBoost = { // Controlling claims should get higher placement in search results.
|
const conBoost = { // Controlling claims should get higher placement in search results.
|
||||||
'match': {
|
'match': {
|
||||||
'bid_state': {
|
'bid_state': {
|
||||||
|
@ -268,8 +273,7 @@ function getResults (input) {
|
||||||
funcScoreChannelWeight,
|
funcScoreChannelWeight,
|
||||||
],
|
],
|
||||||
'must': [
|
'must': [
|
||||||
channelSearch,
|
...dynamicFilters(),
|
||||||
// channelidSearch, // Commented for now to prevent query error while I investigate.
|
|
||||||
{
|
{
|
||||||
'bool': {
|
'bool': {
|
||||||
'should': [
|
'should': [
|
||||||
|
@ -292,7 +296,7 @@ function getResults (input) {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
// console.log('QUERY: ', esQuery);
|
// console.log('QUERY: ', JSON.stringify(esQuery));
|
||||||
return eclient.search(esQuery);
|
return eclient.search(esQuery);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue