I'm sure I'm doing something simple wrong here. Can you please help me?
const options = { keys: ['content'], includeScore: true, includeMatches: true, shouldSort: true }
const notes = [
{
content: 'the lazy frog jumped over the log',
},
{
content: 'the lazy dog jumped over the banana',
},
{
content: 'the crazy man ate a frog',
},
]
const fuse = new Fuse(notes, options)
const searchExp = { $and: [{ content: `=frog` }, { content: `=lazy` }] }
const result = fuse.search(searchExp)
expect(result.length).toEqual(1)
I expected that searchExp to return only one result (the first one, because it's the only one that contains bothfrog and lazy. But instead, it returns two (the first and third).
I have tried this expression in other forms (without the equals):
const searchExp = { $and: [{ content: 'frog }, { content: 'lazy }] } //apostrophe, returns the same 2 results
const searchExp = { $and: [{ content: frog }, { content: lazy }] } //no extended, returns all three (3) results
I'm definitely missing something here. Can you please help me?
Thank you!
David
I'm sure I'm doing something simple wrong here. Can you please help me?
I expected that searchExp to return only one result (the first one, because it's the only one that contains both
frog
andlazy
. But instead, it returns two (the first and third).I have tried this expression in other forms (without the equals): const searchExp = { $and: [{ content:
'frog
}, { content:'lazy
}] } //apostrophe, returns the same 2 results const searchExp = { $and: [{ content:frog
}, { content:lazy
}] } //no extended, returns all three (3) results I'm definitely missing something here. Can you please help me? Thank you! David