krisk / Fuse

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

Strange matches and scores in results #703

Closed fcorallini closed 1 year ago

fcorallini commented 1 year ago

Version

Fuse.js v6.6.2

🔬Minimal Reproduction

var list = [
  'Gas naturale',
  'Gas naturale',
  'Gas naturale',
  'Gas naturale liquefatto',
  'Gas naturale liquefatto',
  'Gas naturale liquefatto',
  'Potassa caustica',
  'Indice Scorte di gas Austria',
  'Indice Scorte di gas Francia',
  'Indice Scorte di gas Italia',
  'Indice Scorte di gas Spagna',
  'Indice Scorte di gas Svezia',
  'Indice Scorte di gas Ungheria',
  'Gas Naturale NGP Spot, prezzo/Smc',
  'Gas Naturale NGP Spot, prezzo/ton',
  'Gas Naturale PSV (Italia), prezzo/Smc',
  'Gas Naturale PSV (Italia), prezzo/ton',
  'Gas naturale, Europa (WB CMO 10/22)',
  'Gas naturale, USA (WB CMO 10/22)',
  'Gas naturale, Europa (WB CMO 04/22)',
  'Gas naturale, USA (WB CMO 10/22)',
  ];

var options = {
    includeScore: true,
    ignoreFieldNorm: true,
    ignoreLocation: true,
    threshold: 0.5,
  };

fuse = new Fuse(list, options)
fuse.search('Gas USA')

Results

{item: 'Gas naturale', refIndex: 6, score: 0.412423964482104}
{item: 'Gas naturale', refIndex: 862, score: 0.412423964482104}
{item: 'Gas naturale', refIndex: 1671, score: 0.412423964482104}
{item: 'Gas naturale liquefatto', refIndex: 7, score: 0.48536978618240584}
{item: 'Gas naturale liquefatto', refIndex: 863, score: 0.48536978618240584}
{item: 'Gas naturale liquefatto', refIndex: 1672, score: 0.48536978618240584}
{item: 'Potassa caustica', refIndex: 1262, score: 0.5493389749536035}
{item: 'Indice Scorte di gas Austria', refIndex: 597, score: 0.5712176052489716}
{item: 'Indice Scorte di gas Francia', refIndex: 599, score: 0.5712176052489716}
{item: 'Indice Scorte di gas Italia', refIndex: 601, score: 0.5712176052489716}
{item: 'Indice Scorte di gas Spagna', refIndex: 608, score: 0.5712176052489716}
{item: 'Indice Scorte di gas Svezia', refIndex: 609, score: 0.5712176052489716}
{item: 'Indice Scorte di gas Ungheria', refIndex: 611, score: 0.5712176052489716}
{item: 'Gas Naturale NGP Spot, prezzo/Smc', refIndex: 1481, score: 0.5712176052489716}
{item: 'Gas Naturale NGP Spot, prezzo/ton', refIndex: 1482, score: 0.5712176052489716}
{item: 'Gas Naturale PSV (Italia), prezzo/Smc', refIndex: 1484, score: 0.5712176052489716}
{item: 'Gas Naturale PSV (Italia), prezzo/ton', refIndex: 1485, score: 0.5712176052489716}
{item: 'Gas naturale, Europa (WB CMO 10/22)', refIndex: 486, score: 0.5998190268701458}
{item: 'Gas naturale, USA (WB CMO 10/22)', refIndex: 487, score: 0.5998190268701458}  < ---- [  why not first ??? ]
{item: 'Gas naturale, Europa (WB CMO 04/22)', refIndex: 532, score: 0.5998190268701458}
{item: 'Gas naturale, USA (WB CMO 10/22)', refIndex: 487, score: 0.5998190268701458}  
etc ....
github-actions[bot] commented 1 year ago

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

reorx commented 1 year ago

Another strange thing is that items like {item: 'Indice Scorte di gas Austria', refIndex: 597, score: 0.5712176052489716} with score higher than threshold 0.5 are not omitted.

reorx commented 1 year ago

Fixed or just closed for stale?

fcorallini commented 1 year ago

@reorx Just closed for stale, not solved yet.