Git Product home page Git Product logo

Comments (6)

charlesvinette avatar charlesvinette commented on June 29, 2024 1

Can confirm the issue also exists on beta43! Worked around it by downgrading to Beta 41. Thanks for sharing @brydar

from kbar.

dubzzz avatar dubzzz commented on June 29, 2024

Here is just a minimal repro with fuse only:

const fuse_js_1 = require("fuse.js");

const filtered = [
  {
    priority: 0,
    ancestors: [],
    children: [],
    id: "blog",
    name: "Blog long name aaa",
    keywords: "",
    command: {},
  },
  {
    priority: 0,
    ancestors: [],
    children: [],
    id: "contact",
    name: "Contact",
    keywords: "",
    command: {},
  },
  {
    priority: 0,
    ancestors: [],
    children: [],
    id: "test1",
    name: "test registration bug aaa",
    keywords: "",
  },
];
const fuseOptions = {
  keys: [
    {
      name: "name",
      weight: 0.5,
    },
    {
      name: "keywords",
      getFn: function (item) {
        return item.keywords.split(",");
      },
      weight: 0.5,
    },
    "subtitle",
  ],
  includeScore: true,
  includeMatches: true,
  threshold: 0.2,
  minMatchCharLength: 1,
  tokenize: function (str) {
    // Example: Preserve hyphens and special characters as separate tokens
    return str.split(/[\s\-,.!()]+/).filter(Boolean);
  },
};

const fuse = new fuse_js_1(filtered, fuseOptions);
console.log(fuse.search("aaa")); // only receiving "Blog long name aaa" but not "test registration bug aaa"

It seems that the main question is: where to put the bar for threshold? 0.2 is probably too low for many cases, but what would be the best?

from kbar.

dubzzz avatar dubzzz commented on June 29, 2024

Based on this page, the behaviour is expected given the current options passed to fuse. Actually we pass distance=100 and threshold=0.2, meaning that for strings longer than 0.2*100=20 characters we will have to match lots of characters before seeing them into the list of suggestions.

@timc1 Do you think there could be a way to let users configure part of fuse? I mean overriding some of the configuration to put threshold to something larger (or smaller). See other suggestion in the message right after

from kbar.

dubzzz avatar dubzzz commented on June 29, 2024

I think setting the ignoreLocation to true might help. If such option is ok to be added into the configuration of fuse, maybe I can open a PR to add it. Cc @timc1

from kbar.

dubzzz avatar dubzzz commented on June 29, 2024

Normally this issue should be fixed now with #350 (not released yet)

from kbar.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.