Download the PHP package jarir-ahmed/search without Composer
On this page you can find all versions of the php package jarir-ahmed/search. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download jarir-ahmed/search
More information about jarir-ahmed/search
Files in jarir-ahmed/search
Package search
Short Description A unified, framework-agnostic search abstraction for PHP with Elasticsearch and in-memory engines.
License MIT
Informations about the package search
search
A unified, framework-agnostic search abstraction for PHP. Write your queries once and run them against Elasticsearch / OpenSearch in production or a dependency-free in-memory engine for tests and small datasets — same API, same results shape.
Features
- One
SearchEngineInterface:index,bulk,delete,clear,search— swap backends without touching call sites. - Engines for Elasticsearch/OpenSearch, Solr, Algolia, Meilisearch, Typesense, a database (PDO) engine, an in-memory engine, and a vector/semantic engine.
- Fluent
Querybuilder shared by every engine: term, field boosts, exact filters, fuzziness, sorting, pagination, and embeddings for semantic search. - HTTP engines talk through a pluggable
TransportInterface, so they're fully unit-testable without a live server.
Backends
| Engine | Class | Notes |
|---|---|---|
| In-memory | Engines\InMemoryEngine |
Tokenized scoring, fuzzy (Levenshtein), substring, filters. No deps. |
| Elasticsearch / OpenSearch | Engines\ElasticsearchEngine |
Query DSL via transport. |
| Solr | Engines\SolrEngine |
JSON Request API + edismax. |
| Algolia | Engines\AlgoliaEngine |
Transport carries app-id / API-key headers. |
| Meilisearch | Engines\MeilisearchEngine |
Bearer-token transport. |
| Typesense | Engines\TypesenseEngine |
Needs query_by fields. |
| Database (PDO) | Engines\DatabaseEngine |
Portable LIKE-based FTS, self-creates its table. |
| Vector / semantic | Engines\VectorEngine |
Cosine similarity over caller-supplied embeddings. |
Per-engine setup (transports, credentials, index configuration) is documented in docs/engines.md.
Requirements
- PHP >= 7.4,
ext-json ext-curlonly if you use the bundledCurlTransport
Install
Quick start (in-memory)
Elasticsearch / OpenSearch
The engine talks to ES through a TransportInterface. Swap in your own (Guzzle, PSR-18, a
mock) by implementing request(string $method, string $path, ?array $body): array.
Note:
termfilters andsortassume the field is keyword/numeric in your ES mapping.
Solr, Algolia, Meilisearch and Typesense work the same way — construct the engine with a transport and an index/collection name. Configure service auth on the transport, e.g.:
Database engine (no search server)
Semantic / vector search
Supply embeddings from any model; ranking is by cosine similarity — no external service.
Query reference
| Method | Description |
|---|---|
Query::create($term) |
New query for a search string (empty = match all). |
->fields(['title' => 2.0, 'body']) |
Restrict + boost searched fields. |
->filter($field, $value) |
Exact filter (ANDed). Matches array membership too. |
->fuzziness($n) |
Max edit distance for approximate matches. |
->sortBy($field, 'asc'|'desc') |
Sort by a field instead of relevance. |
->from($n) / ->size($n) |
Pagination. |
search() returns a SearchResult (iterable, countable): hits(), ids(), documents(),
total(), isEmpty(). Each Hit has id, score, source.
Testing
The suite covers the in-memory engine end-to-end and the Elasticsearch engine via a fake transport (no server required).
License
MIT
All versions of search with dependencies
ext-json Version *