=== Fast JSON Search ===
Contributors: jrmora
Tags: search, json, performance, speed, mysql
Requires at least: 6.0
Tested up to: 7.0
Stable tag: 1.0.0
Requires PHP: 7.4
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Donate link: https://jrmora.com/

Replaces heavy MySQL search queries with a static JSON index file for instantaneous, ultra-fast search responses.

== Description ==

Default WordPress search relies on heavy MySQL queries using full table scans (`LIKE %keyword%`). As your site grows with thousands of posts, this process degrades server performance, increases database CPU load, and leads to slow search response times or timeouts.

**Fast JSON Search** solves this bottleneck completely by offloading the search process to a lightweight, static JSON file. Upon publishing or updating content, the plugin automatically indexes titles, content excerpts, categories, and tags into a optimized JSON file inside your uploads directory.

When a user searches on your site, the plugin intercepts the main query, scans the pre-indexed JSON file in milliseconds, and feeds the matched post IDs directly back to WordPress (`WHERE ID IN (...)`). This bypasses expensive database string comparisons, drastically lowering database load and delivering near-instant search results.

**Key Features:**

* **Database Relief:** Eliminates heavy `LIKE %...%` queries on full-text content across the database.
* **Automatic Reindexing:** Automatically updates the JSON search file every time a post is published, edited, or deleted.
* **Accent & Diacritics Normalization:** Strips accents and special characters during index generation and matching, guaranteeing accurate results regardless of search spelling (e.g., matching "Periodismo" with "periodismo").
* **Polylang Compatibility:** Built-in support to respect multilingual filtering when using Polylang.
* **Manual Reindex Tool:** Includes a simple admin setting page to manually rebuild the search index on demand after bulk content imports.
* **Clean & Lightweight:** Zero external dependencies, no extra database tables, zero background cron bloat, and fully internationalized for localization.

**When is this plugin most useful?**

* Content-heavy websites, blogs, and digital publications with thousands of published posts.
* Sites experiencing high server CPU usage or database slow-query logs triggered by native site searches.
* Hosting environments with strict database resource limits where un-indexed full-text searching degrades performance.

== Installation ==

1. Upload the `fast-json-search` directory to the `/wp-content/plugins/` directory, or upload the `.zip` file directly through the WordPress admin dashboard via **Plugins > Add New > Upload**.
2. Activate the plugin through the **Plugins** menu in WordPress.
3. Upon activation, the plugin automatically generates the initial `search-index.json` file inside your `/wp-content/uploads/` directory.
4. Optional: Navigate to **Settings > Fast JSON Search** to review the manual reindex button.

== Frequently Asked Questions ==

= How does the plugin replace MySQL search queries? =
When a frontend search is triggered, the plugin intercepts the main SQL query, nullifies the standard `LIKE %phrase%` clause, and searches the local `search-index.json` file instead. Once matching IDs are retrieved, it supplies those IDs directly into the SQL query using `post__in`.

= Does it create extra custom database tables? =
No. Fast JSON Search does not write any additional tables to your database. It generates a single static `.json` file inside your default WordPress uploads folder.

= What happens when I publish or edit an article? =
The index is updated automatically in real-time. The plugin listens to native WordPress actions (`save_post` and `deleted_post`) to rebuild the index without manual intervention.

= Is the JSON file publicly accessible or heavy? =
The JSON file only stores essential public information: post IDs, post titles, clean permalinks, stripped content excerpts (first 100 words), and taxonomy terms. It is highly compressed and stripped of unnecessary markup to keep file size minimal.

= What happens if I uninstall the plugin? =
By default, the generated `search-index.json` file is kept in your uploads folder to avoid accidental data removal. However, you can enable the "Clean Data on Uninstall" option in the plugin settings page to automatically delete the JSON index file and clean up all settings upon plugin uninstallation.

== Screenshots ==

1. The Fast JSON Search administration screen with the manual reindex trigger.
2. Query Monitor execution comparison demonstrating low-latency ID-based queries instead of full table scans.

== Changelog ==

= 1.0.0 =
* Initial official release.
* Automated JSON index compilation on post save and post deletion.
* Native search query interception with SQL `LIKE` clause elimination.
* Integrated string normalization for diacritics and accent-insensitive matching.
* Added Polylang language filtering support.
* Added manual reindexing option in WP Admin.

== Upgrade Notice ==

= 1.0.0 =
* Initial production release for static JSON search indexing.

== Copyright ==

Fast JSON Search is distributed under the terms of the GNU GPL v2 or later.