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:
parent
e28f097fc2
commit
062a7aa2cf
@ -80,17 +80,7 @@ function loadIndex(searchInfo) {
|
|||||||
|
|
||||||
// Query the index and return the processed results
|
// Query the index and return the processed results
|
||||||
function queryIndex(query) {
|
function queryIndex(query) {
|
||||||
// The index requires the query to be lowercase
|
var results = index.search(query);
|
||||||
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 });
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
// Only return the array of paths to pages
|
// Only return the array of paths to pages
|
||||||
return results.map(function(hit) { return pages[hit.ref]; });
|
return results.map(function(hit) { return pages[hit.ref]; });
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user