By default, only the page title, URL, description, and some content are added to the search index. However, you can add any extra property you want.
You do this by using a custom indexer and override the extra method.
class YourIndexer extends Spatie\SiteSearch\Indexers\DefaultIndexer
{
public function extra() : array{
return [
'authorName' => $this->functionThatExtractsAuthorName()
]
}
public function functionThatExtractsAuthorName()
{
}
}
The extra properties will be available on a search result hit.
$searchResults = Search::onIndex('my-index')->query('your query')->get();
$firstHit = $searchResults->hits->first();
$firstHit->authorName;
All extra properties are searchable by default. When using the Meilisearch driver, you can customize the index settings to control which attributes are searchable.