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.
This commit is contained in:
Peter Bacon Darwin 2017-07-04 12:49:45 +01:00 committed by Pete Bacon Darwin
parent e28f097fc2
commit 062a7aa2cf
1 changed files with 1 additions and 11 deletions

View File

@ -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]; });
}