Skip to content

chore: update flexsearch to v0.8 (breaking change)Β #161

@josecelano

Description

@josecelano

Overview

Update flexsearch from version 0.7.43 to 0.8.105 (or latest stable).

Context

This is a major version update (0.7 β†’ 0.8) with significant breaking changes that require code modifications and thorough testing.

Related Snyk PR: #153

Current Usage

Flexsearch is currently used in the blog search functionality:

Current implementation:

import FlexSearch from 'flexsearch';
postsIndex = new FlexSearch.Index({ tokenize: 'forward' });

What's New in v0.8

According to the release notes:

  • πŸš€ 4.5x faster query performance
  • πŸ”Œ Persistent indexes support (IndexedDB, Redis, SQLite, PostgreSQL, MongoDB, ClickHouse)
  • 🎨 Result highlighting
  • πŸ” Enhanced language customization via Encoder class
  • πŸ“¦ Improved build system with better CJS/ESM support
  • πŸ”§ Improved interoperability and TypeScript definitions
  • ⚑ Regex pre-compilation
  • 🎯 Intermediate result sets and Resolver

Breaking Changes

  • API changes: Import patterns and method signatures may have changed
  • Build system: Different module format (CJS vs ESM)
  • Type definitions: Updated TypeScript types

Required Work

1. Update Dependency

npm install flexsearch@^0.8.105

2. Update Code

Review and update src/lib/utils/search.ts:

  • Check import statement compatibility
  • Verify Index constructor and options
  • Test add() and search() methods
  • Check return types and data structures

3. Testing Checklist

  • Search functionality works correctly
  • Search results are accurate
  • Result highlighting works (if implemented)
  • Performance is acceptable
  • No TypeScript errors
  • Build completes successfully
  • Test on different browsers (if client-side indexing is used)

4. Documentation

  • Update any relevant comments in the code
  • Document any configuration changes

Resources

Priority

Low - Current version (0.7.43) is working fine. This is an enhancement for better performance and features.

Labels

  • enhancement
  • dependencies
  • breaking-change

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions