shyim / opensearch-php-dsl
OpenSearch/Elasticsearch DSL library
Installs: 2 126 543
Dependents: 8
Suggesters: 0
Security: 0
Stars: 13
Watchers: 3
Forks: 201
Open Issues: 0
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
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
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