Laravel Packages

Crawl and Index Your Website with Laravel Site Search

Published
Crawl and Index Your Website with Laravel Site Search image

Laravel Site Search is a package by Spatie to create a full-text search index by crawling your site. You can think of it as a private Google search for your sites to crawl and index all your content and provide a highly customizable, indexed search.

Using this package, you can create an index via the provided artisan command, which will prompt you for the name of the index you'd like to make, the URL of the site, etc.

Once you have your index, you can crawl the site using a queued job with the provided console command. Lastly, you can search against the index—the following are a few examples:

use Spatie\SiteSearch\Search;
 
$searchResults = Search::onIndex($indexName)
->query('your query')
->get();
 
// Limit results
$searchResults = Search::onIndex('my-index')
->query('your query')
->limit(20)
->get(); // returns the first 20 results
 
// Pagination (defaults to 20 results per page)
$searchResults = Search::onIndex('my-index')
->query('your query')
->paginate(20);

Under the hood, Laravel Site Search is powered by Meilisearch, which provides exceptionally fast search speeds and various customization options like synonyms and custom properties.

Learn More

You can learn more about this package and view the source code on GitHub. The documentation is an excellent place to start for setup instructions and all the details to start using this fantastic package.

Paul Redmond photo

Staff writer at Laravel News. Full stack web developer and author.

Sponsored

masteringlaravel logo
Laravel Code Review

Get expert guidance in a few days with a Laravel code review

Visit Laravel Code Review

The latest

View all →
CPX: The Composer Package Executor for PHP image

CPX: The Composer Package Executor for PHP

Read article
Laravel AI SDK Adds Human-in-the-Loop Tool Approval image

Laravel AI SDK Adds Human-in-the-Loop Tool Approval

Read article
Pest 5 Released With Test Impact Analysis, Agent Verification, and Evals image

Pest 5 Released With Test Impact Analysis, Agent Verification, and Evals

Read article
Queue-SQL: Run Mass Deletes and Updates Across Parallel Queue Jobs image

Queue-SQL: Run Mass Deletes and Updates Across Parallel Queue Jobs

Read article
Blade Formatting in Laravel Pint image

Blade Formatting in Laravel Pint

Read article
Inertia DevTools Is Now on the Chrome Web Store image

Inertia DevTools Is Now on the Chrome Web Store

Read article