Skip to content

Commit 1adecec

Browse files
einorlersaimaz
authored andcommitted
Updated the documentation (#213)
* updated the readme * copied the release info to changelog * updated the how to section on filters * updated the regexp queery docs: changed filter to query
1 parent d646f45 commit 1adecec

File tree

4 files changed

+55
-85
lines changed

4 files changed

+55
-85
lines changed

CHANGELOG.md

+8-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
# CHANGELOG
22
v5.0.0 (2017-x)
33
---
4-
- **[BC break]** Removed deprecated aggregation classes.
5-
- **[BC break]** Removed deprecated query classes.
6-
- **[BC break]** `Search::getQueryParams()` changed to `Search::getUriParams()`.
7-
- **[BC break]** `FilterEndpoint` was removed due deprecated filters.
4+
- **Namespace for some queries were changed**. Queries were consolidated to a domain like Elasticsearch does. All queries were grouped to `Compound`, `FullText`, `Geo`, `Joining`, `Span`, `Specialized` and `TermLevel`.
5+
- PHP version support changed to >=5.6
6+
- Added `elasticsearch\elasticsearch` to required dependency list in the composer.json.
7+
- Deprecated aggregations removed. Check if the namespace is correct. All aggregations grouped to `Bucketing`, `Metric` and `Pipeline` namespaces.
8+
- `Search::getQueryParams()` changed to `Search::getUriParams()`. All setter's for request URI parameters removed in favor of `uriParams` container. You can add URI parameters by `addUriParam`, and this function also has validation.
9+
- `Search::setFields()` and `Search::getFields()` were changed to `Search::setStoredFields()` and `Search::getStoredFields()`.
10+
- `FilterEndpoint` was removed due to deprecated filters in elasticsearch.
11+
- Added missing scroll param to URL params (#202)
812

913
v2.2.1 (2017-01-26)
1014
---

README.md

+14-10
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,15 @@ is the preffered and recommended way to ask ONGR support questions.
1515

1616
| Elasticsearch version | ElasticsearchDSL version |
1717
| --------------------- | --------------------------- |
18-
| >= 5.0 | >= 5.0 |
19-
| >= 2.0, < 5.0 | >= 2.0 |
18+
| >= 5.0 | >= 5.0 |
19+
| >= 2.0, < 5.0 | >= 2.0, < 5.0 |
2020
| >= 1.0, < 2.0 | 1.x |
21-
| <= 0.90.x | not supported |
21+
| <= 0.90.x | 0.x |
2222

2323
## Documentation
2424

25-
[The online documentation of the bundle is here](docs/index.md)
25+
The latest library online documentation of the bundle [is here](http://docs.ongr.io/ElasticsearchDSL). If you need 2.x
26+
docs you can find it in [the github branch here](https://github.com/ongr-io/ElasticsearchDSL/tree/2.x/docs).
2627

2728
## Try it!
2829

@@ -34,24 +35,27 @@ Install library with [composer](https://getcomposer.org):
3435
$ composer require ongr/elasticsearch-dsl
3536
```
3637

38+
> [elasticsearch-php](https://github.com/elastic/elasticsearch-php) client is defined in the composer requirements, no need to install it.
39+
3740
### Search
3841

3942
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).
4043

4144
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:
4245

43-
Install `elasticsearch-php`:
46+
If you are using Symfony there is also the [ElasticsearchBundle](https://github.com/ongr-io/ElasticsearchBundle)
47+
which provides full integration with Elasticsearch DSL.
4448

45-
```bash
46-
$ composer require elasticsearch/elasticsearch
47-
```
49+
The library is standalone and is not coupled with any framework. You can use it in any PHP project, the only
50+
requirement is composer. Here's the example:
4851

4952
Create search:
5053

5154
```php
5255
<?php
53-
require 'vendor/autoload.php';
54-
$client = ClientBuilder::create()->build();
56+
require 'vendor/autoload.php'; //Composer autoload
57+
58+
$client = ClientBuilder::create()->build(); //elasticsearch-php client
5559

5660
$matchAll = new ONGR\ElasticsearchDSL\Query\MatchAllQuery();
5761

docs/HowTo/HowToSearch.md

+32-70
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ $search = new Search();
1010

1111
> We won't include namespaces in any examples. Don't worry all class's names are unique, so any IDE editor should autocomplete and include it for you ;).
1212
13-
So, when we have a `Search` object we can start add something to it. Usually you will add `Query`, `Filter` and `Aggregation`.
13+
So, when we have a `Search` object we can start adding something to it. Usually you will add `Query` and `Aggregation`.
1414

1515
> More info how create [queries](../Query/index.md) and [aggregations](../Aggregation/index.md) objects.
1616
@@ -43,32 +43,40 @@ At the end it will form this query:
4343
4444
### Form a Filter
4545

46-
Since Elasticsearch 2.0 all filters were replaced by queries. Queries acts like
47-
filters when you use them in filter context.
48-
49-
To add a filter is the same way like a query. First, lets create some `Filter` object.
50-
46+
Since Elasticsearch 5.0 the support for top level filters was dropped. The same functionality
47+
is now supported via `BoolQuery`. Adding a filter to the bool query is done like so:
48+
5149
```php
52-
$matchAllQuery = new MatchAllQuery();
53-
```
54-
55-
And simply add to the `Search`:
50+
$search = new Search();
51+
$boolQuery = new BoolQuery();
52+
$boolQuery->add(new MatchAllQuery());
53+
$geoQuery = new TermQuery('field', 'value');
54+
$boolQuery->add($geoQuery, BoolQuery::FILTER);
55+
$search->addQuery($boolQuery);
5656

57-
```php
58-
$search->addFilter($matchAllQuery);
57+
$search->toArray();
5958
```
6059

61-
Unlike `Query`, when we add a `Filter` with our DSL library it will add a query and all necessary stuff for you. So when we add one filter we will get this query:
60+
This will result in
6261

63-
```JSON
62+
```
6463
{
65-
"query": {
66-
"bool": {
67-
"filter": {
68-
"match_all": {}
69-
}
70-
}
71-
}
64+
"query": {
65+
"bool": {
66+
"must": [
67+
{
68+
"match_all": {}
69+
}
70+
],
71+
"filter": [
72+
{
73+
"term": {
74+
"field": "value"
75+
}
76+
}
77+
]
78+
}
79+
}
7280
}
7381
```
7482

@@ -113,63 +121,17 @@ The query will look like:
113121
```
114122
> More info how to form bool queries find in [Bool Query](../Query/Bool.md) chapter.
115123
116-
The same way it works with a `Filter`. Take a look at this example:
117-
118-
```php
119-
$search = new Search();
120-
$termFilter = new TermQuery('name', 'ongr');
121-
$missingFilter = new MissingQuery('disabled');
122-
$existsFilter = new ExistsQuery('tag');
123-
$search->addFilter($termFilter);
124-
$search->addFilter($missingFilter);
125-
$search->addFilter($existsFilter, BoolQuery::MUST_NOT);
126-
```
127-
128-
Elasticsearch DSL will form this query:
129-
130-
```JSON
131-
{
132-
"query": {
133-
"bool": {
134-
"filter": {
135-
"bool": {
136-
"must": [
137-
{
138-
"term": {
139-
"name": "ongr"
140-
}
141-
},
142-
{
143-
"missing": {
144-
"field": "disabled"
145-
}
146-
}
147-
],
148-
"must_not": [
149-
{
150-
"exists": {
151-
"field": "tag"
152-
}
153-
}
154-
]
155-
}
156-
}
157-
}
158-
}
159-
}
160-
```
161-
162124
### Modify queries
163125

164126

165127

166128

167129
### Sent request to the elasticsearch
168-
And finaly we can pass it to `elasticsearch-php` client. To generate an array for the client we call `toArray()` function.
130+
And finally we can pass it to `elasticsearch-php` client. To generate an array for the client we call `toArray()` function.
169131

170132
```php
171133
//from elasticsearch/elasticsearch package
172-
$client = new Elasticsearch\Client();
134+
$client = ClientBuilder::create()->build();
173135

174136
$searchParams = [
175137
'index' => 'people',
@@ -180,4 +142,4 @@ $searchParams = [
180142
$docs = $client->search($searchParams);
181143
```
182144

183-
> This example is for elasticsearch/elasticsearch ~1.0 version.
145+
> This example is for elasticsearch/elasticsearch ~5.0 version.

docs/Query/TermLevel/Regexp.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ The regexp query allows you to use regular expression term queries.
88

99
```JSON
1010
{
11-
"filter": {
11+
"query": {
1212
"regexp":{
1313
"name.first" : "s.*y"
1414
}

0 commit comments

Comments
 (0)