Skip to main content
Create smaller records by splitting big records into logical chunks such as paragraphs or sentences. To split an attribute, your Searchable class must implement a split${Attribute} method. For example, if you want to split the body attribute, the method name should be splitBody.

Split directly on the Searchable class

The most basic way to split a record is by doing it directly on the Searchable class:
PHP
If all split methods for a specific model return an empty array, no records are sent to Algolia.

Split using a splitter

Sometimes you need to isolate the splitting logic into a dedicated class.
PHP

Write a splitter

One of the primary benefits of creating a splitter class is the ability to type-hint any dependencies your splitter may need in its constructor. Laravel automatically resolves and injects these dependencies into your splitter instance. To write a splitter, create a new class that implements the Algolia\ScoutExtended\Contracts\SplitterContract. The split method should split the given $value as needed:
PHP

Distinct

The distinct feature lets you force Algolia to return distinct results based on one attribute defined in attributeForDistinct. Using this attribute, you can limit the number of returned records that contain the same value in that attribute. To use distinct, configure the attributeForDistinct in your config/scout-articles.php configuration file:
PHP
Last modified on June 12, 2026