PHP code example of gnugat / search-engine

1. Go to this page and download the library: Download gnugat/search-engine 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/ */

    

gnugat / search-engine example snippets


// ...
$criteria = $criteriaFactory->fromQueryParameters('blog', [
    // Filters
    'title' => 'IG',
    'author_ids' => '1,3',

    // Pagination
    'page' => '2',
    'per_page' => '3',

    // Ordering
    'sort' => 'author_id,-title',

    // Relation embeding
    'embed' => 'author',
]);
print_r(iterator_to_array(
    $searchEngine
        ->match($criteria)
        ->take(
            $criteria->paginating->offset,
            $criteria->paginating->itemsPerPage
        )
        ->getIterator()
));