Skip to content

Commit 77625c2

Browse files
author
David Barrett
committed
Fix bug where the token separators used in the search component and the search inder were inconsistent
1 parent df76015 commit 77625c2

3 files changed

Lines changed: 6 additions & 2 deletions

File tree

addon/services/docs-search.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import Service, { inject as service } from '@ember/service';
22
import { getOwner } from '@ember/application';
33
import { computed } from '@ember/object';
44
import lunr from 'lunr';
5+
import config from 'dummy/config/environment';
56

67
const { Index, Query } = lunr;
78

@@ -11,7 +12,7 @@ export default Service.extend({
1112
search(phrase) {
1213
return this.loadSearchIndex()
1314
.then(({ index, documents }) => {
14-
let words = phrase.toLowerCase().split(/\s+/);
15+
let words = phrase.toLowerCase().split(config['ember-cli-addon-docs'].searchTokenSeparator);
1516
let results = index.query((query) => {
1617
// In the future we could boost results based on the field they come from
1718
for (let word of words) {

index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ module.exports = {
4747
projectName: this.parent.pkg.name,
4848
projectTag: this.parent.pkg.version,
4949
projectHref: info && info.browse(),
50-
deployVersion: 'ADDON_DOCS_DEPLOY_VERSION'
50+
deployVersion: 'ADDON_DOCS_DEPLOY_VERSION',
51+
searchTokenSeparator: /\s+/
5152
}
5253
};
5354

lib/broccoli/search-indexer.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ module.exports = class SearchIndexCompiler extends Writer {
2727
this.field('text');
2828
this.field('keywords');
2929

30+
this.tokenizer.separator = writer.config['ember-cli-addon-docs'].searchTokenSeparator;
31+
3032
for (let doc of writer.buildDocuments()) {
3133
if (doc) {
3234
documents[doc.id] = doc;

0 commit comments

Comments
 (0)