interface SearchableInterface

Internal shape for models that can be indexed and searched.

Application models gain this capability through the Searchable trait and do not need to implement this interface directly. Keep this shape compatible with the trait while widening collection boundaries to Model for engines.

Methods

static Builder
search(string $query = '', Closure|null $callback = null)

Perform a search against the model's indexed data.

getScoutModelsByIds(Builder $builder, array $ids)

Get the requested models from an array of object IDs.

queryScoutModelsByIds(Builder $builder, array $ids)

Get a query builder for retrieving the requested models from an array of object IDs.

makeSearchableUsing(Collection $models)

Modify the collection of models being made searchable.

pushSoftDeleteMetadata()

Sync the soft deleted status for this model into the metadata.

searchableUsing()

Get the Scout engine for the model.

string|null
syncWithSearchUsing()

Get the queue connection that should be used when syncing.

string|null
syncWithSearchUsingQueue()

Get the queue that should be used with syncing.

void
searchable()

Make the given model instance searchable.

void
unsearchable()

Remove the given model instance from the search index.

string
searchableAs()

Get the index name for the model when searching.

string
indexableAs()

Get the index name for the model when indexing.

array
toSearchableArray()

Get the indexable data array for the model.

bool
shouldBeSearchable()

Determine if the model should be searchable.

bool
searchIndexShouldBeUpdated()

Determine if the model's search index should be updated.

bool
wasSearchableBeforeUpdate()

Determine if the model existed in the search index prior to an update.

bool
wasSearchableBeforeDelete()

Determine if the model existed in the search index prior to deletion.

mixed
getScoutKey()

Get the value used to index the model.

string
getScoutKeyName()

Get the key name used to index the model.

string
getScoutKeyType()

Get the auto-incrementing key type for querying models.

array
scoutMetadata()

Get all Scout related metadata.

withScoutMetadata(string $key, mixed $value)

Set a Scout related metadata.

Details

Perform a search against the model's indexed data.

Parameters

string $query
Closure|null $callback

Return Value

Builder

at line 38
Collection getScoutModelsByIds(Builder $builder, array $ids)

Get the requested models from an array of object IDs.

Parameters

Builder $builder
array $ids

Return Value

Collection

at line 46
Builder queryScoutModelsByIds(Builder $builder, array $ids)

Get a query builder for retrieving the requested models from an array of object IDs.

Parameters

Builder $builder
array $ids

Return Value

Builder

at line 54
Collection makeSearchableUsing(Collection $models)

Modify the collection of models being made searchable.

Parameters

Collection $models

Return Value

Collection

at line 61
SearchableInterface pushSoftDeleteMetadata()

Sync the soft deleted status for this model into the metadata.

Return Value

SearchableInterface

at line 66
Engine searchableUsing()

Get the Scout engine for the model.

Return Value

Engine

at line 71
string|null syncWithSearchUsing()

Get the queue connection that should be used when syncing.

Return Value

string|null

at line 76
string|null syncWithSearchUsingQueue()

Get the queue that should be used with syncing.

Return Value

string|null

at line 81
void searchable()

Make the given model instance searchable.

Return Value

void

at line 86
void unsearchable()

Remove the given model instance from the search index.

Return Value

void

at line 91
string searchableAs()

Get the index name for the model when searching.

Return Value

string

at line 96
string indexableAs()

Get the index name for the model when indexing.

Return Value

string

at line 101
array toSearchableArray()

Get the indexable data array for the model.

Return Value

array

at line 106
bool shouldBeSearchable()

Determine if the model should be searchable.

Return Value

bool

at line 111
bool searchIndexShouldBeUpdated()

Determine if the model's search index should be updated.

Return Value

bool

at line 116
bool wasSearchableBeforeUpdate()

Determine if the model existed in the search index prior to an update.

Return Value

bool

at line 121
bool wasSearchableBeforeDelete()

Determine if the model existed in the search index prior to deletion.

Return Value

bool

at line 126
mixed getScoutKey()

Get the value used to index the model.

Return Value

mixed

at line 131
string getScoutKeyName()

Get the key name used to index the model.

Return Value

string

at line 136
string getScoutKeyType()

Get the auto-incrementing key type for querying models.

Return Value

string

at line 141
array scoutMetadata()

Get all Scout related metadata.

Return Value

array

at line 148
SearchableInterface withScoutMetadata(string $key, mixed $value)

Set a Scout related metadata.

Parameters

string $key
mixed $value

Return Value

SearchableInterface