krisk / Fuse

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

Invalid value for key #571

Closed becory closed 2 years ago

becory commented 2 years ago

Hi, I got a problem from Fuse.

My case:

const data = [{
    id:23
    subject: 'issue1'
    tags:[{id:1, name:'test'},{id:2, name:'bug'},{id:3, name:'epic'}]
},
{
    id:25
    subject: 'issue2'
    tags:[]
}]

searchOpt = {
          keys: [`${item}.id`],
          useExtendedSearch: true, 
        }
const fuse =  new Fuse(data, searchOpt)
fuse.search({ $or: [{ $path: ['tags.id'], $val: 1 }, { $path: ['tags.id'], $val: 2}] })

Problem

I want to search $or in the tags.id

but always get exception Error: Invalid value for key tags.id

How can I skip the null array?