Engine
abstract class Engine
Abstract base class for search engine implementations.
Engines handle the actual indexing and searching operations with external search services like Meilisearch, or in-memory for testing.
Properties
| protected EngineOperationRunner|null | $operationRunner | The operation runner assigned to this engine. |
|
| protected string | $operationRunnerEngineName | The configured name of this engine. |
Methods
Pluck and return the primary keys of the given results.
Get the total count from a raw result returned by the engine.
Create a search index.
Delete a search index.
Get the import concurrency allowed for the given model.
Assign the operation runner to this engine.
Determine if this engine has operations worth observing.
Run a Builder operation through the operation runner.
Pluck and return the primary keys of the given results using the given key name.
Details
at line 41
abstract void
update(Collection $models)
Update the given models in the search index.
at line 48
abstract void
delete(Collection $models)
Remove the given models from the search index.
at line 53
abstract mixed
search(Builder $builder)
Perform a search against the engine.
at line 58
abstract mixed
paginate(Builder $builder, int $perPage, int $page)
Perform a paginated search against the engine.
at line 63
abstract Collection
mapIds(mixed $results)
Pluck and return the primary keys of the given results.
at line 68
abstract Collection
map(Builder $builder, mixed $results, Model $model)
Map the given results to instances of the given model.
at line 73
abstract LazyCollection
lazyMap(Builder $builder, mixed $results, Model $model)
Map the given results to instances of the given model via a lazy collection.
at line 78
abstract int
getTotalCount(mixed $results)
Get the total count from a raw result returned by the engine.
at line 83
abstract void
flush(Model $model)
Flush all of the model's records from the engine.
at line 88
abstract mixed
createIndex(string $name, array $options = [])
Create a search index.
at line 93
abstract mixed
deleteIndex(string $name)
Delete a search index.
at line 98
int
importConcurrency(Model $model, int $configured)
Get the import concurrency allowed for the given model.
at line 111
Engine
setOperationRunner(EngineOperationRunner $runner, string $engineName)
Assign the operation runner to this engine.
The runner persists on a cached engine for the worker lifetime. Engines without observable operations retain no runner.
at line 127
protected bool
hasObservableOperations()
Determine if this engine has operations worth observing.
at line 137
void
runUpdate(Collection $models)
Update the given models through the operation runner.
at line 167
void
runDelete(Collection $models)
Delete the given models through the operation runner.
at line 195
mixed
runSearch(Builder $builder)
Search through the operation runner.
at line 215
mixed
runPaginate(Builder $builder, int $perPage, int $page)
Paginate through the operation runner.
at line 235
void
runFlush(Model $model)
Flush the given model through the operation runner.
at line 265
mixed
runOperation(string $operation, Builder $builder, Closure $callback, string|null $index = null)
Run a Builder operation through the operation runner.
An omitted index uses the Builder's configured or searchable index. Pass an explicit index when the operation targets another dataset.
at line 291
Collection
mapIdsFrom(mixed $results, string $key)
Pluck and return the primary keys of the given results using the given key name.
at line 299
Collection
keys(Builder $builder)
Get the results of the query as a Collection of primary keys.
at line 307
Collection
get(Builder $builder)
Get the results of the given query mapped onto models.
at line 319
LazyCollection
cursor(Builder $builder)
Get a lazy collection for the given query mapped onto models.