olivernn / lunr.js

A bit like Solr, but much smaller and not as bright
http://lunrjs.com
MIT License
8.87k stars 547 forks source link

Any way to apply a overall document weight based on specific document type/category/field? #451

Closed Tuckie closed 4 years ago

Tuckie commented 4 years ago

I currently have a website with slowly changing content along side a blog.

Is there any way to de-prioritize results from the blog pages as opposed to results found elsewhere on the site?

olivernn commented 4 years ago

When adding documents to the index you can apply a boost to the document as a whole.

lunr(function () {
  this.add(blogPage, { boost: 0.5 })
  this.add(otherPage, { boost: 1.0 }) // this is the default behaviour
})

The boost can be less than one to de-prioritise matches.