shyim/opensearch-php-dsl

OpenSearch/Elasticsearch DSL library

1.1.0 2024-09-16 10:12 UTC

This package is auto-updated.

Last update: 2024-10-16 10:24:23 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.

Test codecov Latest Stable Version Total Downloads

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