Skip to content

shyim/opensearch-php-dsl

 
 

Repository files navigation

OpenSearch DSL

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

About

Query DSL library for OpenSearch and Elasticsearch

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 100.0%