lucaong / minisearch

Tiny and powerful JavaScript full-text search engine for browser and Node
https://lucaong.github.io/minisearch/
MIT License
4.67k stars 133 forks source link

Make the parameters of BM25+ scoring algorithm configurable #186

Closed lucaong closed 1 year ago

lucaong commented 1 year ago

Resolves: #163

Although this is rarely needed, and requires a good understanding of the Okapi BM25+ scoring model, some use cases (such as non-latin scripts with a very different structure) can benefit from it.

// BM25 params can be passed as part of searchOptions in the constructor
const ms = new MiniSearch({
  fields: ['text'],
  searchOptions: { bm25: { k: 1.0, b: 0.7, d: 0.5 } }
})

// Alternatively, they can be passed as options to individual searches
ms.search('something', { bm25: { k: 1.0, b: 0.7, d: 0.5 } })