Live Search Optimizer
Relevance-Ranked AJAX Search for WordPress
Overview
Live Search Optimizer is a WordPress plugin that replaces the default search with real-time, relevance-ranked AJAX search. It supports searching inside ACF fields and custom taxonomies, with configurable debounce timing and keyword highlighting.
Problem
WordPress's default search is a blunt LIKE-query against post_title and post_content. No relevance ranking, no custom field support, no instant-results UX.
For a manufacturing catalog where customers search by part number, spec, or model, the default search fails to surface the right products. A search for a specific part number might return pages that mention it in passing rather than the actual product listing.
Approach
Built real-time AJAX search with configurable debounce timing, relevance-weighted scoring, and support for searching inside ACF fields and custom taxonomies. The scoring algorithm weights title matches higher than content matches, and exact matches higher than partial matches.
The search index is rebuilt incrementally as products are saved, avoiding the need for full reindex operations. Each search query is optimized to minimize database load while maintaining instant-results feel.
Architecture
Relevance Scoring
Custom weighting between titles and content ensures that exact matches in product names rank higher than mentions in body text. ACF fields and taxonomies are included in the search index with configurable weight multipliers.
Real-Time AJAX
Configurable debounce timing prevents server flooding while maintaining instant-results feel. The default 300ms debounce provides a good balance between responsiveness and server load. Results render as-you-type with keyword highlighting in both titles and excerpts.
Search Index
The plugin maintains a lightweight search index in a custom table, updated on save_post hooks. This avoids the overhead of querying wp_postmeta on every search request while keeping the index current.
Reusable Shortcode
Exposed as a single shortcode for easy reuse across future projects:
[live_search placeholder="Search..." results_limit="10"]
Results
- Instant, debounced search-as-you-type across custom post types with keyword highlighting
- Searches inside ACF fields and custom taxonomies -- part numbers and specs surface correctly
- Single shortcode integration for easy reuse across future projects
- Configurable debounce timing and result limits per instance