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
- Added `document_dir`. From now on you can change documents directory for each mapped bundle.
12
17
- No more needed to define analysis in manager, it will be collected automatically from documents.
13
18
14
19
### Breaking changes
15
20
- Removed all deprecations from 1.x version.
21
+
- Removed `_ttl` metafield annotation.
16
22
- Service name `@annotations.cached_reader` changed to `@es.annotations.cached_reader`#717
17
23
- From Document annotation removed all properties except `type`. From now on everything has to be defined in the `options`.
18
-
-`string` property type was deprecated in elasticsearch 5.0, please use text or keyword accordingly.
24
+
-`string` property type was deprecated in elasticsearch 5.0, please use `text` or `keyword` accordingly.
19
25
More info: https://www.elastic.co/blog/strings-are-dead-long-live-strings
20
26
-`auth` in the configuration was removed. Use authentication information directly in host or create event listener
21
27
to modify client creation. There are too many ways to authenticate elasticsearch. That said we leaving this customisation to the user due difficult support.
22
28
-`connections` node in configuration was removed. Use `index` from now on. There was absolute
23
29
misunderstanding to have exposed connections, we never saw any benefits to use single connection
24
30
between several managers.
25
-
-`analysis` node in `index`/`connection` was deprecated. From now on used analyzers, filters and other
31
+
- Changed the namespace of the `DocumentParserException` to `ONGR\ElasticsearchBundle\Mapping\Exception`. #722
32
+
-`analysis` node in `index`/`connection` was deprecated. From now on used analyzers, filters, etc. must be provided in document annotations
26
33
-`Results` (constants container for result type definitions) class was removed in favor for
27
34
new find functions with predefined types in the names.
28
35
- Export service now uses own query calling instead of elasticsearch-php. It was changes due a bug
In addition manager provides repository access, which enables direct access to the elasticsearch type. Repositories represents a document. Whenever you need to do any action with a repository to get it:
47
+
In addition manager provides repository access, which enables direct access to the elasticsearch type.
48
+
Repository represents a document. Whenever you need to do any action with a repository, you can access
Will come with v1.1.0 version. Check [milestones](https://github.com/ongr-io/ElasticsearchBundle/milestones) to see a progress with the new versions releases.
Copy file name to clipboardExpand all lines: Resources/doc/results_parsing.md
+6-6Lines changed: 6 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -24,7 +24,7 @@ For all chapters below we will use a data example inserted in the elasticsearch
24
24
25
25
## Results iterator
26
26
27
-
Whenever any search action is performed and `Result::RESULTS_OBJECT` is selected as the result type the `DocumentIterator` will be returned. It has plenty of helper functions to aggregate more efficiently with the results.
27
+
Usually when any search action is performed the `DocumentIterator` will be returned. It has plenty of helper functions to aggregate more efficiently with the results.
28
28
29
29
30
30
Lets assume you search the index with:
@@ -34,7 +34,7 @@ Lets assume you search the index with:
34
34
$repo = $this->get('es.manager.default.content');
35
35
$search = $repo->createSearch();
36
36
$termQuery = new MatchAllQuery();
37
-
$results = $repo->execute($search, Result::RESULTS_OBJECT); // Result::RESULTS_OBJECT is the default value
37
+
$results = $repo->findDocuments($search);
38
38
39
39
```
40
40
@@ -68,7 +68,7 @@ cannot be associated with document. You can get document's score from results it
@@ -95,9 +95,9 @@ foreach ($results as $document) {
95
95
96
96
`DocumentIterator` doesn't cache or store generated document object. `Converter` directly returns the instance after it's requested and will generate again if it will be requested.
97
97
98
-
We highly recommend to `unset()` document instance after you dont need it or manage memory at your own way.
98
+
We highly recommend to `unset()` document instance after you don't need it or manage memory at your own way.
99
99
100
-
There is a possibility to change the `DocumentIterator` behaviour. Take a look at the [overwriting bundle parts](overwriting_bundle.md).
100
+
There is a possibility to change the `DocumentIterator` behaviour. Take a look at the [overwriting bundle parts](http://docs.ongr.io/ElasticsearchBundle/overwriting_bundle).
Copy file name to clipboardExpand all lines: Resources/doc/scan.md
+6-6Lines changed: 6 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,9 +4,9 @@ If the index is huge and in a single request there is not enough to get all reco
4
4
5
5
> More info about index scanning in [elastic official docs](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-scroll.html#scroll-scan)
6
6
7
-
You can scan index with any structured search and do a continious scroll. To execute that kind of search you only need to append a scroll time amount to a `Search` object.
7
+
You can scan index with any structured search and do a continuous scroll. To execute that kind of search you only need to append a scroll time amount to a `Search` object.
8
8
9
-
> Scan & Scroll doesn't work if the result type is `Repository:RESULTS_ARRAY`.
9
+
> Scan & Scroll doesn't work for `Repository::findArray()` method.
10
10
11
11
Here's an example with scrolling:
12
12
@@ -20,7 +20,7 @@ $search->setScroll('10m'); // Scroll time
20
20
$termQuery = new TermQuery('country', 'Lithuania');
21
21
$search->addQuery($termQuery);
22
22
23
-
$results = $repo->execute($search);
23
+
$results = $repo->findDocuments($search);
24
24
25
25
foreach ($results as $document) {
26
26
@@ -32,7 +32,7 @@ foreach ($results as $document) {
32
32
33
33
Usually result amount will be 10 (if no size set), but if the result type is any iterator, it will do a next request when the results set limit is reached and will continue results scrolling in foreach cycle. You dont have to worry about any scroll ids and how to perform second request, everything is handled automatically.
34
34
35
-
If you are using `Repository:RESULTS_RAW`, then bundle won't request next iteration and you should do it by yourself. Here's an example how to do it:
35
+
If you are using `findRaw()` method, then bundle won't request next iteration and you should do it by yourself. Here's an example how to do it:
36
36
37
37
38
38
```php
@@ -45,14 +45,14 @@ $search->setScroll('10m'); // Scroll time
45
45
$termQuery = new TermQuery('country', 'Lithuania');
Copy file name to clipboardExpand all lines: Resources/doc/search.md
+30-13Lines changed: 30 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,11 +2,24 @@
2
2
3
3
## Structured search with DSL
4
4
5
-
If find functions are not enough, there is a possibility to perform a structured search using [query builder](https://github.com/ongr-io/ElasticsearchDSL). In a nutshell you can do any query or filter that is defined in [Elasticsearch Query DSL documentation](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl.html).
5
+
If find functions are not enough, there is a possibility to perform a structured search using [query builder](https://github.com/ongr-io/ElasticsearchDSL). In a nutshell you can construct any queries, aggregations, etc. that are defined in [Elasticsearch Query DSL documentation](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl.html).
6
6
7
-
To begin with structured search you will need a `Search` object.
7
+
To begin with structured search you will need a `Search` object. You need to add all the queries and other DSL constructs
8
+
to this search object and then perform the search from the repository service. There are three specialized `find` methods
9
+
dedicated for this task and you may choose between depending on your needs:
8
10
9
-
e.g. We want to search for cities in Lithuania with more than 10K population
|`findDocuments()`| Returns an instance of `DocumentIterator`|
14
+
|`findArray()`| Returns an instance of `ArrayIterator`|
15
+
|`findRaw()`| Returns an array of raw results with unaltered elasticsearch response structure |
16
+
17
+
For the majority of cases, you will be using `findDocuments` that returns an iterator with hydrated documents. In addition
18
+
it provides a convenient way of handling aggregations, that can be accessed via `getAggregations()` method.
19
+
20
+
### Simple Example
21
+
22
+
In this example we will search for cities in Lithuania with more than 10K population
10
23
11
24
```php
12
25
@@ -19,7 +32,7 @@ $search->addQuery($termQuery);
19
32
$rangeQuery = new RangeQuery('population', ['from' => 10000]);
20
33
$search->addQuery($rangeQuery);
21
34
22
-
$results = $repo->execute($search);
35
+
$results = $repo->findDocuments($search);
23
36
24
37
```
25
38
@@ -54,7 +67,8 @@ It will construct a query:
54
67
55
68
> Important: by default result size in elasticsearch is 10, if you need more set size to your needs.
56
69
57
-
Setting size or offset is to the search is very easy, because it has getters and setters for these attributes. Therefore to set size all you need to do is to write
70
+
Setting size or offset is to the search is very easy, because it has getters and setters for these attributes.
71
+
Therefore to set size all you need to do is to write
58
72
59
73
```php
60
74
@@ -66,14 +80,17 @@ Similarly other properties like Scroll, Timeout, MinScore and more can be define
66
80
67
81
For more query and filter examples take a look at the [Elasticsearch DSL library docs](https://github.com/ongr-io/ElasticsearchDSL/blob/master/docs/index.md). We covered all examples that we found in [Elasticsearch Query DSL documentation](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl.html) how to cover in object oriented way.
68
82
69
-
> The results parsing is the same like in the find functions.
70
-
71
83
## Searching in Multiple Types
72
84
73
-
Previous section showed how to search in single type using repository. In some
74
-
cases you might need to search multiple types at once. In order to do that you
75
-
can use manager's `execute()` method (actually repository's `execute()` is just
76
-
a proxy for this method).
85
+
Previous example illustrated the usual case scenario of performing a search in a single type.
86
+
However if you should ever find yourself in a rear situation where a search needs to be performed
87
+
on several types at once, you can use a specific `search` method in manager, that accepts an
88
+
array with the names of types on which the search needs to be performed.
89
+
90
+
However, unlike some of the `find` functions in repository this method returns only the raw results,
91
+
therefore the use of this method should be minimal and only when needed.
92
+
93
+
### Example of searching in multiple types
77
94
78
95
Lets say you have `City` and `State` documents with `title` field. Search all
0 commit comments