DatabaseEngine
class DatabaseEngine extends Engine implements PaginatesEloquentModelsUsingDatabase
Database search engine implementation.
Searches directly in the database using LIKE queries and optional full-text search. This engine requires no external services and works with any database that Hypervel supports.
Properties
| protected EngineOperationRunner|null | $operationRunner | The operation runner assigned to this engine. |
from Engine |
| protected string | $operationRunnerEngineName | The configured name of this engine. |
from Engine |
| protected Model>, array<class-string, string[]>> | $attributeColumns | Cached searchable attribute columns by model class and attribute class. |
|
| protected Model>, array<string, mixed>> | $fullTextOptions | Cached full-text options by model class. |
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.
Assign the operation runner to this engine.
Update the given models without observing an external index operation.
Delete the given models without observing an external index operation.
Run a Builder operation through the operation runner.
Pluck and return the primary keys of the given results using the given key name.
Paginate the given search on the engine using database pagination.
Paginate the given search on the engine using simple database pagination.
Get the Eloquent models for the given builder.
Build the initial text search database query for all relevant columns.
Add an "order by" clause that orders by relevance (Postgres only).
Add additional, developer defined constraints to the search query.
Ensure that soft delete constraints are properly applied to the query.
Get the columns marked with a given attribute.
Details
at line 486
void
update(Collection $models)
Update the given models in the search index.
The database engine doesn't need to update an external index.
at line 508
void
delete(Collection $models)
Remove the given models from the search index.
The database engine doesn't need to remove from an external index.
at line 52
mixed
search(Builder $builder)
Perform a search against the engine.
at line 67
mixed
paginate(Builder $builder, int $perPage, int $page)
Perform a paginated search against the engine.
at line 440
Collection
mapIds(mixed $results)
Pluck and return the primary keys of the given results.
at line 455
Collection
map(Builder $builder, mixed $results, Model $model)
Map the given results to instances of the given model.
at line 463
LazyCollection
lazyMap(Builder $builder, mixed $results, Model $model)
Map the given results to instances of the given model via a lazy collection.
at line 474
int
getTotalCount(mixed $results)
Get the total count from a raw result returned by the engine.
at line 526
void
flush(Model $model)
Flush all of the model's records from the engine.
at line 542
mixed
createIndex(string $name, array $options = [])
Create a search index.
at line 551
mixed
deleteIndex(string $name)
Delete a search index.
in
Engine at line 102
Engine
setOperationRunner(EngineOperationRunner $runner, string $engineName)
Assign the operation runner to this engine.
Boot-only. The runner persists on this engine for the worker lifetime. Engines without observable operations retain no runner.
in
Engine at line 117
protected bool
hasObservableOperations()
Determine if this engine has operations worth observing.
at line 496
void
runUpdate(Collection $models)
Update the given models without observing an external index operation.
at line 518
void
runDelete(Collection $models)
Delete the given models without observing an external index operation.
in
Engine at line 205
mixed
runPaginate(Builder $builder, int $perPage, int $page)
Paginate through the operation runner.
at line 534
void
runFlush(Model $model)
Flush the given model without observing an external index operation.
in
Engine at line 255
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.
in
Engine at line 281
Collection
mapIdsFrom(mixed $results, string $key)
Pluck and return the primary keys of the given results using the given key name.
in
Engine at line 289
Collection
keys(Builder $builder)
Get the results of the query as a Collection of primary keys.
in
Engine at line 297
Collection
get(Builder $builder)
Get the results of the given query mapped onto models.
in
Engine at line 309
LazyCollection
cursor(Builder $builder)
Get a lazy collection for the given query mapped onto models.
at line 80
LengthAwarePaginator
paginateUsingDatabase(Builder $builder, int $perPage, string $pageName, int $page)
Paginate the given search on the engine using database pagination.
at line 104
Paginator
simplePaginateUsingDatabase(Builder $builder, int $perPage, string $pageName, int $page)
Paginate the given search on the engine using simple database pagination.
at line 130
protected Collection
searchModels(Builder $builder, int|null $page = null, int|null $perPage = null)
Get the Eloquent models for the given builder.
at line 154
protected Builder
buildSearchQuery(Builder $builder)
Initialize / build the search query for the given Scout builder.
at line 178
protected Builder
initializeSearchQuery(Builder $builder, array $columns, array $prefixColumns = [], array $fullTextColumns = [])
Build the initial text search database query for all relevant columns.
at line 251
protected bool
shouldOrderByRelevance(Builder $builder)
Determine if the query should be ordered by relevance.
at line 263
protected Builder
orderByRelevance(Builder $builder, Builder $query)
Add an "order by" clause that orders by relevance (Postgres only).
at line 294
protected Builder
addAdditionalConstraints(Builder $builder, Builder $query)
Add additional, developer defined constraints to the search query.
at line 325
protected Builder
constrainForSoftDeletes(Builder $builder, Builder $query)
Ensure that soft delete constraints are properly applied to the query.
at line 358
protected array
getFullTextColumns(Builder $builder)
Get the full-text columns for the query.
at line 368
protected array
getPrefixColumns(Builder $builder)
Get the prefix search columns for the query.
at line 379
protected array
getAttributeColumns(Builder $builder, string $attributeClass)
Get the columns marked with a given attribute.
at line 416
protected array
getFullTextOptions(Builder $builder)
Get the full-text search options for the query.