MeilisearchEngine
class MeilisearchEngine extends Engine implements DeletesByFilter, SupportsSemanticSearch, UpdatesIndexSettings
Meilisearch search engine implementation.
Provides full-text, semantic, and hybrid search using Meilisearch as the backend.
Constants
| protected FILTER_DELETE_TIMEOUT_IN_MS |
The maximum time to wait for a filtered deletion task. |
| protected FILTER_DELETE_INTERVAL_IN_MS |
The interval between filtered deletion task checks. |
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 |
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.
Run a Builder operation through the operation runner.
Pluck the given results with the given primary key name.
Create a new MeilisearchEngine instance.
Add embeddings to the given searchable records.
Combine application and Builder filters without changing their precedence.
Update the index settings for the given index.
Configure the soft delete filter within the given settings.
Delete all search indexes, optionally scoped by uid prefix.
Generate a tenant token for frontend direct search.
Determine if Meilisearch should generate embeddings natively.
Generate and validate embeddings using the optional Hypervel AI SDK.
Get the underlying Meilisearch client.
Dynamically call the Meilisearch client instance.
Details
at line 65
void
update(Collection $models)
Update the given models in the search index.
at line 177
void
delete(Collection $models)
Remove the given models from the search index.
at line 197
mixed
search(Builder $builder)
Perform a search against the engine.
at line 208
mixed
paginate(Builder $builder, int $perPage, int $page)
Perform a paginated search against the engine.
at line 403
Collection
mapIds(mixed $results)
Pluck and return the primary keys of the given results.
at line 438
Collection
map(Builder $builder, mixed $results, Model $model)
Map the given results to instances of the given model.
at line 478
LazyCollection
lazyMap(Builder $builder, mixed $results, Model $model)
Map the given results to instances of the given model via a lazy collection.
at line 515
int
getTotalCount(mixed $results)
Get the total count from a raw result returned by the engine.
at line 523
void
flush(Model $model)
Flush all of the model's records from the engine.
at line 579
mixed
createIndex(string $name, array $options = [])
Create a search index.
at line 637
mixed
deleteIndex(string $name)
Delete a search index.
in
Engine at line 98
int
importConcurrency(Model $model, int $configured)
Get the import concurrency allowed for the given model.
in
Engine 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.
in
Engine at line 127
protected bool
hasObservableOperations()
Determine if this engine has operations worth observing.
in
Engine at line 137
void
runUpdate(Collection $models)
Update the given models through the operation runner.
in
Engine at line 167
void
runDelete(Collection $models)
Delete the given models through the operation runner.
in
Engine at line 215
mixed
runPaginate(Builder $builder, int $perPage, int $page)
Paginate through the operation runner.
in
Engine at line 235
void
runFlush(Model $model)
Flush the given model through the operation runner.
in
Engine 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 418
Collection
mapIdsFrom(mixed $results, string $key)
Pluck the given results with the given primary key name.
at line 428
Collection
keys(Builder $builder)
Get the results of the query as a Collection of primary keys.
in
Engine at line 307
Collection
get(Builder $builder)
Get the results of the given query mapped onto models.
in
Engine at line 319
LazyCollection
cursor(Builder $builder)
Get a lazy collection for the given query mapped onto models.
at line 52
__construct(Client $meilisearch, bool $softDelete = false, array $config = [])
Create a new MeilisearchEngine instance.
at line 126
protected array
addEmbeddingsToRecords(array $records, array $settings)
Add embeddings to the given searchable records.
at line 222
protected array
semanticSearchParameters(Builder $builder)
Build semantic and hybrid search parameters.
at line 271
protected mixed
performSearch(Builder $builder, array $searchParams = [])
Perform the given search on the engine.
at line 308
protected string
filters(Builder $builder)
Get the filter string for the query.
at line 371
protected string|array
combineFilters(array|string|null $applicationFilters, string $builderFilters)
Combine application and Builder filters without changing their precedence.
at line 393
protected array
buildSortFromOrderByClauses(Builder $builder)
Get the sort array for the query.
at line 534
void
deleteByFilter(Builder $builder)
Delete every document matching the prepared Builder filters.
at line 609
void
updateIndexSettings(string $name, array $settings = [])
Update the index settings for the given index.
at line 625
array
configureSoftDeleteFilter(array $settings = [])
Configure the soft delete filter within the given settings.
at line 652
array
deleteAllIndexes(string|null $prefix = null)
Delete all search indexes, optionally scoped by uid prefix.
When $prefix is non-empty, only indexes whose uid starts with $prefix are deleted. When $prefix is null (or empty string, which str_starts_with matches against every string), every index on the Meilisearch server is deleted.
at line 688
string
generateTenantToken(array $searchRules, string $apiKeyUid, string $apiKey, DateTimeInterface|null $expiresAt = null)
Generate a tenant token for frontend direct search.
Tenant tokens allow secure, scoped searches directly from the frontend without exposing the admin API key. All tenants share a single index, with data isolation enforced at query time via embedded filters.
at line 718
protected array
modelSettings(Model $model)
Get the configured settings for a model.
at line 728
protected array
embeddingSettings(Model $model)
Get the validated embedding settings for a model.
at line 768
protected bool
usesNativeEmbeddings(array $settings)
Determine if Meilisearch should generate embeddings natively.
at line 780
protected array
generateEmbeddings(array $inputs, array $settings)
Generate and validate embeddings using the optional Hypervel AI SDK.
at line 803
protected bool
usesSoftDelete(Model $model)
Determine if the given model uses soft deletes.
at line 811
Client
getMeilisearchClient()
Get the underlying Meilisearch client.
at line 819
mixed
__call(string $method, array $parameters)
Dynamically call the Meilisearch client instance.