ykan/elastickit

Elasticsearch DSL query builder for PHP

Maintainers

Package info

github.com/ykan821/ElasticKit

pkg:composer/ykan/elastickit

Statistics

Installs: 5

Dependents: 0

Suggesters: 0

Stars: 4

Open Issues: 0

v8.0.0-beta.1 2026-06-01 14:14 UTC

This package is auto-updated.

Last update: 2026-06-01 15:12:09 UTC


README

A PHP library for building Elasticsearch DSL queries and managing indices.

PHP Elasticsearch DSL 查询构建和索引管理库。

Requirements

  • PHP 8.1+
  • Elasticsearch 8.x

Installation

composer require ykan/elastickit:^8

Quick Start

use ElasticKit\Index\Index;

// Setup
$client = \Elastic\Elasticsearch\ClientBuilder::create()->setHosts(['http://localhost:9200'])->build();
Index::setClient($client);
// Define index
class ProductIndex extends Index
{
    protected $name = 'products';
    protected $mappings = [
        'properties' => [
            'title'  => ['type' => 'text'],
            'price'  => ['type' => 'float'],
            'status' => ['type' => 'keyword'],
        ],
    ];
}
// Search
$results = ProductIndex::query()
    ->match('title', 'elasticsearch')
    ->sort('price', 'asc')
    ->size(20)
    ->get();

$results->total();   // hit count
$results->docs();    // _source array

// CRUD
ProductIndex::doc(1)->create(['title' => 'New Product', 'price' => 29.99]);
ProductIndex::doc(1)->update(['price' => 39.99]);
ProductIndex::doc(1)->delete();

📚 Documents

  • DSL — Query building, aggregations, parameters
  • Index — Search, CRUD, bulk, rebuild, events

License

MIT