Download the PHP package monkeyscloud/monkeyslegion-search without Composer
On this page you can find all versions of the php package monkeyscloud/monkeyslegion-search. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download monkeyscloud/monkeyslegion-search
More information about monkeyscloud/monkeyslegion-search
Files in monkeyscloud/monkeyslegion-search
Package monkeyslegion-search
Short Description Multi-engine search adapter (Meilisearch, Typesense, OpenSearch, Elasticsearch, Solr) with attribute-driven index syncing from Entity and hybrid BM25+vector search support
License MIT
Informations about the package monkeyslegion-search
monkeyslegion-search
Multi-engine full-text, hybrid, and semantic search adapter for MonkeysLegion v2 with attribute-driven index syncing, auto-sync observers, queued indexing, and enterprise-grade query features.
Features
| Feature | Description |
|---|---|
| 6 Engine Adapters | Meilisearch, Typesense, OpenSearch, Elasticsearch, Apache Solr, Null (testing) |
| SearchableTrait | Scout-style toSearchableArray(), shouldBeSearchable(), search(), makeSearchable() |
| Auto-Sync Observers | Automatic index sync on entity create/update/delete via #[ObservedBy] or #[Subscribe] |
| Queued Indexing | Async index operations via monkeyslegion-queue integration |
| Fluent Query Builder | Chainable API for search, filter, sort, facet, highlight, geo, aggregate |
| Hybrid Search | BM25 + vector scoring with configurable weight blending |
| Geo-Distance Search | near(), withinRadius(), sortByDistance() with per-hit distance |
| Advanced Aggregations | sum, avg, min, max, cardinality, histogram, date_histogram, terms |
| Autocomplete / Suggest | Engine-native prefix suggestions across all adapters |
| Search Scopes | Reusable, composable query modifiers |
| Middleware Pipeline | Intercept queries for logging, analytics, caching, rate limiting |
| Multi-Index Search | Cross-index queries with score re-ranking |
| Raw Engine Queries | Engine-native DSL passthrough when the Builder isn't enough |
| Cursor Iteration | Memory-efficient lazy iteration over large result sets |
| Batch Reindexing | Chunked import with progress callbacks + zero-downtime alias swaps |
| Zero Dependencies | Internal cURL HTTP client — no PSR-18 or Guzzle required |
| PHP 8.4 Property Hooks | Computed properties on DTOs ($offset, $lastPage, $isHybrid, $isGeo) |
Installation
Requirements
| Requirement | Version |
|---|---|
| PHP | ^8.4 |
| Extensions | ext-curl, ext-json |
| Optional | monkeyslegion-queue (async indexing), monkeyslegion-entity (auto-sync) |
Quick Start
1. Mark Your Entity as Searchable
2. Configure Search Engines (MLC)
3. Search with the Fluent Builder
SearchableTrait
The SearchableTrait provides a Scout-style API for any entity:
Key Methods
| Method | Description |
|---|---|
toSearchableArray() |
Override to control indexed data structure |
shouldBeSearchable() |
Override for conditional indexing (e.g. skip drafts) |
getSearchKey() |
Document ID (defaults to $id) |
getSearchIndex() |
Index name (from #[Searchable] or auto-generated) |
static search(string $term) |
Create a fluent Builder for the entity |
searchable() |
Index this entity instance |
unsearchable() |
Remove this entity from the index |
static makeSearchable(iterable) |
Bulk-index entities |
static makeUnsearchable(iterable) |
Bulk-remove entities |
Auto-Sync (Observers)
Per-Entity Observer
Add #[ObservedBy(SearchObserver::class)] to your entity for automatic sync on create/update/delete:
Global Subscriber (Zero-Config)
The SearchSubscriber listens to ALL entities via #[Subscribe]. Just add #[Searchable] and SearchableTrait — no #[ObservedBy] needed:
Lifecycle Events
| Event | Action |
|---|---|
created / saved |
Index document (if shouldBeSearchable() is true) |
updated |
Re-index or remove (handles status transitions) |
deleted |
Remove from index |
restored |
Re-index document |
Queued Indexing
Offload index operations to background workers via monkeyslegion-queue:
Geo-Distance Search
Advanced Aggregations
Go beyond simple facets with full aggregation support:
Supported Aggregation Types
| Type | Output | Description |
|---|---|---|
sum |
Scalar | Sum of field values |
avg |
Scalar | Average |
min |
Scalar | Minimum value |
max |
Scalar | Maximum value |
cardinality |
Scalar | Unique value count |
terms |
Buckets | Top values by count |
histogram |
Buckets | Numeric ranges |
date_histogram |
Buckets | Date-based ranges |
Autocomplete / Suggestions
Search Scopes
Encapsulate reusable query logic into composable scopes:
Middleware Pipeline
Intercept and instrument search queries with a middleware stack:
Custom Middleware
Multi-Index Search
Search across multiple indexes with merged, score-ranked results:
Raw Engine Queries
When the Builder abstraction isn't enough, pass engine-native DSL directly:
Cursor Iteration
Memory-efficient streaming for processing large result sets:
Batch Reindexing
Chunked import with progress callbacks and zero-downtime alias swaps:
Hybrid Search (BM25 + Vector)
Combine traditional full-text scoring with vector similarity for semantic search:
Sync Index Schema
Attributes Reference
#[Searchable] — Class Level
| Parameter | Type | Default | Description |
|---|---|---|---|
index |
?string |
Auto-generated | Custom index name |
engine |
string |
'default' |
Engine connection name |
autoSync |
bool |
true |
Auto-index on persist/delete |
queue |
bool |
false |
Queue indexing via monkeyslegion-queue |
idField |
string |
'id' |
Property used as document ID |
#[SearchField] — Property Level
| Parameter | Type | Default | Description |
|---|---|---|---|
searchable |
bool |
true |
Include in full-text search |
filterable |
bool |
false |
Allow filter expressions |
sortable |
bool |
false |
Allow sorting |
facetable |
bool |
false |
Generate facet counts |
weight |
int |
1 |
Relevance weight multiplier |
analyzer |
?string |
null |
Custom analyzer (engine-specific) |
as |
?string |
null |
Custom field name in index |
#[SearchIndex] — Class Level
| Parameter | Type | Default | Description |
|---|---|---|---|
stopWords |
list<string> |
[] |
Words to ignore |
synonyms |
array<string, list<string>> |
[] |
Synonym groups |
rankingRules |
list<string> |
[] |
Engine-specific ranking |
tokenSeparators |
list<string> |
[] |
Custom token separators |
maxTotalHits |
?int |
null |
Max retrievable hits |
extra |
array<string, mixed> |
[] |
Raw engine settings |
Engine Comparison
| Feature | Meilisearch | Typesense | OpenSearch | Elasticsearch | Solr |
|---|---|---|---|---|---|
| Full-text search | ✓ | ✓ | ✓ | ✓ | ✓ |
| Filtering | ✓ | ✓ | ✓ | ✓ | ✓ |
| Faceting | ✓ | ✓ | ✓ | ✓ | ✓ |
| Sorting | ✓ | ✓ | ✓ | ✓ | ✓ |
| Highlighting | ✓ | ✓ | ✓ | ✓ | ✓ |
| Vector / kNN | ○ | ✓ | ✓ | ✓ | ○ |
| Hybrid search | ○ | ✓ | ✓ | ✓ | ○ |
| Geo search | ✓ | ✓ | ✓ | ✓ | ✓ |
| Autocomplete | ✓ | ✓ | ✓ | ✓ | ✓ |
| Raw queries | ✓ | ✓ | ✓ | ✓ | ✓ |
| Index aliases | ✗ | ✗ | ✓ | ✓ | ✗ |
| Default port | 7700 | 8108 | 9200 | 9200 | 8983 |
✓ = Supported ○ = Limited/Experimental
Architecture
Testing
License
MIT — see LICENSE.
All versions of monkeyslegion-search with dependencies
ext-curl Version *
ext-json Version *
monkeyscloud/monkeyslegion-core Version ^2.0
monkeyscloud/monkeyslegion-entity Version ^2.0
monkeyscloud/monkeyslegion-di Version ^2.0
monkeyscloud/monkeyslegion-events Version ^2.0
monkeyscloud/monkeyslegion-http-client Version ^1.0
psr/log Version ^3.0