TypesenseEngine
class TypesenseEngine extends Engine
Typesense search engine implementation.
Provides full-text search using Typesense as the backend.
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.
Pluck and return the primary keys of the given results using the given key name.
Create a new TypesenseEngine instance.
Import the given documents into the index.
Create an import sorting data object for a given document.
Delete a document from the index.
Build the search parameters for a given Scout query builder.
Parse the given filter value.
Create a "where" filter string.
Create a "where in" filter string.
Create a "where not in" filter string.
Parse the order by fields for the query.
Get collection from model or create new one.
Get the underlying Typesense client.
Get a Scout configuration value.
Dynamically proxy missing methods to the Typesense client instance.
Details
at line 50
void
update(Collection $models)
Update the given models in the search index.
at line 140
void
delete(Collection $models)
Remove the given models from the search index.
at line 179
mixed
search(Builder $builder)
Perform a search against the engine.
at line 200
mixed
paginate(Builder $builder, int $perPage, int $page)
Perform a paginated search against the engine.
at line 433
Collection
mapIds(mixed $results)
Pluck and return the primary keys of the given results.
at line 446
Collection
map(Builder $builder, mixed $results, Model $model)
Map the given results to instances of the given model.
at line 488
LazyCollection
lazyMap(Builder $builder, mixed $results, Model $model)
Map the given results to instances of the given model via a lazy collection.
at line 518
int
getTotalCount(mixed $results)
Get the total count from a raw result returned by the engine.
at line 529
void
flush(Model $model)
Flush all of the model's records from the engine.
at line 539
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 90
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 98
Collection
keys(Builder $builder)
Get the results of the query as a Collection of primary keys.
in
Engine at line 106
Collection
get(Builder $builder)
Get the results of the given query mapped onto models.
in
Engine at line 118
LazyCollection
cursor(Builder $builder)
Get a lazy collection for the given query mapped onto models.
at line 38
__construct(Client $typesense, int $maxTotalResults)
Create a new TypesenseEngine instance.
at line 94
protected Collection
importDocuments(Collection $collectionIndex, array $documents, string|null $action = null)
Import the given documents into the index.
at line 122
protected stdClass
createImportSortingDataObject(array $document)
Create an import sorting data object for a given document.
at line 160
protected array
deleteDocument(Collection $collectionIndex, mixed $modelId)
Delete a document from the index.
Returns an empty array if the document doesn't exist (idempotent delete). Other errors (network, auth, etc.) are allowed to bubble up.
at line 223
protected mixed
performSearch(Builder $builder, array $options = [])
Perform the given search on the engine.
at line 250
protected array
performPaginatedSearch(Builder $builder)
Perform a paginated search on the engine.
at line 294
array
buildSearchParameters(Builder $builder, int $page, int|null $perPage)
Build the search parameters for a given Scout query builder.
at line 341
protected string
filters(Builder $builder)
Prepare the filters for a given search query.
at line 369
protected array|string|int|float
parseFilterValue(array|string|bool|int|float $value)
Parse the given filter value.
at line 387
protected string
parseWhereFilter(array|string|int|float $value, string $key)
Create a "where" filter string.
at line 399
protected string
parseWhereInFilter(array $value, string $key)
Create a "where in" filter string.
at line 409
protected string
parseWhereNotInFilter(array $value, string $key)
Create a "where not in" filter string.
at line 419
protected string
parseOrderBy(array $orders)
Parse the order by fields for the query.
at line 562
protected Collection
getOrCreateCollectionFromModel(Model $model, string|null $collectionName = null, bool $indexOperation = true)
Get collection from model or create new one.
at line 614
protected bool
usesSoftDelete(Model $model)
Determine if model uses soft deletes.
at line 622
Client
getTypesenseClient()
Get the underlying Typesense client.
at line 630
protected mixed
getConfig(string $key, mixed $default = null)
Get a Scout configuration value.
at line 640
mixed
__call(string $method, array $parameters)
Dynamically proxy missing methods to the Typesense client instance.