krisk / Fuse

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

Does not give a score of 0 (exact match) if the input has more than one words ! #244

Closed bhuvesh40 closed 4 years ago

bhuvesh40 commented 6 years ago

For the input:

[
      {
        value: 'Common Room'
    },
    {
      value: 'Sitting Room'
    },
    {
      value: 'Parlor'
    },
    {
      value: 'Break room'
    },
    {
      value: 'Conference Room'
    }
]

and for the code:

  var options = {
  shouldSort: true,
  tokenize: true,
  includeScore: true,
  threshold: 0.2,
  location: 0,
  distance: 100,
  maxPatternLength: 32,
  minMatchCharLength: 1,
  keys: [
    "value"
]
};
var fuse = new Fuse(list, options); // "list" is the item array
var result = fuse.search("conference room");

It gives a score of 0.25. Is there something i'm missing over here?

brennanerbz commented 6 years ago

Any word on this?

akrz commented 5 years ago

You need matchAllTokens: true

When true, the result set will only include records that match all tokens. Will only work if tokenize is also true.

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