Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions static/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ var Search = Control.extend({
var searchIndexVersionKey = this.formatLocalStorageKey(this.searchIndexVersionLocalStorageKey);
var index = this.getLocalStorageItem(searchIndexKey);
var indexVersion = this.getLocalStorageItem(searchIndexVersionKey);
var currentIndexVersion = 1;// Bump this whenever the index code is changed
var currentIndexVersion = 2;// Bump this whenever the index code is changed

if (index && currentIndexVersion === indexVersion) {
searchEngine = lunr.Index.load(index);
Expand All @@ -323,6 +323,7 @@ var Search = Control.extend({

this.pipeline.remove(lunr.stemmer);
this.pipeline.remove(lunr.stopWordFilter);
this.pipeline.remove(lunr.trimmer);
this.searchPipeline.remove(lunr.stemmer);

this.ref('name');
Expand Down Expand Up @@ -353,11 +354,10 @@ var Search = Control.extend({
//run the search
.query(function(q) {


if (searchTerm.indexOf('can-') > -1) {// If the search term includes “can-”

// look for an exact match and apply a large positive boost
q.term(searchTerm, { usePipeline: true, boost: 120 });
q.term(searchTerm, { usePipeline: true, boost: 375 });

} else {
// add “can-”, look for an exact match in the title field, and apply a positive boost
Expand Down
9 changes: 9 additions & 0 deletions test/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,12 @@ QUnit.test('Search for “stache”', function(assert) {
done();
});
});

QUnit.test('Search for “%special”', function(assert) {
var done = assert.async();
search.searchEngineSearch('%special').then(function(results) {
assert.equal(results.length > 0, true, 'got results');
assert.equal(indexOfPageInResults('can-stache/keys/special', results), 0, 'first result is the can-stache/keys/special page');
done();
});
});