[PR #448] [CLOSED] feat: implement fuzzy search with Fuse.js for better template discovery #461

Closed
opened 2025-11-22 20:39:06 -06:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Dokploy/templates/pull/448
Author: @jaainil
Created: 10/12/2025
Status: Closed

Base: mainHead: adding-fuse.js


📝 Commits (2)

  • fdd59d8 chore: add bun.lock file to lock project dependencies
  • 84efaa3 refactor(code-editor): simplify completion options and add type assertions

📊 Changes

7 files changed (+914 additions, -111 deletions)

View changed files

app/bun.lock (+687 -0)
📝 app/package-lock.json (+9 -0)
📝 app/package.json (+28 -27)
📝 app/src/components/Search.tsx (+71 -38)
📝 app/src/components/TemplateGrid.tsx (+2 -20)
📝 app/src/components/ui/code-editor.tsx (+7 -26)
app/src/hooks/useFuseSearch.ts (+110 -0)

📄 Description

What is this PR about?

Implementation of Fuse.js fuzzy search to enhance template discovery with typo-tolerant, weighted search capabilities.

Changes Made

Features

  • Fuzzy Search: Handles typos and misspellings (e.g., "gost" finds "Ghost", "ackel" finds "Ackee")
  • 🎯 Weighted Search: Prioritizes matches in name (2x) > tags (1.5x) > description (1x) > ID (0.5x)
  • Performance Optimized: Uses useDeferredValue for smooth typing without lag
  • 🔍 Smart Matching: Case-insensitive, diacritics-ignored, location-agnostic search
  • 🚀 Instant Results: Matches from first character typed

Technical Implementation

  • Created useFuseSearch.ts custom hook with memoized Fuse instance
  • Configured optimal Fuse.js options (threshold: 0.4, ignoreLocation: true)
  • Implemented debounced URL updates (500ms) separate from instant search
  • Removed duplicate filtering logic from TemplateGrid component
  • Added local input state to prevent React re-render lag

Configuration

threshold: 0.4        // Balanced fuzzy matching
minMatchCharLength: 1 // Instant results
ignoreLocation: true  // Match anywhere in text

Checklist

Before submitting this PR, please make sure that:

Testing

Tested with various search queries:

  • Exact matches: "ghost", "docker", "postgres"
  • Fuzzy matches: "ackel" → "Ackee", "gost" → "Ghost", "doker" → Docker templates
  • Partial matches: "doc" → "Docmost", "Docuseal", "Documenso"
  • Performance: Smooth typing with 300+ templates, no lag

N/A - Enhancement feature


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Dokploy/templates/pull/448 **Author:** [@jaainil](https://github.com/jaainil) **Created:** 10/12/2025 **Status:** ❌ Closed **Base:** `main` ← **Head:** `adding-fuse.js` --- ### 📝 Commits (2) - [`fdd59d8`](https://github.com/Dokploy/templates/commit/fdd59d82f801ddc13afb6cbbcd5f719dc3b679a7) chore: add bun.lock file to lock project dependencies - [`84efaa3`](https://github.com/Dokploy/templates/commit/84efaa33203d00a471b0da5d4748709f5c5af5aa) refactor(code-editor): simplify completion options and add type assertions ### 📊 Changes **7 files changed** (+914 additions, -111 deletions) <details> <summary>View changed files</summary> ➕ `app/bun.lock` (+687 -0) 📝 `app/package-lock.json` (+9 -0) 📝 `app/package.json` (+28 -27) 📝 `app/src/components/Search.tsx` (+71 -38) 📝 `app/src/components/TemplateGrid.tsx` (+2 -20) 📝 `app/src/components/ui/code-editor.tsx` (+7 -26) ➕ `app/src/hooks/useFuseSearch.ts` (+110 -0) </details> ### 📄 Description ## What is this PR about? Implementation of **Fuse.js fuzzy search** to enhance template discovery with typo-tolerant, weighted search capabilities. ## Changes Made ### Features - ✨ **Fuzzy Search**: Handles typos and misspellings (e.g., "gost" finds "Ghost", "ackel" finds "Ackee") - 🎯 **Weighted Search**: Prioritizes matches in name (2x) > tags (1.5x) > description (1x) > ID (0.5x) - ⚡ **Performance Optimized**: Uses `useDeferredValue` for smooth typing without lag - 🔍 **Smart Matching**: Case-insensitive, diacritics-ignored, location-agnostic search - 🚀 **Instant Results**: Matches from first character typed ### Technical Implementation - Created useFuseSearch.ts custom hook with memoized Fuse instance - Configured optimal Fuse.js options (threshold: 0.4, ignoreLocation: true) - Implemented debounced URL updates (500ms) separate from instant search - Removed duplicate filtering logic from TemplateGrid component - Added local input state to prevent React re-render lag ### Configuration ```typescript threshold: 0.4 // Balanced fuzzy matching minMatchCharLength: 1 // Instant results ignoreLocation: true // Match anywhere in text ``` ## Checklist Before submitting this PR, please make sure that: - [x] I have read the suggestions in the README.md file https://github.com/Dokploy/templates?tab=readme-ov-file#general-suggestions-when-creating-a-template - [x] I have tested the template in my instance, so the maintainers don't spend time trying to figure out what's wrong. - [x] I have added tests that demonstrate that my correction works or that my new feature works. ## Testing Tested with various search queries: - ✅ Exact matches: "ghost", "docker", "postgres" - ✅ Fuzzy matches: "ackel" → "Ackee", "gost" → "Ghost", "doker" → Docker templates - ✅ Partial matches: "doc" → "Docmost", "Docuseal", "Documenso" - ✅ Performance: Smooth typing with 300+ templates, no lag ## Issues related (if applicable) N/A - Enhancement feature --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2025-11-22 20:39:06 -06:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/templates#461