From 062a7aa2cf7216e0fc3c5498fb1d2247dc37189b Mon Sep 17 00:00:00 2001 From: Peter Bacon Darwin Date: Tue, 4 Jul 2017 12:49:45 +0100 Subject: [PATCH] build(aio): revert to general purpose search algorithm Now that we have upgraded to the latest lunr search engine, the results from the standard `search` method are more appropriate. So we do not need to create our own special queries to get good results. --- aio/src/app/search/search-worker.js | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/aio/src/app/search/search-worker.js b/aio/src/app/search/search-worker.js index 1fbaf438da..ebda62f471 100644 --- a/aio/src/app/search/search-worker.js +++ b/aio/src/app/search/search-worker.js @@ -80,17 +80,7 @@ function loadIndex(searchInfo) { // Query the index and return the processed results function queryIndex(query) { - // The index requires the query to be lowercase - var terms = query.toLowerCase().split(/\s+/); - var results = index.query(function(qb) { - terms.forEach(function(term) { - // Only include terms that are longer than 2 characters, if there is more than one term - // Add trailing wildcard to each term so that it will match more results - if (terms.length === 1 || term.trim().length > 2) { - qb.term(term, { wildcard: lunr.Query.wildcard.TRAILING }); - } - }); - }); + var results = index.search(query); // Only return the array of paths to pages return results.map(function(hit) { return pages[hit.ref]; }); }