krisk / Fuse

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

Number arrays not finding results. #738

Open marceloverdijk opened 8 months ago

marceloverdijk commented 8 months ago

Is there an existing issue for this?

Description of the bug

Number arrays not finding results.

The Fuse.js version where this bug is happening.

6.6.2

Is this a regression?

Which version did this behavior use to work in?

6.6.2

Steps To Reproduce

[
  {
    "title": "Some title",
    "years": [2022, 2023]
  }
]

const options = {
  includeScore: true,
  keys: ['title', 'years']
}

const fuse = new Fuse(list, options)

const result = fuse.search('2022')

Won't find the entry.

Changing the array from numbers to string it will work: "years": [2022, 2023] ==> "years": ['2022', '2023']

But I need to actual numbers.

Note that this also works:

[
  {
    "title": "Some title",
    "years": [
      { "year": 2022 },
      { "year": 2023 }
    ]
  }
]

const options = {
  includeScore: true,
  keys: ['title', 'years.year']
}

const fuse = new Fuse(list, options)

const result = fuse.search('2022')

In that case the number is matched.

So it only happend for number arrays.

Expected behavior

Number arrays to be supported.

Screenshots

No response

Additional context

No response

github-actions[bot] commented 4 months 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

marceloverdijk commented 4 months ago

Please don not close, this is an actual issue.

github-actions[bot] commented 2 weeks 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