Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Laravel Site Search Laravel Package

spatie/laravel-site-search

Crawl and index your Laravel site for fast full-text search—like a private Google. Highly customizable crawling and indexing, with concurrent requests. Uses SQLite FTS5 by default (no external services), or Meilisearch for advanced features.

View on GitHub
Deep Wiki
Context7

title: Retrieving results weight: 3

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(); // returns all results

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(); // returns the first 20 results

Paginating results

You can paginate results using by calling paginate.

use Spatie\SiteSearch\Search;

$searchResults = Search::onIndex('my-index')
    ->query('your query')
    ->paginate(20); // returns an instance of `Illuminate\Pagination\Paginator` with 20 results per page

Deep linking to sections

Search results can link directly to a specific section of a page. When your HTML headings have id attributes, the indexer automatically extracts them and associates them with nearby text content.

<h2 id="installation">Installation</h2>
<p>To install the package, run...</p>

<h2 id="configuration">Configuration</h2>
<p>After installation, configure...</p>

Use the urlWithAnchor() method on a Hit to get the full URL including the fragment:

foreach ($searchResults->hits as $hit) {
    $url = $hit->urlWithAnchor(); // https://example.com/page#configuration
}

If no anchor is available for the matched content, urlWithAnchor() returns the base URL.

This works with all drivers (SQLite, Meilisearch, etc.).

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
codraw/entity-migrator
codraw/doctrine-extra
codraw/aws-tool-kit
codraw/validator
codraw/workflow
codraw/open-api
codraw/cron-job
codraw/process
codraw/log
nexmo/api-specification
capell-app/block-library
axium/identity
cetria/laravel-dummy-models
cetria/reflection-helper
agropredict/sso-auth-bundle
evolvestudio/spam-protection
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony