Download the PHP package renatomaldonado/manticore-laravel-search without Composer
On this page you can find all versions of the php package renatomaldonado/manticore-laravel-search. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download renatomaldonado/manticore-laravel-search
More information about renatomaldonado/manticore-laravel-search
Files in renatomaldonado/manticore-laravel-search
Package manticore-laravel-search
Short Description Laravel driver for Manticore Search using the official PHP client
License
Informations about the package manticore-laravel-search
Laravel Manticore Search
A driver for integrating Manticore Search with Laravel, featuring a fluent query builder, Eloquent model hydration, robust pagination, and support for multiple named connections.
Related packages
If you need full Eloquent support (migrations, create, update, delete,
relations, scopes, casts) natively on Manticore, see
laravel-manticore-eloquent
— a Laravel database driver over the Manticore MySQL protocol.
This package (manticore-laravel-search) focuses on the HTTP/JSON search API,
fluent query builder, consolidation, and facets.
What this library does
- Exposes a fluent query builder through
Model::manticore(). - Supports full-text search (
match) plus structured filters (where,whereIn,whereBetween,whereNull,whereRaw, etc.). - Supports SQL mode (
select,groupBy,having,orderBy,toSql,rawQuery). - Hydrates results into your model instances, including cast resolution and custom attribute mapping.
- Preserves request filters during pagination, including large payloads via a cached context token.
- Provides an optional
Manticorefacade for direct manager/client/table access.
Requirements
| Dependency | Version |
|---|---|
| PHP | ^8.1 |
| Laravel | ^10.0 \| ^11.0 \| ^12.0 |
manticoresoftware/manticoresearch-php |
^4.0 |
Installation
Configuration
Publish the config file:
Named connections (recommended)
Legacy flat config (backward compatibility)
If connections is empty or missing, the resolver falls back to the flat top-level keys (manticore.host, manticore.port, etc.) that predate multi-connection support.
Model setup
Add the HasManticoreSearch trait and implement searchableAs().
searchableAs() may return a string or an array of index names for multi-index queries.
Quick example
Builder API
Filtering
| Method | Description |
|---|---|
match(string $keywords, ?string $field, string $boolean) |
Full-text search. $field defaults to *. |
where(string $field, mixed $op, mixed $value) |
Equality or comparison. Supports =, !=, <>, >, >=, <, <=. |
orWhere(string $field, mixed $op, mixed $value) |
OR variant of where. |
whereNot(string $field, mixed $op, mixed $value) |
Negated filter. |
whereIn(string $field, array $values) |
IN filter. |
whereNotIn(string $field, array $values) |
NOT IN filter. |
whereBetween(string $field, array $range) |
Range filter [min, max]. |
whereNull(string $field) |
IS NULL — SQL mode only. |
whereNotNull(string $field) |
IS NOT NULL — SQL mode only. |
whereRaw(string $sql, string $boolean) |
Inject a raw SQL fragment — SQL mode only. |
whereGeoDistance(string $field, float $lat, float $lon, float $meters) |
Geo-distance filter. |
Ordering, limiting, selecting
| Method | Description |
|---|---|
orderBy(string\|array $column, ?string $direction) |
Accepts a column + direction, or an [col => dir] array. |
limit(int $limit) |
|
offset(int $offset) |
|
forPage(int $page, int $perPage) |
Sets limit + offset for the given page number. |
select(array\|string $fields) |
Triggers SQL mode. |
groupBy(array\|string $fields) |
Triggers SQL mode. |
having(array\|string $conditions) |
Triggers SQL mode. |
Options and metadata
| Method | Description |
|---|---|
option(string $key, mixed $value) |
Set a Manticore query option (max_matches, etc.). |
maxMatches(int $value) |
Shorthand for option('max_matches', $value). |
aggregate(string $name, array $aggregation) |
Add a facet aggregation. |
expression(string $name, mixed $exp) |
Add a script/expression field. |
withHighlight() |
Enable highlight in Search API responses. |
Eager loading
Connection and index overrides
| Method | Description |
|---|---|
usingConnection(string $name) |
Use a named connection from config. Flushes the local client cache. |
useIndex(string\|array $indexes) |
Override searchableAs(). Supports multi-index. |
rawQuery(string $sql, bool $rawMode) |
Execute manual SQL, bypassing the builder. |
Utility chainables
| Method | Description |
|---|---|
when(mixed $condition, callable $cb, ?callable $default) |
Apply a callback only when $condition is truthy. |
tap(callable $callback) |
Inspect/modify the builder mid-chain without breaking it. |
dump() |
Dump the compiled SQL and options, then continue the chain. |
dd() |
Dump the compiled SQL and options, then exit. |
Execution
| Method | Returns |
|---|---|
get() |
Illuminate\Database\Eloquent\Collection |
first() |
Model or null |
last() |
Model or null |
count() |
int |
pluck(string $field) |
Collection |
toArray() |
array |
toJson(int $options) |
string |
toSql() |
string — compiled SQL, no network call |
chunk(int $size, callable $callback) |
Iterates results in pages; returns false if callback returns false. |
paginate(int $perPage, string $pageName, ?int $page) |
LengthAwarePaginator |
getFacets() |
array (not available in rawQuery mode) |
Consolidation (group-merge)
Consolidation fetches multiple documents and merges all rows that share the same $groupField value into a single model, storing the originals under a $historyAttribute.
getConsolidatedBy() is an alias for consolidateAllBy() kept for backward compatibility.
Pagination and filter preservation
paginate() and paginateConsolidatedBy() automatically carry the current request's filters into the paginator links — including GET params, POST/JSON bodies, and custom page key names.
When the query string exceeds pagination.max_query_length bytes, the filters are stored in cache and replaced with a short token (_mctx) in the link. The full payload is restored on the next request.
To recover the full input payload manually:
To flush the cached total count for a query:
Relevant config keys under pagination:
| Key | Default | Description |
|---|---|---|
context_key |
_mctx |
URL token name for cached filter context. |
max_query_length |
1500 |
Byte threshold above which context caching activates. |
context_ttl |
900 |
Seconds to keep the filter context in cache. |
cache_prefix |
manticore:pagination: |
Cache key prefix. |
total_cache_ttl |
300 |
Seconds to cache the total count between pages. |
Optional facade
Architecture overview
Practical examples
SQL mode
Raw SQL
Facets
Chunked processing
Multi-connection
Debug
Tests
The CI workflow (.github/workflows/tests.yml) runs Unit and Feature tests across PHP 8.1–8.3 and Laravel 10–12, and Integration tests against a live Manticore Search container on PHP 8.2–8.3.
All versions of manticore-laravel-search with dependencies
laravel/framework Version ^10.0|^11.0|^12.0
manticoresoftware/manticoresearch-php Version ^4.0