This documentation is for a version that has reached its End Of Life. Such versions are no longer supported and don't receive security updates. Consider updating to a newer version.
Index custom Elasticsearch data¶
Elasticsearch indexes content and location data out of the box. Besides what is indexed automatically, you can add additional data to the Elasticsearch index.
To do so, subscribe to one of the following events:
Ibexa\Contracts\ElasticSearchEngine\Mapping\Event\ContentIndexCreateEvent
Ibexa\Contracts\ElasticSearchEngine\Mapping\Event\LocationIndexCreateEvent
These events are called when the index is created for the content and location documents.
You can pass the event to a subscriber which gives you access to the document that you can modify.
In the following example, when an index in created for a content or a location document, the event subscriber adds a custom_field
of the type StringField
to the index:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
|
Remember to register the subscriber as a service:
1 2 3 4 |
|