1. Go to this page and download the library: Download ols/php-fts library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
// Atomic update: soft delete + re-insert in a single lock
$newDocId = $engine->update($docId, ['title' => 'Updated title', 'price' => 149.90]);
// Soft delete (cleaned up on compaction)
$engine->delete($docId);
$count = $engine->count(); // Number of live documents
$rate = $engine->fragmentationRate(); // Fragmentation percentage (0 = clean, 100 = all deleted)
if ($engine->fragmentationRate() > 20) {
$engine->compact(); // Rebuild index files, remove deleted documents
}
$engine->reset(); // Wipe all index files and start fresh