PHPackages                             soderlind/wp-loupe - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Search &amp; Filtering](/categories/search)
4. /
5. soderlind/wp-loupe

ActiveWordpress-plugin[Search &amp; Filtering](/categories/search)

soderlind/wp-loupe
==================

WP Loupe is a powerful search enhancement plugin for WordPress that delivers fast, accurate, and typo-tolerant search results. WP Loupe exposes a developer-friendly API so you can build your own search UI.

0.8.3(2mo ago)8433[7 PRs](https://github.com/soderlind/wp-loupe/pulls)GPL-2.0-or-laterPHPCI passing

Since Jan 22Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/soderlind/wp-loupe)[ Packagist](https://packagist.org/packages/soderlind/wp-loupe)[ Docs](https://github.com/soderlind/wp-loupe)[ Fund](https://paypal.me/PerSoderlind)[ RSS](/packages/soderlind-wp-loupe/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (5)Versions (80)Used By (0)

> **0.5.2 and later, require PHP 8.3**

WP Loupe - Enhanced WordPress Search
====================================

[](#wp-loupe---enhanced-wordpress-search)

> New! 🚀 WP Loupe - **Admin Search** is here! Search your admin content with the same powerful Loupe engine. Available at [wp-loupe-admin-search](https://github.com/soderlind/wp-loupe-admin-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. **WP Loupe works out of the box with WordPress’s standard search.**

Quick Links
-----------

[](#quick-links)

[Installation](#installation) | [REST API](#rest-api) | [Building Your Own Search UI](#building-your-own-search-ui) | [Settings](#settings) | [Filters](#filters) | [MCP Docs](docs/mcp.md) | [Changelog](CHANGELOG.md)

Overview
--------

[](#overview)

WP Loupe transforms WordPress's search functionality by:

- Creating a dedicated search index for lightning-fast results
- Supporting typo-tolerant searches
- Automatically maintaining the search index
- Providing a stable REST API for custom search experiences

> Integrating with external agents or automation? See **[docs/mcp.md](docs/mcp.md)**.

REST API
--------

[](#rest-api)

WP Loupe exposes search via REST endpoints:

- **POST** `/wp-json/wp-loupe/v1/search` (recommended; supports JSON filters, facets, geo, and explicit sorting)
- **GET** `/wp-json/wp-loupe/v1/search?q=...` (legacy; kept for backward compatibility)

Developer documentation (schema + examples + Gutenberg block example): **[docs/search-api.md](docs/search-api.md)**

MCP (Model Context Protocol) Integration (Summary)
--------------------------------------------------

[](#mcp-model-context-protocol-integration-summary)

WP Loupe ships with an optional MCP server enabling external AI agents or automation tools to discover commands and query your site.

Key points:

- Discovery endpoints: `/.well-known/mcp.json` &amp; `/.well-known/oauth-protected-resource` (enable in Settings → WP Loupe → MCP)
- Hybrid access: anonymous users can run limited `searchPosts`; tokens increase limits &amp; unlock `healthCheck`
- Token UI: create, scope-limit, set TTL (1–168h) or indefinite (0), revoke individually or all
- Last-used tracking for tokens; copy raw token once on creation
- Configurable rate limits (window, per-window quotas, max hits) via admin UI + filter overrides
- WP-CLI command for issuing tokens (mirrors into UI registry)
- Secure pagination cursors (HMAC) and standardized envelope responses

Full details, filter references, and examples: see [docs/mcp.md](docs/mcp.md).

Features
--------

[](#features)

- Fast index-backed search for configured post types
- Typo-tolerance (Loupe)
- Per-field weighting, filterable fields, sortable fields (configured in Settings)
- Developer-facing REST API for building custom UIs
- Optional MCP server for external agent/automation access

Installation
------------

[](#installation)

1. **Quick Install**

    - Download [`wp-loupe.zip`](https://github.com/soderlind/wp-loupe/releases/latest/download/wp-loupe.zip)
    - Upload via WordPress Plugins &gt; Add New &gt; Upload Plugin
2. **Composer Install**

    ```
    composer require soderlind/wp-loupe
    ```
3. **Post-Installation**

    - Activate the plugin
    - Go to Settings &gt; WP Loupe
    - Click "Reindex" to build the initial search index (runs in batches; safe for large sites)

- Plugin [updates are handled automatically](https://github.com/soderlind/wordpress-plugin-github-updater#readme) via GitHub. No need to manually download and install updates.

Building Your Own Search UI
---------------------------

[](#building-your-own-search-ui)

**WP Loupe 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), WP Loupe will power the results automatically — no custom UI required.

WP Loupe 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 WP Loupe via the REST API.

Start here: **[docs/search-api.md](docs/search-api.md)**

Settings
--------

[](#settings)

You can configure WP Loupe's search behavior and performance via the WordPress admin: Settings &gt; WP Loupe.

### General Settings

[](#general-settings)

#### Post Types

[](#post-types)

Select which post types to include in the search index.

#### Field Weight

[](#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

[](#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

[](#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

### MCP Settings

[](#mcp-settings)

WP Loupe can optionally expose an MCP (Model Context Protocol) server so external AI agents or automation tools can discover capabilities and query your site.

You can configure MCP in the WordPress admin under Settings &gt; WP Loupe &gt; MCP, including:

- Enable/disable the discovery endpoints (`/.well-known/mcp.json` and `/.well-known/oauth-protected-resource`)
- Create and manage access tokens (scope + TTL + revoke)
- Configure rate limits for anonymous vs token-authenticated requests
- Add access tokens.

Full details: **[docs/mcp.md](docs/mcp.md)**

### Advanced Settings

[](#advanced-settings)

WP Loupe provides advanced configuration options to fine-tune your search experience:

#### Prefix Search

[](#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 huck` would find documents containing huckleberry - `huck is my friend`, however, would not.

#### Typo Tolerance

[](#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

[](#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

[](#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 &gt; WP Loupe &gt; Advanced tab.

Reindexing
----------

[](#reindexing)

Reindexing rebuilds the index for your configured post types.

- **Admin UI:** Settings → WP Loupe → click **Reindex** (runs in batches to avoid timeouts)
- **WP-CLI (recommended for large sites):**

    ```
     wp wp-loupe reindex
    ```

    Optional flags:

    ```
     wp wp-loupe reindex --post-types=post,page --batch-size=1000
    ```

Testing
-------

[](#testing)

- PHPUnit:

    ```
     composer test
    ```
- Pest (runs using the PHPUnit config):

    ```
     composer test:pest
    ```

FAQ
---

[](#faq)

### How does it handle updates to posts?

[](#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?

[](#will-it-slow-down-my-site)

No. WP Loupe uses a separate, optimized search index and doesn't impact your main database performance.

### Can I customize what content is searchable?

[](#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?

[](#does-it-work-with-custom-post-types)

Yes, you can select which post types to include in the Settings page or via filters.

Filters
-------

[](#filters)

### `wp_loupe_db_path`

[](#wp_loupe_db_path)

This filter allows you to change the path where the Loupe database files are stored. By default, it's in the `WP_CONTENT_DIR .'/wp-loupe-db'` directory.

```
add_filter( 'wp_loupe_db_path', function ( $path ) {
	return WP_CONTENT_DIR . '/my-path';
} );
```

### `wp_loupe_post_types`

[](#wp_loupe_post_types)

This filter allows you to modify the array of post types that the WP Loupe plugin works with. By default, it includes 'post' and 'page'.

```
add_filter( 'wp_loupe_post_types', [ 'post', 'page', 'book' ] );
```

### `wp_loupe_posts_per_page`

[](#wp_loupe_posts_per_page)

This filter allows you to modify the number of search results per page. By default it's 10, set in `WPAdmin->Settings->Reading->"Blog pages show at most"`.

```
add_filter( 'wp_loupe_posts_per_page', 20 );
```

### `wp_loupe_index_protected`

[](#wp_loupe_index_protected)

This filter allows you to index posts and pages that are protected by a password. By default, it's set to `false`.

```
add_filter( 'wp_loupe_index_protected','__return_true' );
```

### `wp_loupe_field_{$field_name}`

[](#wp_loupe_field_field_name)

This filter allows you to change the field content before it is indexed.

By default, the following is used to remove HTML tags and comments from `post_content`. Among others, it removes the WordPress block comments.

```
add_filter( 'wp_loupe_field_post_content', 'wp_strip_all_tags' );
```

### `wp_loupe_schema_{$post_type}`

[](#wp_loupe_schema_post_type)

Modify the search schema for a specific post type. The filter name is dynamically generated based on the post type.

```
// Customize the schema for 'book' post type
add_filter( 'wp_loupe_schema_book', function( $schema ) {
	$schema['book_isbn'] = [		// Add a new field
		'weight'     => 2.0,		// Higher weight means higher relevance in search results
		'filterable' => true,		// Allow filtering by this field
		'sortable'   => [			// Allow sorting by this field
			'direction' => 'asc'	// Default sort direction
		],
	];

	// Modify existing field settings
	$schema['post_title']['weight'] = 3.0; // Increase title weight for books

	// Remove a field
	unset( $schema['post_excerpt'] );

	$schema['book_author'] = [
		'weight'     => 1.5,
		'filterable' => true,
		'sortable'   => [ 'direction' => 'asc' ],
	];

	return $schema;
});
```

The schema configuration supports the following options for each field:

- `weight` (float): The relevance weight in search results. Default: 1.0
- `filterable` (bool): Whether the field can be used for filtering. Default: false
- `sortable` (array): Sorting configuration with `direction` key ('asc' or 'desc'). Default: null

Default schema fields:

```
[
	'post_title'   => [
		'weight'     => 2,
		'filterable' => true,
		'sortable'   => [ 'direction' => 'asc' ],
	],
	'post_content' => [ 'weight' => 1.0],
	'post_excerpt' => [ 'weight' => 1.5 ],
	'post_date'    => [
		'weight'     => 1.0,
		'filterable' => true,
		'sortable'   => [ 'direction' => 'desc' ],
	],
	'post_author'  => [
		'weight'     => 1.0,
		'filterable' => true,
		'sortable'   => [ 'direction' => 'asc' ],
	],
	'permalink'    => [ 'weight' => 1.0 ],
]
```

Technical Requirements
----------------------

[](#technical-requirements)

- PHP 8.3
- SQLite 3.35+ (required by Loupe 0.13.x)
- PHP extensions: `pdo_sqlite`, `intl`, `mbstring`
- WordPress 6.7+

This architecture provides a balance between search quality, performance, and ease of integration with WordPress.

Acknowledgements
----------------

[](#acknowledgements)

- WP Loupe is built upon [Loupe](https://github.com/loupe-php/loupe/). Loupe is licensed under the MIT license.
- The plugin uses [Select2](https://select2.org/) for the post type selection dropdown. Select2 is licensed under the MIT license.
- The plugin uses Yannick Lefebvre's [WP Plugin Update Checker](https://github.com/YahnisElsts/plugin-update-checker?tab=readme-ov-file#github-integration) for updates. WP Plugin Update Checker is licensed under the MIT license.

Copyright and License
---------------------

[](#copyright-and-license)

WP Loupe is copyright © 2024 [Per Søderlind](http://github.com/soderlind).

WP Loupe 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.

WP Loupe 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](LICENSE) for more information.

 / block. 4. Keep indentation with tabs (current style) or convert uniformly if you restyle the list.
5. Avoid adding very small, single-sentence subsections to keep TOC scannable. --&gt;

###  Health Score

43

—

FairBetter than 91% of packages

Maintenance88

Actively maintained with recent releases

Popularity19

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity47

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 86.5% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~15 days

Total

51

Last Release

74d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1649452?v=4)[Per Søderlind](/maintainers/soderlind)[@soderlind](https://github.com/soderlind)

---

Top Contributors

[![soderlind](https://avatars.githubusercontent.com/u/1649452?v=4)](https://github.com/soderlind "soderlind (339 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (33 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (17 commits)")[![Copilot](https://avatars.githubusercontent.com/in/1143301?v=4)](https://github.com/Copilot "Copilot (3 commits)")

---

Tags

developer-friendlyloupesearch-enginesearchingtypo-tolerantwordpress-pluginwordpress pluginsearch engineloupesearchingdeveloper-friendlytypo-tolerant

###  Code Quality

TestsPest

### Embed Badge

![Health badge](/badges/soderlind-wp-loupe/health.svg)

```
[![Health](https://phpackages.com/badges/soderlind-wp-loupe/health.svg)](https://phpackages.com/packages/soderlind-wp-loupe)
```

###  Alternatives

[jackpopp/geodistance

Search for locations within a radius using latitude and longitude values with your eloquent models.

125120.4k13](/packages/jackpopp-geodistance)[ppshobi/psonic

PHP client for Sonic Search Engine

13494.8k3](/packages/ppshobi-psonic)[opensearchserver/opensearchserver

PHP library for OpenSearchServer: professionnal search engine, crawlers (web, file, database), REST APIs, .... This library uses OpenSearchServer's V2 API.

5267.5k](/packages/opensearchserver-opensearchserver)[nilportugues/sphinx-search

Fully unit tested SphinxClient (SphinxAPI) for PHP5.3 and above to be used with SphinxSearch

18452.9k2](/packages/nilportugues-sphinx-search)[ripaclub/sphinxsearch

Sphinx Search library provides SphinxQL indexing and searching features

6232.2k3](/packages/ripaclub-sphinxsearch)[cmsig/seal-symfony-bundle

An integration of CMS-IG SEAL search abstraction into Symfony Framework.

15195.8k5](/packages/cmsig-seal-symfony-bundle)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
