1. Go to this page and download the library: Download andydefer/php-search 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/ */
andydefer / php-search example snippets
declare(strict_types=1);
use AndyDefer\PhpSearch\Engines\SearchEngine;
use AndyDefer\PhpSearch\Configs\EngineConfig;
use AndyDefer\PhpServices\Services\FileSystemService;
// Initialisation
$fileSystem = new FileSystemService();
$config = new EngineConfig(getcwd());
$queryProcessor = $container->get(QueryProcessorInterface::class);
$preFilter = $container->get(PreFilterInterface::class);
$engine = new SearchEngine($queryProcessor, $fileSystem, $config, $preFilter);
// Indexation
$engine->index('./data');
// Recherche
$results = $engine->search('Leonard', 10);
foreach ($results as $result) {
echo $result['name'] . ' - ' . $result['percentage'] . "%\n";
}
bash
# Indexer un dossier de fichiers JSONL
./vendor/bin/php-search index ./data
# Rechercher (utilise le dernier index)
./vendor/bin/php-search "Leonard" 10
# Rechercher dans un index spécifique
./vendor/bin/php-search "Cardio" 5 --source=./doctors
bash
# Indexation
./vendor/bin/php-search index ./docs
./vendor/bin/php-search index ./docs/artists.jsonl
# Recherche (dernier index)
./vendor/bin/php-search "Leonard" 10
# Recherche dans un index spécifique
./vendor/bin/php-search "Doctor" 5 --source=./docs2
# Gestion des index
./vendor/bin/php-search --list-indexes
./vendor/bin/php-search --stats --source=./docs
./vendor/bin/php-search --delete-index --source=./docs
./vendor/bin/php-search --clear-cache --source=./docs
./vendor/bin/php-search --clear-cache --source=./docs --query=Leonard