Skip to content

Number arrays not finding results. #738

@marceloverdijk

Description

@marceloverdijk

Is there an existing issue for this?

  • I have searched the existing issues

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?

  • This is a regression bug

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions