shyim / opensearch-php-dsl
OpenSearch/Elasticsearch DSL library
Requires
- php: >=8.0
Requires (Dev)
Suggests
- elasticsearch/elasticsearch: Client library querying with the actual server
- opensearch-project/opensearch-php: Client library querying with the actual server
This package is auto-updated.
Last update: 2026-07-21 15:32:43 UTC
README
Introducing OpenSearch DSL library to provide objective query builder for opensearch-php client. You can easily build any Opensearch query and transform it to an array.
This is a fork of ongr-io/ElasticsearchDSL, which will be more regularly updated. Thanks for ongr-io for building this Library!
If you need any help, Github issues is the preferred and recommended way to ask support questions.
Version matrix
| OpenSearch version | OpenSearchDSL version |
|---|---|
| >= 1.0 | >= 1.0 |
| >= 2.0 | >= 1.0 |
Documentation
- User Guide - Comprehensive guide with examples for building queries, aggregations, sorting, and more
- API Documentation - Detailed reference documentation
Quick Start
Installation
Install library with composer:
composer require shyim/opensearch-php-dsl
Note: This library does not require
elasticsearch/elasticsearchoropensearch-project/opensearch-php. It is a standalone query builder that generates arrays compatible with any OpenSearch client.
Basic Example
<?php require 'vendor/autoload.php'; use OpenSearchDSL\Search; use OpenSearchDSL\Query\MatchAllQuery; $search = new Search(); $search->addQuery(new MatchAllQuery()); $params = [ 'index' => 'your_index', 'body' => $search->toArray(), ]; // Use with opensearch-php client $client = \OpenSearch\ClientBuilder::create()->build(); $results = $client->search($params);
Features
- Query Building: Support for all OpenSearch query types (match, term, range, bool, geo, etc.)
- Aggregations: Bucket, metric, and pipeline aggregations
- Sorting: Field sorting with multiple criteria
- Highlighting: Search result highlighting
- Suggestions: Term, phrase, and completion suggesters
- Framework Agnostic: Works with any HTTP client or OpenSearch client library
For detailed examples and usage instructions, see the User Guide.