Elasticsearch Index Feeder

The Elasticsearch Index Feeder module allows you to feed the Elasticsearch index with pre-defined data from Magnolia during publication events.

Prerequisites

In order to use this module, you’ll need to make sure you have the following as well:

Configuration

The Hooks API module only lets you register for one workspace. Because of this, we have to provide multiple configurations when multiple workspaces should be fed to Elasticsearch.

To do this, provide a light-module like this in your magnolia.resources.dir:

.
├── addElasticsearchIndexFeeders (1)
│   └── hooks (2)
│       ├── feedDamWorkspaceData.yaml
│       └── feedWebsiteWorkspaceData.yaml
1 Root light module level.
2 Notice the second level the hooks directory is at within the light module.

Configure the hook

Each hook can be configured as follows:

###################################### SPECIFY THE HOOK COMMAND #######################################
class: info.magnolia.indexfeeder.command.ElasticSearchIndexFeederCommandDefinition
description: Feeds the specified data below into the elastic search index.
catalog: elasticsearch
commandName: elasticsearchIndex
asynchronous: false # if true it will use asynchronous client

###################################### SPECIFY ELASTICSEARCH CONNECTION ##############################################
# Config appropriate information in case using cloud account
# https://www.elastic.co/guide/en/cloud-enterprise/2.0/ece-getting-started-connect.html
hostName: "localhost"
port: 9200
scheme: "http"

###################################### SPECIFY ELASTICSEARCH INDEX NAME #########################################
indexName: mgnl_elastic
useOneIndexPerWorkspace: true

###################################### SPECIFY WHEN TO FEED ##############################################
# https://docs.magnolia-cms.com/hooks-api/index.html#_hook_triggers
trigger:
  workspace: website
  actions:
    - PUBLISH
    - UNPUBLISH

###################################### SPECIFY THE CONTENT TO FEED #######################################
# Uncomment one of the blocks below and tailor it to your needs

############################################
# Wildcard approach:
############################################
# contentSelectionAttribute: "*"
# contentAttributesToPush:
#   "*":
#     - title
#     - description

############################################
# Selective approach:
############################################
# contentSelectionAttribute: "mgnl:template"
# contentAttributesToPush:
#   "mtk2:pages/basic":
#     - title
#     - description
#   "demo:foo/bar":
#     - foo
#     - bar

Usage

Elasticsearch Index Creation and Treatment

One Index per Workspace

  • One Index per Workspace

  • One Index for every webhook

useOneIndexPerWorkspace: true

If this setting was chosen, the indexName settings is suffixed with the workspace-name using this naming scheme: indexName + "_" + workspace.

To apply that for the example above, mgnl_elastic_website would be created in Elasticsearch.

useOneIndexPerWorkspace: false

If this setting was chosen, the indexName settings is used untouched.

Wildcard approach

Using the wildcard configuration approach, every content published in the specified workspace will be pushed to elasticsearch.

Try to make sure you define properties that every content has in common.

Selective approach

The selective approach allows you to filter out specific data from your content to push into elasticsearch.

contentSelectionAttribute: "mgnl:template"
contentAttributesToPush:
  "mtk2:pages/basic": (1)
    - title
    - description
1 Here, only pages of the website workspace based on the "mtk2:pages/basic"-template will be considered for elasticsearch feeding:
Feedback

DX Core

×

Location

This widget lets you know where you are on the docs site.

You are currently perusing through the Magnolia Search Index Feeder module docs.

Main doc sections

DX Core Headless PaaS Legacy Cloud Incubator modules