krisk / Fuse

Lightweight fuzzy-search, in JavaScript
https://fusejs.io/
Apache License 2.0
17.89k stars 759 forks source link

Fuse limits range weights from >0 to <1, contradicting the docs #493

Closed bashunaimiroy closed 3 years ago

bashunaimiroy commented 3 years ago

Describe the bug

I am receiving the error '"weight" property in key must be in the range of (0, 1)' when using weights that are suggested as an example in the Fuse.js docs, including a weight of exactly 1, or weights of more than 1.

image

image

Version

Version 5.2.3

Is this a regression?

I do not know

🔬Minimal Reproduction

const list = [{
title: "A Bug Report",
author: "Bashu"
}]
const options = {
   keys: [
          {
            name: 'title',
            weight: 2
          },
          {
            name: 'author',
            weight: 1
          }
   ]
}
const fuse = new Fuse(list, options)
fuse.search('Bashu')

Additional context

IvanDeluxe commented 3 years ago

Hey :)

I've dealt with that problem recently, just do:

npm i fuse.js@6.4.1

For some reason, "npm i fuse.js" doesn't install the latest version...

Wrote about it: https://github.com/krisk/Fuse/issues/463

Enjoy the weekend! :)