From 32ebc7ac9f53ad51f8f558b18b3948137f75a394 Mon Sep 17 00:00:00 2001 From: Mark Beamer Jr Date: Tue, 16 Jul 2019 20:30:15 -0400 Subject: [PATCH] Only consider the 1st 3 terms in a search query for subqueries as they are likely to be related content searches and do not need to be so precise. --- server/controllers/lighthouse.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/server/controllers/lighthouse.js b/server/controllers/lighthouse.js index 4f6f0be..a3c2b1e 100644 --- a/server/controllers/lighthouse.js +++ b/server/controllers/lighthouse.js @@ -86,7 +86,8 @@ function getResults (input) { let queries = []; let conCatTerm = ''; let phraseTerm = ''; - escapedQuery.split(' ').forEach((term) => { + escapedQuery.split(' ').every((term, index) => { + if (index === 4) { return false } phraseTerm = phraseTerm + ' ' + term; conCatTerm = conCatTerm + term; queries.push( @@ -129,7 +130,8 @@ function getResults (input) { }; const splitATD = () => { let queries = []; - escapedQuery.split(' ').forEach((term) => { + escapedQuery.split(' ').every((term, index) => { + if (index === 4) { return false } queries.push({ // Contains search term in Author, Title, Description 'query_string': { 'query' : `*${term}*`,