ykan / elastickit
Elasticsearch DSL query builder for PHP
v8.0.0-beta.1
2026-06-01 14:14 UTC
Requires
- php: ^8.1
- elasticsearch/elasticsearch: ^8.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.9
- phpmd/phpmd: ^2.15
- phpstan/phpstan: ^2.1
- phpunit/phpunit: ^10.5
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
License
MIT