|
8 | 8 |
|
9 | 9 | Introducing Elasticsearch DSL library to provide objective query builder for [Elasticsearch bundle](https://github.com/ongr-io/ElasticsearchBundle) and [elasticsearch-php](https://github.com/elastic/elasticsearch-php) client. You can easily build any Elasticsearch query and transform it to an array. |
10 | 10 |
|
11 | | -If you have any questions, don't hesitate to ask them on [Gitter](https://gitter.im/ongr-io/support) chat, or just come to say Hi ;). |
| 11 | +If you have any questions, don't hesitate to ask them on [](https://gitter.im/ongr-io/support) chat, or just come to say Hi ;). |
| 12 | + |
| 13 | +## Documentation |
| 14 | + |
| 15 | +[The online documentation of the bundle is here](docs/index.md) |
| 16 | + |
| 17 | +## Try it! |
| 18 | + |
| 19 | +### Installation |
| 20 | + |
| 21 | +Install library with [composer](https://getcomposer.org): |
| 22 | + |
| 23 | +``` |
| 24 | +composer require ongr/elasticsearch-dsl "~1.0" |
| 25 | +``` |
| 26 | + |
| 27 | +### Search |
| 28 | + |
| 29 | +Elasticsearch DSL was extracted from [Elasticsearch Bundle](https://github.com/ongr-io/ElasticsearchBundle) to provide standalone query dsl for [elasticsearch-php](https://github.com/elastic/elasticsearch-php). Examples how to use it together with [Elasticsearch Bundle](https://github.com/ongr-io/ElasticsearchBundle) can be found in the [Elasticsearch Bundle docs](https://github.com/ongr-io/ElasticsearchBundle/blob/master/Resources/doc/search.md). |
| 30 | + |
| 31 | +If you dont want to use Symfony or Elasticsearch bundle, no worries, you can use it in any project together with [elasticsearch-php](https://github.com/elastic/elasticsearch-php). Here's the example: |
| 32 | + |
| 33 | +Install `elasticsearch-php`: |
| 34 | + |
| 35 | +``` |
| 36 | +composer require "elasticsearch/elasticsearch": "~2.0" |
| 37 | +``` |
| 38 | + |
| 39 | +Create search: |
| 40 | + |
| 41 | +```php |
| 42 | + <?php |
| 43 | + require 'vendor/autoload.php'; |
| 44 | + $client = ClientBuilder::create()->build(); |
| 45 | + |
| 46 | + $matchAll = new ONGR\ElasticsearchDSL\Query\MatchAllQuery(); |
| 47 | + |
| 48 | + $search = new ONGR\ElasticsearchDSL\Search(); |
| 49 | + $search->addQuery($matchAll) |
| 50 | + |
| 51 | + $params = [ |
| 52 | + 'index' => 'your_index', |
| 53 | + 'body' => $search->toArray(), |
| 54 | + ]; |
| 55 | + |
| 56 | + $results = $client->search($params); |
| 57 | +``` |
| 58 | + |
| 59 | +Elasticsearch DSL covers every elasticsearch query, all examples can be found in [the documentation](docs/index.md) |
0 commit comments