This is the documentation for
v1 but the latest version is
v2
.
You can switch versions in the menu on the left/at the top.
Check your current version with the following command:
composer show spatie/laravel-site-search
You can retrieve results from an index using Spatie\SiteSearch\Search
.
##Getting all results
Here's how you can retrieve all results from an index named my-index
.
use Spatie\SiteSearch\Search;
$searchResults = Search::onIndex('my-index')
->query('your query')
->get();
##Limiting results
You can limit the amount of results using the limit
function.
use Spatie\SiteSearch\Search;
$searchResults = Search::onIndex('my-index')
->query('your query')
->limit(20)
->get();
##Paginating results
You can paginate results using by calling paginate
.
use Spatie\SiteSearch\Search;
$searchResults = Search::onIndex('my-index')
->query('your query')
->paginate(20);