Skip to content

Releases

v7.6.0-beta.6

v7.6.0-beta.6 Pre-release
Pre-release

Choose a tag to compare

@krisk krisk released this 24 Nov 01:26

Features

  • index: add a compact saved index format (7a5db23)

Performance Improvements

  • index: count words once per text and cache norm ids by word count (db9d161)

Saved indexes load about 3x faster

index.serialize() saves an index in a new compact format, and Fuse.parseIndex() reads it as well as the existing toJSON() format, which is unchanged:

// Ahead of time
const saved = JSON.stringify(Fuse.createIndex(keys, list).serialize())

// At startup
const fuse = new Fuse(list, options, Fuse.parseIndex(JSON.parse(saved)))

At 100k objects with 3 keys, loading a saved index takes 30 ms instead of 87 ms, and the file is 32 MB instead of 39 MB. Before this, loading a saved object index was slower than rebuilding it (54 ms); now it's about twice as fast. For plain string lists, loading saves little (6.5 ms against an 8 ms rebuild). Load the index with the same list, in the same order, as when it was saved. See saved indexes.

Faster index builds

Building an index is faster: 1.2x to 1.7x for string lists and 1.1x to 1.2x for objects, measured against 7.6.0-beta.5. Search speed and results are unchanged.

v7.6.0-beta.5

v7.6.0-beta.5 Pre-release
Pre-release

Choose a tag to compare

@krisk krisk released this 23 Nov 22:05

Performance Improvements

  • index: store index records in columns (3a38d56)
  • token: store the inverted index's removal ledger compactly (e587382)
  • normalize text once in TokenSearch and hole-sift MaxHeap (3b9d9ea), closes #868, thanks to @maccarlton25

Performance

The index now stores records in typed-array columns instead of one object per record and per field value, and token search keeps its per-document bookkeeping in packed integers. Measured against 7.6.0-beta.4 on the repository benchmarks (seeded data, alternating runs, medians), index memory at 100k items:

Index 7.6.0-beta.4 7.6.0-beta.5 Change
Objects 69.6 MB 12.0 MB 5.8x smaller
Objects with token search 225 MB 23.8 MB 9.5x smaller
Strings 7.2 MB 3.4 MB 2.1x smaller
Strings with token search 52.8 MB 8.3 MB 6.4x smaller

Building a token-search index is 13-18% faster. Search speed is unchanged, and results, scores and toJSON() output are identical.

Two paths got slower: loading a saved index with Fuse.parseIndex (about 14 ms more per 100k objects, since records are converted into columns) and building an index over plain strings (about 0.7 ms more at 100k). The saved index format didn't change, so indexes saved by any 7.x version still load.

Behavior changes

  • FuseIndex.records is deprecated and will be removed in v8. It now returns a fresh, detached copy of the records on each access, so writing to it no longer affects search. Development builds warn once. Use toJSON() to serialize an index.
  • toJSON() and add() return new objects instead of the index's own records, and records passed to setIndexRecords() or assigned to records are copied in. Mutating them afterwards doesn't change the index.
  • Fuse.parseIndex() and setIndexRecords() reject records whose document indexes, field keys or array positions aren't integers from 0 to 2^31 - 1, instead of storing corrupted values.

v7.6.0-beta.4

v7.6.0-beta.4 Pre-release
Pre-release

Choose a tag to compare

@krisk krisk released this 23 Nov 05:12

Features

  • search: match with a single-pass Myers algorithm by default (806afd2)

Performance

Fuzzy search now uses Myers' bit-vector algorithm, which finds the best match in a single pass over each text instead of Bitap's one scan per allowed typo. Measured against 7.6.0-beta.3 on the repository benchmarks (seeded data, alternating runs, medians):

Workload Speedup
Fuzzy search 2.1–5.7x
Fuzzy search with includeMatches 2.1–4.9x
Token search 3.1–7.7x
Logical $and / $or queries 1.4–1.6x
First search after building the index 5.1x

No benchmark got slower. The bundle grows by about 1 KB gzipped, since Bitap stays available.

New option: matchAlgorithm

matchAlgorithm: 'myers' | 'bitap' (default 'myers'). Set 'bitap' to keep the previous algorithm. Results, scores and match indices are the same at normal settings; Myers can differ only when distance is smaller than the query length (per 32-character chunk) or location is not an integer. See the fuzzy search docs.

v7.6.0-beta.3

v7.6.0-beta.3 Pre-release
Pre-release

Choose a tag to compare

@krisk krisk released this 23 Nov 04:10

Bug Fixes

  • bitap: report the score of the best match (f83fa61)

Behavior change

Fuzzy match scores now always describe the best match found. Previously, a later and worse candidate could overwrite the reported score, so many results scored worse than their actual match (for example, Fuse.match('optimization', 'Apple they optimization') returned 0.183 for an exact hit that scores 0.11). Scores can only go down, and with default options the set of matching results is unchanged, but result order can change where the best match was under-reported, typically moving full-word matches above partial ones. If you snapshot exact scores or result order in tests, expect updates.

v7.6.0-beta.2

v7.6.0-beta.2 Pre-release
Pre-release

Choose a tag to compare

@krisk krisk released this 22 Nov 23:57

Performance Improvements

  • bitap: reuse bit arrays and look up the alphabet by char code, 1.5–2x faster fuzzy search and up to 2.4x faster token search (0d691dc, 830626a), closes #865

Bug Fixes

  • index: stop Fuse instances from sharing a mutable index (fe90da8)

v7.6.0-beta.1

v7.6.0-beta.1 Pre-release
Pre-release

Choose a tag to compare

@krisk krisk released this 22 Nov 07:32

Bug Fixes

  • diacritics: compose Hangul back after stripping, so Korean search keeps working (96813ad), closes #861
  • extended-search: keep query terms that contain a line break (ce1df04), closes #862 #863
  • index: collect terminal nested array values individually (ff8a19e), closes #856
  • preserve in-flight worker search indices (171a4ce), closes #843
  • search: exclude inverse matches across array elements (de29276), closes #854
  • search: preserve fractional limit behavior (d9ab5a9), closes #849
  • search: preserve keyless inverse exclusions (0f76d02), closes #857
  • search: support token search in logical queries (fd17a49), closes #853
  • validate FuseWorker count (98e1dd0), closes #841
  • worker: detach handlers from discarded workers (8f6a948)
  • worker: recover after failed worker initialization (909743c), closes #842
  • worker: release pending handlers after errors (3df986d), closes #838
  • workers: ignore nullish document additions (d5ce7f4), closes #855

v7.6.0-beta.0

v7.6.0-beta.0 Pre-release
Pre-release

Choose a tag to compare

@krisk krisk released this 09 Aug 04:40

Beta preview of the MongoDB-style object query syntax. Install with npm install fuse.js@beta.

Features

  • search: add MongoDB-style object query syntax (#08459a9)

Express match types structurally instead of encoding them in magic characters:

const fuse = new Fuse(books, { keys: ['title', 'author'] })

fuse.search({ title: { $startsWith: 'old' }, author: { $eq: 'Kay' } })

Five operators ($fuzzy, $eq, $contains, $startsWith, $endsWith), plus $not for negation and field-local $and / $or.

Object String equivalent
$fuzzy term
$eq =term
$contains 'term
$startsWith ^term
$endsWith term$
$not: { $contains } !term
$not: { $startsWith } !^term
$not: { $endsWith } !term$

Highlights:

  • No useExtendedSearch flag. Object operators are unambiguous, so the flag that exists to parse magic characters in strings is not needed.
  • Exact parity with string syntax. An object query compiles to the same matchers as its string equivalent, so score and matches indices are identical.
  • Strict validation. Unknown operators, empty or non-string values, and illegal nesting throw immediately instead of silently degrading to a fuzzy search. The published types enforce the same grammar at compile time.
  • Composable. Field-local $and / $or for a field, and object leaves work anywhere a string leaf does inside logical $and / $or.
  • Works with FuseWorker, and basic builds stay lean (the compiler is behind the extended-search build flag).

$not wraps exactly one of $contains / $startsWith / $endsWith. $fuzzy and $eq have no inverse matcher, so negating them throws; $ne is reserved for a future whole-string inequality.

Docs: https://fusejs.io/extended-search#object-syntax

This is a prerelease. Feedback welcome before 7.6.0 goes stable.

v7.5.0

Choose a tag to compare

@krisk krisk released this 13 Jul 17:19

⚠️ Behavior changes

Every change in this release is a bug fix, but each one corrects a scoring or ranking bug. Scores and result ordering will shift for some queries. That is why this ships as a minor rather than a patch: the public API is unchanged and upgrading is a drop-in, but the results you get back can differ, and that should not arrive silently in a patch bump.

If you assert on exact score values or on a specific result order, expect those assertions to need updating. Re-baseline them against 7.5.0 rather than pinning to 7.4.x, since the 7.4.x behavior was wrong in the cases below.

  • Field-length normalisation now counts words correctly. Tabs and newlines were not treated as word separators, so a multi-line or tab-delimited field was scored as though it were one long word, making it look far shorter than it is. Fields containing \t, \n, or \r now score differently (#830).
  • Key weights are now normalised in object and keyless-logical search. Weights that did not sum to 1 were applied unnormalised, skewing the relative influence of each key. If your keys weights do not already sum to 1, your relative ranking changes (#833).
  • limit now returns the correct top-N when scores tie. A tie at the cutoff boundary could evict a result that should have been kept, so limit could return the wrong items, not merely the right items in a different order (#835).
  • Bitap respects minMatchCharLength in the exact-match shortcut. Matches shorter than minMatchCharLength were still reported via the exact-match fast path, so the matches array could contain entries it was configured to exclude (#831).

Bug Fixes

  • bitap: respect minMatchCharLength in exact-match shortcut (dbb98b6), closes #831
  • fieldNorm: count tabs and newlines as word separators (6fe85b0), closes #830
  • fieldNorm: count word-starts instead of space transitions (2946f97)
  • scoring: normalise key weights in object and keyless-logical search (e164b61), closes #833
  • search: keep the correct top-N under limit when scores tie (437f8f3), closes #835, thanks @spokodev for the report and the fix

Full Changelog: v7.4.2...v7.5.0

v7.4.2

Choose a tag to compare

@krisk krisk released this 05 Jun 22:23

Bug Fixes

  • types: ship CommonJS type declarations (.d.cts) so consumers on moduleResolution: node16/nodenext no longer hit TS1479 ("masquerading as ESM") when importing the package from a CommonJS project. The lib entries now resolve to a runtime-accurate export = declaration and the worker to its named declaration, via the require exports condition. (#780)

Full Changelog: v7.4.1...v7.4.2

v7.4.1

Choose a tag to compare

@krisk krisk released this 02 Jun 00:31

Bug Fixes

  • types: ship TypeScript declarations for fuse.js/worker (572ad1e), closes #828
  • types: add TypeScript declarations for fuse.js/worker-script (6ef6c33), closes #828

Both worker subpaths now resolve types under node16/nodenext and bundler module resolution.