Loupe Search - Enhanced WordPress Search
A search enhancement plugin for WordPress that builds a fast, typo-tolerant index and exposes a developer-friendly API so you can build your own search UI. Loupe Search works out of the box with WordPress’s standard search.
Renamed from WP Loupe. Loupe Search is the successor to the WP Loupe plugin. Existing installs upgrade seamlessly, and the legacy filters, REST namespace, CLI command, and index folder still work as deprecated aliases. See Renamed from WP Loupe for details.
Quick Links
Section titled “Quick Links”Requirements | Installation | Settings | Reindexing | FAQ | Building Your Own Search UI | REST API | AI Agent Integration | Filters | Docs | Changelog
Overview
Section titled “Overview”Loupe Search replaces WordPress core search:
- Queries a dedicated SQLite index instead of the posts table
- Tolerates misspellings, and supports phrase matching and exclusion operators
- Keeps the index in sync as content is created, updated, and deleted
- Exposes a stable REST API for custom search experiences
Integrating with AI agents or automation? Loupe Search registers native abilities via the WordPress Abilities API.
Features
Section titled “Features”- Fast index-backed search for configured post types
- Typo-tolerant matching, phrase matching, and exclusion operators
- Per-field weighting, filterable fields, sortable fields (configured in Settings)
- Developer-facing REST API for building custom UIs, with filters, facets, geo search, and result highlighting/snippets
- Native AI agent integration via the WordPress Abilities API
Technical Requirements
Section titled “Technical Requirements”- PHP 8.1 or higher
- SQLite 3.35+ (required by Loupe 0.13.x)
- PHP extensions:
pdo_sqlite,intl,mbstring - WordPress 6.9+
About the PHP extensions:
pdo_sqliteprovides the SQLite driver Loupe uses to store and query the search index;intlpowers locale-aware tokenizing, collation, and typo tolerance; andmbstringensures multibyte (UTF-8) text is handled correctly during indexing and search. All three are required, but they are enabled by default on most modern PHP installations and shared hosts, so no action is usually needed. If your host is missing one, contact them or enable it in your PHP configuration.
Installation
Section titled “Installation”-
Install from WordPress.org (not yet available — the plugin is awaiting review)
- In your WordPress admin, go to Plugins > Add New
- Search for “Loupe Search”
- Click “Install Now”, then “Activate”
-
Quick Install
- Download
loupe-search.zip - Upload via WordPress Plugins > Add New > Upload Plugin
- Download
-
Composer Install
Terminal window composer require soderlind/loupe-search -
Post-Installation
- Activate the plugin
- Go to Settings > Loupe Search
- Click “Reindex” to build the initial search index (runs in batches; safe for large sites)
Settings
Section titled “Settings”You can configure Loupe Search’s search behavior and performance via the WordPress admin: Settings > Loupe Search.
General Settings
Section titled “General Settings”Post Types
Section titled “Post Types”Select which post types to include in the search index.
Field Weight
Section titled “Field Weight”Weight determines how important a field is in search results:
- Higher weight (e.g., 2.0) makes matches in this field more important in results ranking.
- Default weight is 1.0.
- Lower weight (e.g., 0.5) makes matches less important but still searchable.
Filterable Fields
Section titled “Filterable Fields”Filterable fields can be used to refine search results:
- Enable this option to allow filtering search results by this field’s values.
- Best for fields with consistent, categorized values like taxonomies, status fields, or controlled metadata.
- Examples: categories, tags, post type, author, or custom taxonomies.
Note: Fields with highly variable or unique values (like content) make poor filters as each post would have its own filter value.
Sortable Fields
Section titled “Sortable Fields”Sortable fields can be used to order search results:
- Enable this option to allow sorting search results by this field’s values
- Works best with numerical fields, dates, or short text values
- Examples: date, price, rating, title
Advanced Settings
Section titled “Advanced Settings”Loupe Search provides advanced configuration options to fine-tune your search experience:
Prefix Search
Section titled “Prefix Search”- Configure prefix search behavior. Prefix search allows finding terms by typing only the beginning (e.g., “huck” finds “huckleberry”).
- Prefix search is only performed on the last word in a search query. Prior words must be typed out fully to get accurate results. E.g.
my friend huckwould find documents containing huckleberry -huck is my friend, however, would not.
Typo Tolerance
Section titled “Typo Tolerance”- Enable Typo Tolerance: When enabled, searches will match terms with minor spelling errors.
- First Character Double Counting: When enabled, typos in the first character of a word will count as two errors instead of one.
- Typo Tolerance for Prefix Search: Allows typo tolerance in partial word searches.
- Alphabet Size: Define the size of the alphabet for typo calculations.
- Index Length: Configure the maximum length of indexed terms.
- Typo Thresholds: Set the minimum word length required for allowing different numbers of typos.
Query Parameters
Section titled “Query Parameters”- Maximum Query Tokens: Limits the number of words processed in a search query (default: 12).
- Minimum Prefix Length: Sets the minimum character length before prefix search activates (default: 3).
Languages
Section titled “Languages”- Configure which languages the search index should optimize for. Default is English (‘en’).
These advanced settings can be accessed in the WordPress admin under Settings > Loupe Search > Advanced tab.
Reindexing
Section titled “Reindexing”Reindexing rebuilds the index for your configured post types.
-
Admin UI: Settings → Loupe Search → click Reindex (runs in batches to avoid timeouts)
-
WP-CLI (recommended for large sites):
Terminal window wp loupe-search reindexOptional flags:
Terminal window wp loupe-search reindex --post-types=post,page --batch-size=1000
How does it handle updates to posts?
Section titled “How does it handle updates to posts?”The search index automatically updates when content is created, modified, or deleted.
Will it slow down my site?
Section titled “Will it slow down my site?”No. Loupe Search uses a separate, optimized search index and doesn’t impact your main database performance.
Can I customize what content is searchable?
Section titled “Can I customize what content is searchable?”Yes, using filters you can control exactly what content gets indexed and how it’s searched.
Does it work with custom post types?
Section titled “Does it work with custom post types?”Yes, you can select which post types to include in the Settings page or via filters.
Building Your Own Search UI
Section titled “Building Your Own Search UI”Loupe Search works out of the box with WordPress’s standard search. If your theme uses the normal search flow (e.g. a search form that routes to the built-in search results page), Loupe Search will power the results automatically — no custom UI required.
Loupe Search intentionally does not ship a front-end search block/shortcode UI. If you want a custom search experience (autocomplete, filters/facets, geo, custom sorting, etc.), build the UI you want and query Loupe Search via the REST API.
Start here: docs/search-api.md
REST API
Section titled “REST API”Loupe Search exposes search via REST endpoints:
- POST
/wp-json/loupe-search/v1/search(recommended; supports JSON filters, facets, geo, explicit sorting, and search-result highlighting/snippets) - GET
/wp-json/loupe-search/v1/search?q=...(legacy; kept for backward compatibility)
The old
wp-loupe/v1namespace still works as a deprecated alias. See Renamed from WP Loupe.
Developer documentation (schema + examples + Gutenberg block example): docs/search-api.md
AI Agent Integration (WordPress Abilities API)
Section titled “AI Agent Integration (WordPress Abilities API)”Loupe Search registers two abilities via the WordPress Abilities API (WordPress 6.9+) so AI agents and automation tools can discover and use search functionality natively — no extra configuration required:
loupe-search/search— Typo-tolerant full-text search across indexed post types. Supports phrase matching, exclusion, and OR operators. Publicly accessible.loupe-search/get-post— Retrieve a single published post by ID. Publicly accessible.
Both abilities are discoverable through the standard WordPress Abilities registry and exposed via REST (show_in_rest).
The legacy
wp-loupe/*abilities (categorywp-loupe) still work as deprecated aliases. See Renamed from WP Loupe.Upgrading from the MCP server? The experimental MCP server, token service, and WP-CLI token commands were removed in 0.8.5. See the MCP → Abilities API migration guide.
Filters
Section titled “Filters”Eight filters let you change what gets indexed, how it is weighted, and how results are returned:
| Filter | Use it to |
|---|---|
loupe_search_post_types | Choose which post types are indexed |
loupe_search_index_protected | Index password-protected posts |
loupe_search_db_path | Move the index directory |
loupe_search_field_{$field_name} | Clean a core post field before indexing |
loupe_search_schema_{$post_type} | Add/remove fields, set weights and sorting |
loupe_search_is_safely_sortable_{$post_type} | Force a core field to be sortable |
loupe_search_is_safely_sortable_meta_{$post_type} | Correct meta-field sortability detection |
loupe_search_posts_per_page | Change results per page |
add_filter( 'loupe_search_post_types', function ( array $post_types ): array { $post_types[] = 'book'; return $post_types;} );Filters reference → — signatures, defaults, schema options, recipes, and when to reindex.
Filters use the
loupe_search_*prefix; the oldwp_loupe_*names still work as deprecated aliases. See Renamed from WP Loupe.
Testing
Section titled “Testing”-
PHPUnit:
Terminal window composer test -
Pest (runs using the PHPUnit config):
Terminal window composer test:pest
Acknowledgements
Section titled “Acknowledgements”- Loupe Search is built upon Loupe. Loupe is licensed under the MIT license.
Copyright and License
Section titled “Copyright and License”Loupe Search is copyright © 2024 Per Søderlind.
Loupe Search is open-source software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2, as published by the Free Software Foundation.
Loupe Search is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE for more information.
📦 Source: soderlind/loupe-search · Edit on GitHub