Download the PHP package glue-agency/craft-elasticsearch without Composer
On this page you can find all versions of the php package glue-agency/craft-elasticsearch. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download glue-agency/craft-elasticsearch
More information about glue-agency/craft-elasticsearch
Files in glue-agency/craft-elasticsearch
Package craft-elasticsearch
Short Description Index Craft Elements to Elasticsearch
License mit
Informations about the package craft-elasticsearch
Elasticsearch
Index Craft Elements to Elasticsearch
Requirements
This plugin requires Craft CMS 5.0.0 or later, and PHP 8.2 or later.
Installation
You can install this plugin from the Plugin Store or with Composer.
With Composer
Open your terminal and run the following commands:
Configuration
If you create a elasticsearch.php file in the config folder you can overwrite the following plugin settings. The config file supports multi env setup.
Extending the Plugin
You can easily add support for custom Craft Fields, or even entirely new Element Types (like Categories or Commerce Products).
Adding Support for Custom Element Types
By default, this plugin indexes Craft Entry elements. To add support for another Element Type (e.g., craft\elements\Category), you need to register four components via Yii2 events:
- Criteria: Tells the settings model how to match the element to an index (e.g. by section or entry type).
- Filter: Tells the element queries how to filter elements for this index, and whether a given element should be indexed or deleted. Implement
apply()to restrict queries, andshouldIndex()to gate indexing per element + index (e.g. based on configurable statuses). - Schema: Defines the Elasticsearch property mappings for the element.
- Mapper: Formats the element's data before sending it to Elasticsearch.
Here is an example of how a custom module or plugin can register support for Categories:
Adding Support for Custom Fields
If you are using a third-party Craft field type and want to map it to a specific Elasticsearch data type, you need to register a Property Mapper (defines the Elasticsearch schema type) and a Field Mapper (formats the value).
If you do not register a field mapper for a custom field, the plugin will gracefully fall back to calling $field->serializeValue() and assigning it a standard Elasticsearch text property.
All versions of craft-elasticsearch with dependencies
craftcms/cms Version ^5.0.0
elasticsearch/elasticsearch Version ^8.0
guzzlehttp/guzzle Version ^7.2.0
insolita/yii2-array-structure-validator Version ^2.0.0
illuminate/collections Version ^10.0||^11.0||^12.0