Using a search profile | laravel-site-search | Spatie

 SPATIE

  Laravel Site Search
======================

spatie.be/open-source

  [Docs](https://spatie.be/docs)  [Laravel-site-search](https://spatie.be/docs/laravel-site-search/v3)  Basic-usage  Using a search profile

 Version   v3   v1

 Other versions for crawler [v3](https://spatie.be/docs/laravel-site-search/v3) [v1](https://spatie.be/docs/laravel-site-search/v1)

- [ Introduction ](https://spatie.be/docs/laravel-site-search/v3/introduction)
- [ Support us ](https://spatie.be/docs/laravel-site-search/v3/support-us)
- [ Requirements ](https://spatie.be/docs/laravel-site-search/v3/requirements)
- [ Installation and setup ](https://spatie.be/docs/laravel-site-search/v3/installation-setup)
- [ About us ](https://spatie.be/docs/laravel-site-search/v3/about-us)
- [ Questions and issues ](https://spatie.be/docs/laravel-site-search/v3/questions-issues)
- [ Changelog ](https://spatie.be/docs/laravel-site-search/v3/changelog)

Basic usage
-----------

- [ High level overview ](https://spatie.be/docs/laravel-site-search/v3/basic-usage/high-level-overview)
- [ Indexing your first site ](https://spatie.be/docs/laravel-site-search/v3/basic-usage/indexing-your-first-site)
- [ Retrieving results ](https://spatie.be/docs/laravel-site-search/v3/basic-usage/retrieving-results)
- [ Preventing content from being indexed ](https://spatie.be/docs/laravel-site-search/v3/basic-usage/preventing-content-from-being-indexed)
- [ Using a search profile ](https://spatie.be/docs/laravel-site-search/v3/basic-usage/using-a-search-profile)
- [ Listing indexes ](https://spatie.be/docs/laravel-site-search/v3/basic-usage/listing-indexes)
- [ Troubleshooting ](https://spatie.be/docs/laravel-site-search/v3/basic-usage/troubleshooting)

Advanced usage
--------------

- [ Creating multiple search indexes ](https://spatie.be/docs/laravel-site-search/v3/advanced-usage/creating-multiple-search-indexes)
- [ Using a custom indexer ](https://spatie.be/docs/laravel-site-search/v3/advanced-usage/using-a-custom-indexer)
- [ Indexing extra properties ](https://spatie.be/docs/laravel-site-search/v3/advanced-usage/indexing-extra-properties)
- [ Available events ](https://spatie.be/docs/laravel-site-search/v3/advanced-usage/available-events)
- [ Using the database driver ](https://spatie.be/docs/laravel-site-search/v3/advanced-usage/using-the-database-driver)
- [ Using the Meilisearch driver ](https://spatie.be/docs/laravel-site-search/v3/advanced-usage/using-the-meilisearch-driver)
- [ Building a Filament integration ](https://spatie.be/docs/laravel-site-search/v3/advanced-usage/filament-integration)

 Using a search profile
======================

###  On this page

1. [ Creating your own search profile ](#content-creating-your-own-search-profile)

A search profile determines which pages get crawled and what content gets indexed. In the `site-search` config file, you'll find in the `default_profile` key that the `Spatie\SiteSearch\Profiles\DefaultSearchProfile::class` is being used by default.

This default profile will instruct the indexing process:

- to crawl each page of your site
- to only index any page that had `200` as the status code of its response
- to not index a page if the response had a header `site-search-do-not-index`

By default, the crawling process will respect the `robots.txt` of your site.

A search profile is also responsible for determining which indexer will be used for a certain page. An indexer is responsible for determining the title, content, description, ... of a page. By default, `Spatie\SiteSearch\Indexers\DefaultIndexer` will get used. To know more about indexers and how to customize them, head over to [the section on indexers](/docs/laravel-site-search/v1/advanced-usage/using-a-custom-indexer).

Creating your own search profile
--------------------------------------------------------------------------------------------------------------------------------------------------------

If you want to customize the crawling and indexing behavior, you could opt to extend `Spatie\SiteSearch\Profiles\DefaultSearchProfile` or create your own class that implements the `Spatie\SiteSearch\Profiles\SearchProfile` interface. This is how that interface looks like.

```
namespace Spatie\SiteSearch\Profiles;

use Spatie\Crawler\Crawler;
use Spatie\Crawler\CrawlResponse;
use Spatie\SiteSearch\Indexers\Indexer;

interface SearchProfile
{
    public function shouldCrawl(string $url): bool;
    public function shouldIndex(string $url, CrawlResponse $response): bool;
    public function useIndexer(string $url, CrawlResponse $response): ?Indexer;
    public function configureCrawler(Crawler $crawler): void;
}
```
