PHP code example of glue-agency / craft-elasticsearch
1. Go to this page and download the library: Download glue-agency/craft-elasticsearch library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
glue-agency / craft-elasticsearch example snippets
return [
/**
* Connection settings
*/
'endpoint' => 'https://your-endpoint.cloud.es.io',
'port' => '443',
/**
* Authentication
*
* Supported auth keys: "basic", "cloudId", "apiKey"
*
* Each auth key ge indexing and linked indexes.
* At least sections or entryTypes must be set.
*
* Available settings per index:
* sections - Limit to specific section handles (optional)
* entryTypes - Limit to specific entry type handles (optional)
* statuses - Limit to specific entry statuses (optional, defaults to ['live', 'pending'])
* fields - Limit which fields are indexed, supports wildcards and nested relations (optional, defaults to all fields)
*/
'indexes' => [
[
'name' => 'index-name',
'element' => \craft\elements\Entry::class,
'site' => 'site-handle',
'settings' => [
'sections' => ['section-handle-1', 'section-handle-2'],
'entryTypes' => ['entry-type-handle-1', 'entry-type-handle-2'],
'statuses' => ['live', 'pending'], // default, can be omitted
],
],
[
'name' => 'index-name',
'element' => \craft\elements\Entry::class,
'site' => 'site-handle',
'settings' => [
'sections' => ['section-handle-3'],
'entryTypes' => ['entry-type-handle-3'],
'statuses' => ['live'], // only index live entries for this index
],
],
],
];