krisk / Fuse

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

Weighted titles together with threshold do not act as expected #312

Closed morsh closed 4 years ago

morsh commented 5 years ago

Hi, Trying to run the following example with 0.3 returns no results, but with 0.4 returns results with ranking of 0.275:

var options = {
  includeScore: true,
  threshold: 0.4,
  location: 0,
  distance: 100,
  maxPatternLength: 32,
  minMatchCharLength: 1,
  keys: [{
    name: 'title',
    weight: 0.3
  }, {
    name: 'author',
    weight: 0.7
  }]
};
var fuse = new Fuse(list, options); // "list" is the item array
var result = fuse.search("Wou");

Returned results:

[
  {
    "item": {
      "title": "Thank You Jeeves",
      "author": {
        "firstName": "P.D",
        "lastName": "Woodhouse"
      }
    },
    "score": 0.2753333333333333
  }
]

From various tests I did, this is always score < threshold + 0.1 but when removing the weights, results act as expected.

krisk commented 5 years ago

This appears to be behaving as expected. In this particular example, when threshold is 0.3, the score is 0.3333333333333333. When the score is greater than threshold, the algorithm gives up.

github-actions[bot] commented 4 years ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days