Skip to content

Instantly share code, notes, and snippets.

@artcommacode
Created June 10, 2014 13:36
Show Gist options
  • Save artcommacode/4ecc05c0167a15d317c0 to your computer and use it in GitHub Desktop.
Save artcommacode/4ecc05c0167a15d317c0 to your computer and use it in GitHub Desktop.
var index = lunr(function () {
this.field('title', {boost: 10});
this.field('text');
this.ref('_id');
});
pages.forEach(function (page) {
if (page.album) index.add(page);
});
render.results = index.search(query).map(function (result) {
result.page = _.first(pages.filter(function (page) {
return page.id === result.ref;
}));
return result;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment