shyim/opensearch-php-dsl

OpenSearch/Elasticsearch DSL library

Maintainers

👁 shyim

Package info

github.com/shyim/opensearch-php-dsl

Homepage

pkg:composer/shyim/opensearch-php-dsl

Statistics

Installs: 6 912 933

Dependents: 10

Suggesters: 1

Stars: 18

Open Issues: 4

1.1.5 2026-04-09 12:34 UTC

Requires

  • php: >=8.0

Suggests

Provides

None

Conflicts

None

Replaces

None

MIT 99d95883071a353a387ca59463a6e86c5a30440d


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.

👁 Test
👁 codecov
👁 Latest Stable Version
👁 Total Downloads

Version matrix

OpenSearch version OpenSearchDSL version
>= 1.0 >= 1.0
>= 2.0 >= 1.0

Documentation

The online documentation of the bundle is here

Try it!

Installation

Install library with composer:

$ composer require shyim/opensearch-php-dsl

elasticsearch-php client is defined in the composer requirements, no need to install it.

Search

The library is standalone and is not coupled with any framework. You can use it in any PHP project, the only requirement is composer. Here's the example:

Create search:

<?php

require 'vendor/autoload.php'; //Composer autoload

$client = ClientBuilder::create()->build(); //opensearch-php client

$matchAll = new OpenSearchDSL\Query\MatchAllQuery();

$search = new OpenSearchDSL\Search();
$search->addQuery($matchAll);

$params = [
'index' => 'your_index',
'body' => $search->toArray(),
];

$results = $client->search($params);

Opensearch DSL covers every Opensearch query, all examples can be found in the documentation