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
Copy file name to clipboardExpand all lines: Resources/doc/mapping.md
+33-18Lines changed: 33 additions & 18 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,6 +3,21 @@
3
3
Elasticsearch bundle requires mapping definitions for it to work with complex operations,
4
4
like insert and update documents, do a full-text search, etc.
5
5
6
+
### App mapping
7
+
8
+
In order for the app's classes to be mapped a fake bundle with the name `App` is added. This is not a perfect solution but was the easiest to implement and add support for it.
9
+
10
+
It requires a class in the project's source root folder.
11
+
12
+
By default, the `App\Kernel` class is used. This class can be changed to any other class by using the configuration:
13
+
14
+
```yaml
15
+
ongr_elasticsearch:
16
+
app_root_class: 'App\YourKernel'
17
+
```
18
+
19
+
The referenced class has to exist as it is used with various ReflectionClass instances to find their folder etc., but can otherwise be empty. If the class does not exist, no mappings for `App` can be configured.
20
+
6
21
### Mapping configuration
7
22
8
23
Here's an example of configuration containing the definitions of filter and analyzer:
@@ -29,7 +44,7 @@ ongr_elasticsearch:
29
44
hosts:
30
45
- 127.0.0.1:9200
31
46
mappings:
32
-
- AppBundle
47
+
- App
33
48
```
34
49
35
50
From 5.0 version mapping was enchased, and now you can change documents directory. See the example below:
@@ -43,7 +58,7 @@ From 5.0 version mapping was enchased, and now you can change documents director
43
58
hosts:
44
59
- 127.0.0.1:9200
45
60
mappings:
46
-
AppBundle: ~ #Document dir will be Document.
61
+
App: ~ #Document dir will be Document.
47
62
CustomBundle:
48
63
document_dir: Entity #For this bundle will search documents in the Entity.
49
64
@@ -53,7 +68,7 @@ From 5.0 version mapping was enchased, and now you can change documents director
53
68
hosts:
54
69
- 127.0.0.1:9200
55
70
mappings:
56
-
- AppBundle
71
+
- App
57
72
```
58
73
59
74
> Both mappings are valid. In the above example, you can change the directory for the particular
@@ -132,17 +147,17 @@ ongr_elasticsearch:
132
147
hosts:
133
148
- 127.0.0.1:9200
134
149
mappings:
135
-
- AppBundle
150
+
- App
136
151
```
137
152
138
153
### Document class annotations
139
154
140
155
Lets start with a document class example.
141
156
142
157
```php
143
-
// src/AppBundle/Document/Content.php
158
+
// src/App/Document/Content.php
144
159
145
-
namespace AppBundle\Document;
160
+
namespace App\Document;
146
161
147
162
use ONGR\ElasticsearchBundle\Annotation as ES;
148
163
@@ -204,8 +219,8 @@ Analyzers names must be defined in `config.yml` under the `analysis` node (read
204
219
Here's an example how to add it:
205
220
206
221
```php
207
-
// src/AppBundle/Document/Product.php
208
-
namespace AppBundle\Document;
222
+
// src/App/Document/Product.php
223
+
namespace App\Document;
209
224
210
225
use ONGR\ElasticsearchBundle\Annotation as ES;
211
226
@@ -238,9 +253,9 @@ To define a nested or object type you have to use `@ES\Embedded` annotation and
238
253
class for this annotation. Here's an example, lets assume we have a `Product` type with `Variant` object field.
0 commit comments