Closed lucaong closed 1 year ago
This makes it more convenient to perform dynamic document boosting:
const documents = [ { id: 1, text: 'Some example text', boostFactor: 1.5 }, { id: 2, text: 'Some other example text', boostFactor: 0.9 }, { id: 3, text: 'Some more example text', boostFactor: null } ] // Initialize MiniSearch specifying storeFields const miniSearch = new MiniSearch({ fields: ['text'], storeFields: ['boostFactor'] }) // Upon search, use the `boostDocument` search option to specify a dynamic boosting factor on the basis of a stored field: miniSearch.search('example', { boostDocument: (_docId, _term, storedFields) => storedFields.boostFactor || 1 })
This makes it more convenient to perform dynamic document boosting: