gbourgeat / elasticsearch-dsl
Elasticsearch DSL 库
此包的官方仓库似乎已消失,因此该包已被冻结。
Requires
- php: ^7.0
- paragonie/random_compat: ^1.0|^2.0
- symfony/serializer: ^3.0|^4.0
Requires (Dev)
- elasticsearch/elasticsearch: ^6.0
- phpunit/phpunit: ^6.0
- satooshi/php-coveralls: ~1.0|~2.0
- squizlabs/php_codesniffer: ^3.0
Suggests
- elasticsearch/elasticsearch: This library is for elasticsearch/elasticsearch client to enhance it with DSL functionality.
This package is not auto-updated.
Last update: 2022-12-16 12:25:15 UTC
README
介绍 Elasticsearch DSL 库,为 Elasticsearch Bundle 和 elasticsearch-php 客户端提供目标查询构建器。您可以轻松构建任何 Elasticsearch 查询并将其转换为数组。
如果您需要任何帮助,请在 Stack Overflow 上提问,这是首选和推荐的方式询问 ONGR 支持。
版本矩阵
| Elasticsearch 版本 | ElasticsearchDSL 版本 |
|---|---|
| >= 6.0 | >= 6.0 |
| >= 5.0, < 6.0 | >= 5.0 |
| >= 2.0, < 5.0 | >= 2.0 |
| >= 1.0, < 2.0 | 1.x |
| <= 0.90.x | 不支持 |
文档
试试看!
安装
使用 composer 安装库
$ composer require ongr/elasticsearch-dsl
elasticsearch-php 客户端已定义在 composer 要求中,无需安装。
搜索
Elasticsearch DSL 从 Elasticsearch Bundle 中提取出来,为 elasticsearch-php 提供独立查询 DSL。有关如何与 Elasticsearch Bundle 一起使用的示例,请参阅 Elasticsearch Bundle 文档。
如果您不想使用 Symfony 或 Elasticsearch Bundle,也不要担心,您可以在任何项目中与 elasticsearch-php 一起使用它。以下是示例
如果您正在使用 Symfony,还有 ElasticsearchBundle,它提供了与 Elasticsearch DSL 的完全集成。
该库是独立的,没有与任何框架耦合。您可以在任何 PHP 项目中使用它,唯一的要求是 composer。以下是示例
创建搜索
<?php require 'vendor/autoload.php'; //Composer autoload $client = ClientBuilder::create()->build(); //elasticsearch-php client $matchAll = new ONGR\ElasticsearchDSL\Query\MatchAllQuery(); $search = new ONGR\ElasticsearchDSL\Search(); $search->addQuery($matchAll); $params = [ 'index' => 'your_index', 'body' => $search->toArray(), ]; $results = $client->search($params);
Elasticsearch DSL 覆盖了每个 Elasticsearch 查询,所有示例都可以在 文档 中找到