You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* 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
-**[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.
[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).
26
27
27
28
## Try it!
28
29
@@ -34,24 +35,27 @@ Install library with [composer](https://getcomposer.org):
34
35
$ composer require ongr/elasticsearch-dsl
35
36
```
36
37
38
+
> [elasticsearch-php](https://github.com/elastic/elasticsearch-php) client is defined in the composer requirements, no need to install it.
39
+
37
40
### Search
38
41
39
42
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).
40
43
41
44
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:
42
45
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.
44
48
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
Copy file name to clipboardexpand all lines: docs/HowTo/HowToSearch.md
+32-70
Original file line number
Diff line number
Diff line change
@@ -10,7 +10,7 @@ $search = new Search();
10
10
11
11
> 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 ;).
12
12
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`.
14
14
15
15
> More info how create [queries](../Query/index.md) and [aggregations](../Aggregation/index.md) objects.
16
16
@@ -43,32 +43,40 @@ At the end it will form this query:
43
43
44
44
### Form a Filter
45
45
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
+
51
49
```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);
56
56
57
-
```php
58
-
$search->addFilter($matchAllQuery);
57
+
$search->toArray();
59
58
```
60
59
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
62
61
63
-
```JSON
62
+
```
64
63
{
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
+
}
72
80
}
73
81
```
74
82
@@ -113,63 +121,17 @@ The query will look like:
113
121
```
114
122
> More info how to form bool queries find in [Bool Query](../Query/Bool.md) chapter.
115
123
116
-
The same way it works with a `Filter`. Take a look at this example:
0 commit comments