fork/craft-elastica

A plugin to connect to Elasticsearch and persist elements via hooks

Installs: 602

Dependents: 0

Suggesters: 0

Security: 0

Stars: 5

Watchers: 8

Forks: 0

Type:craft-plugin

1.0.2.2 2022-02-04 14:48 UTC

This package is auto-updated.

Last update: 2024-04-05 17:11:41 UTC


README

68747470733a2f2f6769746875622e666f726b2e64652f4372616674456c6173746963615f3231303130362e737667

Table of contents

Features

  • Index entries and other elements in Elasticsearch
  • Customize Index data structures via hooks
  • Define Index Templates to configure the Index and its fields and mapping in Elasticsearch
  • Re-Index contents via utility or console command

Requirements

  • Craft CMS >= 3.5.x

Setup

1. Install

Install the package

cd /path/to/project
composer require fork/craft-elastica

2. Configuration

Go to the plugin settings page and enter a index prefix name which is prepended to the indexes beeing created in Elasticsearch. The name of the index is generated from this prefix. Also provide the hostname of the elasticsearch instance.

Usage

To generate the data to index register event handlers in your own module or plugin class like this:

// initialize elasticsearch indexer
Event::on(
   Indexer::class,
   Indexer::EVENT_INDEXER_INIT,
   function (IndexerInitEvent $event) {
       $event->addSectionHandles([
           'articles',
       ]);
   }
);
// build elasticsearch index data
Event::on(
   Indexer::class,
   Indexer::EVENT_BEFORE_INDEX_DATA,
   function (IndexEvent $event) {
       // build your custom data structure to index
       $indexData = MyCustomPlugin::$plugin->mySearchService->getIndexData($event->entry);
       $event->indexData = $indexData;
   }
);

Roadmap

  • Logo
  • Index categories
  • Maybe include search proxy
  • Exclude sites via settings
  • Show index info / test index in utility
  • More documentation
Fork Logo

Brought to you by Fork Unstable Media GmbH