Skip to content
 
 

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

  • User Guide - Comprehensive guide with examples for building queries, aggregations, sorting, and more
  • API Documentation - Detailed reference documentation

Quick Start

Installation

Install library with composer:

composer require shyim/opensearch-php-dsl

Note: This library does not require elasticsearch/elasticsearch or opensearch-project/opensearch-php. It is a standalone query builder that generates arrays compatible with any OpenSearch client.

Basic Example

<?php

require 'vendor/autoload.php';

use OpenSearchDSL\Search;
use OpenSearchDSL\Query\MatchAllQuery;

$search = new Search();
$search->addQuery(new MatchAllQuery());

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

// Use with opensearch-php client
$client = \OpenSearch\ClientBuilder::create()->build();
$results = $client->search($params);

Features

  • Query Building: Support for all OpenSearch query types (match, term, range, bool, geo, etc.)
  • Aggregations: Bucket, metric, and pipeline aggregations
  • Sorting: Field sorting with multiple criteria
  • Highlighting: Search result highlighting
  • Suggestions: Term, phrase, and completion suggesters
  • Framework Agnostic: Works with any HTTP client or OpenSearch client library

For detailed examples and usage instructions, see the User Guide.

About

Query DSL library for OpenSearch and Elasticsearch

Resources

Stars

18 stars

Watchers

2 watching

Forks

Releases

Packages

Used by

Contributors

Languages