kinetis / search-opensearch
Fiber-native non-blocking OpenSearch client construction for Kinetis, on kinetis/search's Revolt-backed HTTP transport.
Requires
- php: ^8.4
- kinetis/framework: ^1.8.1
- kinetis/search: ^1.0.1
- opensearch-project/opensearch-php: ^2.6.0
- psr/http-client: ^1.0.3
Requires (Dev)
- infection/infection: ^0.35.0
- kinetis/revolt-http-client: ^1.4.1
- phpstan/phpstan: ^2.2.8
- phpunit/phpunit: ^13.3.3
- vimeo/psalm: ^6.17
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
kinetis/search-opensearch
Non-blocking OpenSearch client construction for Kinetis
Part of Kinetis, a non-blocking PHP framework for API-first applications, developed in the kinetis-dev/kinetis monorepo.
Builds a real OpenSearch\Client (from opensearch-project/opensearch-php)
through OpenSearch's own TransportFactory/HttpTransport construction
path, over kinetis/search's
Revolt-native HTTP transport instead of the default blocking one. The
returned object is the real, un-wrapped client — nothing Kinetis-specific
sits on top of it.
Each call is one wire attempt against one origin, bounded by one deadline
and one response size, following no redirect. The status, headers and body
are complete before the adapter returns, so a transport failure mid-body
is a SearchNetworkException rather than something the official client
meets while reading a stream. Every status OpenSearch answers with stays
the official client's to map.
use Kinetis\SearchOpenSearch\OpenSearchClientFactory; $client = OpenSearchClientFactory::fromConfig($config); $client->index(['index' => 'articles', 'id' => '1', 'body' => ['title' => 'Kinetis']]); $results = $client->search(['index' => 'articles', 'body' => ['query' => ['match' => ['title' => 'Kinetis']]]]);
Provides
Installing this package auto-registers, via extra.kinetis:
- A container binding for
OpenSearch\Client, built byOpenSearchClientFactory::fromConfig()whenSEARCH_OPENSEARCH_HOSTis set, and one forkinetis/search's engine-neutralSearchClientover it. Unset means the package binds nothing. The client is built during registration and opens no connection, so unusable configuration fails at boot rather than on the first search; an application's ownbootstrap.phpruns afterwards and can replace either binding.
Nothing else. Named connections stay explicit application wiring.
Configuration
SEARCH_OPENSEARCH_HOST=https://localhost:9200
The host, deadline, response bound, credentials and TLS switch are
kinetis/search's, spelled with
this engine's prefix:
| Key | Default | Purpose |
|---|---|---|
SEARCH_OPENSEARCH_HOST |
(required) | One http(s)://host[:port] origin. |
SEARCH_OPENSEARCH_PLAINTEXT |
false |
Accept an http origin. |
SEARCH_OPENSEARCH_TIMEOUT |
30 |
Seconds per request — idle and total. Must be positive. |
SEARCH_OPENSEARCH_MAX_RESPONSE_BYTES |
8388608 |
Largest response body accepted. Must be positive. |
SEARCH_OPENSEARCH_USERNAME |
— | Basic-auth user. |
SEARCH_OPENSEARCH_PASSWORD |
— | Basic-auth password. |
SEARCH_OPENSEARCH_VERIFY_PEER |
true |
Verify the server certificate — false accepts a self-signed one on a security-enabled cluster. |
Every key is scoped — SEARCH_OPENSEARCH_HOST + logs →
SEARCH_LOGS_OPENSEARCH_HOST. Full reference:
kinetis.dev/docs/search.html.
SEARCH_OPENSEARCH_HOST is one origin and one node. Userinfo, a path, a
query and a fragment are all refused: the official client's endpoints are
root-relative, so a base path would be dropped rather than honoured, and
credentials belong in the username and password keys. There is no
multi-node selector or failover — put a load balancer in front of a
multi-node cluster and point this at it.
An unusable host, an http origin without the opt-in, and a
non-positive timeout or response bound each raise a
SearchConfigurationException naming the key. A request that never
produces a complete response raises a SearchNetworkException carrying
it. Both belong to
kinetis/search, along with the
SearchRequestException its engine-neutral client reports an error
status as.
fromConfig()'s optional $transportDecorator parameter wraps the
fully-configured PSR-18 adapter right before TransportFactory gets
it — the seam kinetis/telemetry's TracingSearchTransport plugs
into, without duplicating the transport's own config-reading logic.
Installation
composer require kinetis/search-opensearch
Requires PHP 8.4+, kinetis/framework, and kinetis/search.
Full documentation:
kinetis.dev/docs/search-opensearch.html.
License
MIT — see LICENSE.