Closed nminchow closed 3 years ago
Logical operators with extended search expressions are not returning expected results.
6.4.6
This is the first version I have used
const Fuse = require('fuse.js'); const data = [ { type: 'foo bar', name: 'hit', stub: 'hit', }, { type: 'qux quz', name: 'miss', stub: 'miss', }, ]; const db = new Fuse(data, { keys: ['name', 'stub', 'type'], includeScore: true, }); const notQux = db.search({ $and: [ { type: '!^qux', }, { $or: [ { name: 'hit' }, { stub: 'hit' }, ], }, ], })[0]; console.log(notQux); // undefined const isBar = db.search({ $and: [ { type: '^bar', }, { $or: [ { name: 'hit' }, { stub: 'hit' }, ], }, ], })[0]; console.log(isBar); // { // item: { type: 'foo bar', name: 'hit', stub: 'hit' }, // refIndex: 0, // score: 0.0021180204984211294 // }
In the above example, I would expect the opposite behavior. If my understanding is correct, the first query should be returning the foo bar object, and the second query should be undefined.
foo bar
undefined
Seems to work just fine:
Ah, I missed that I needed to supply the useExtendedSearch param to the initializer! Thanks for the working example.
useExtendedSearch
Describe the bug
Logical operators with extended search expressions are not returning expected results.
Version
6.4.6
Is this a regression?
This is the first version I have used
🔬Minimal Reproduction
Additional context
In the above example, I would expect the opposite behavior. If my understanding is correct, the first query should be returning the
foo bar
object, and the second query should beundefined
.