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.
OpenSearch version | OpenSearchDSL version |
---|---|
>= 1.0 | >= 1.0 |
>= 2.0 | >= 1.0 |
The online documentation of the bundle is here
Install library with composer:
$ composer require shyim/opensearch-php-dsl
elasticsearch-php client is defined in the composer requirements, no need to install it.
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