glue-agency / craft-elastic-app-search
Index Craft Entries to Elastic App Search
Installs: 88
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 4
Forks: 0
Open Issues: 0
Type:craft-plugin
Requires
- php: >=8.0.2
- craftcms/cms: ^4.0.0
- elastic/enterprise-search: ^8.0
- guzzlehttp/guzzle: ^7.2.0
- insolita/yii2-array-structure-validator: ^2.0.0
README
Index Craft Entries to Elastic App Search
Requirements
This plugin requires Craft CMS 4.0.0 or later, and PHP 8.0.2 or later.
Installation
You can install this plugin from the Plugin Store or with Composer.
From the Plugin Store
Go to the Plugin Store in your project’s Control Panel and search for “Elastic App Search”. Then press “Install”.
With Composer
Open your terminal and run the following commands:
# go to the project directory cd /path/to/my-project.test # tell Composer to load the plugin composer require glue-agency/craft-elastic-app-search # tell Craft to install the plugin ./craft plugin/install elastic-app-search
Usage
Backend
WIP
Frontend
Install the elasticsearch @elastic/app-search-javascript
package.
The ElasticAppSearch Plugin config elastic-app-search.php
has a setting exposeJsVars
. When this is set to true
,
you are able to access the searchKey
endpointBase
and engineName
that are needed to setup the Elastic Client.
Setup the Client
ElasticAppSearch.createClient({ searchKey: window.elasticAppSearch.searchKey, endpointBase: window.elasticAppSearch.endpointBase, engineName: window.elasticAppSearch.engineName });
Configuration
If you create a elastic-app-search.php
file in the config
folder you can overwrite the following plugin settings. The config file supports multi env setup.
<?php return [ /** * Connection settings */ 'endpoint' => 'https://your-endpoint.found.io', 'port' => '9200', /** * Authentication * * Supported auth keys: "basic", "apiKey", "token" * * Each auth key requires different settings: * basic: "username", "password" * apiKey: "apiKey" * token: "token" */ 'auth' => 'apiKey', 'apiKey' => 'private-xxxxxxxxxxxxxxxxxxxx', /** * Search */ 'searchKey' => 'search-xxxxxxxxxxxxxxxxxxxx', /** * Sites * * Manage Site indexing and linked indexes. Always requires * the "enabled" and "index" key for each indexable site. * Missing sites will not be indexed. */ 'sites' => [ 'site_nl' => [ 'enabled' => true, 'index' => 'site_index_nl', ], 'site_en' => [ 'enabled' => true, 'index' => 'site_index_en', ], ], ];