Search by

somardigital / silverstripe-forager-elasticsearch

somardesignstudios

Elasticsearch Search Provider for Silverstripe Forager

Package info

github.com/somardigital/silverstripe-forager-elasticsearch

Type:silverstripe-vendormodule

pkg:composer/somardigital/silverstripe-forager-elasticsearch

Statistics

Installs: 8

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

3.0.0 2026-09-23 01:20 UTC

This package is auto-updated.

Last update: 2026-09-23 01:22:09 UTC


README

This module provides the ability to index content for an Elasticsearch engine using Elastic's Elasticsearch PHP library.

Elasticsearch provider for Silverstripe Forager.

This module does not provide any method for performing searches on your engines - we've added some suggestions though.

Installation

composer require somardigital/silverstripe-forager-elasticsearch

Configuration

Set an API key and either an endpoint or Elastic Cloud ID:

ELASTIC_SEARCH_ENDPOINT="https://abc123.ap-southeast-2.aws.found.io"
ELASTIC_SEARCH_CLOUD_ID="xxx:abc123==" # Alternative to ELASTIC_SEARCH_ENDPOINT
ELASTIC_SEARCH_API_KEY="abc123"
ELASTIC_SEARCH_API_ID="xxx" # Only required if API Key does not contain API ID in base64 encoded string
ELASTIC_SEARCH_DASHBOARD="https://abc123.ap-southeast-2.aws.found.io:9243"
ELASTIC_SEARCH_INDEX_PREFIX="dev"

ELASTIC_SEARCH_INDEX_PREFIX is optional. If set, Forager indexes suffixes are prefixed as <prefix>-<suffix>.

Usage

The most notable configuration surface for Elasticsearch is the schema, which determines how data is stored in your Elasticsearch index (engine). There are the following types of data currently configured in this module:

  • text (default)
  • alias
  • binary
  • boolean
  • date
  • float
  • geo_point
  • integer
  • keyword
  • long
  • point
  • object
  • nested
  • semantic_text
  • dense_vector
  • search_as_you_type

The following additional options are available:

  • fields
  • format
  • ignore_above
  • ignore_malformed
  • index
  • meta
  • path
  • properties
  • store
  • term_vector
  • similarity
  • index_options
  • analyzer
  • search_analyzer
  • normalizer
  • dims
  • scaling_factor
  • inference_id
  • search_inference_id
  • chunking_settings

You can specify these data types in the options node of your fields.

SilverStripe\Forager\Service\IndexConfiguration:
  indexes:
    myindex:
      includeClasses:
        SilverStripe\CMS\Model\SiteTree:
          fields:
            title: true
            summary_field:
              property: SummaryField
              options:
                type: text
          settings:

Note: Be careful about whimsically changing your schema. Elasticsearch may need to be fully reindexed if you change the name of a field. Fields cannot be deleted so re-naming one will leave any previously created fields around.

Indexing File Content

The silverstripe-text-extraction module is the recommended approach for fetching the content of files to index. Once configured, you can use the getFileContent method on a file to get the content.

SilverStripe\Forager\Service\IndexConfiguration:
  indexes:
    myindex:
      includeClasses:
        SilverStripe\CMS\Model\SiteTree:
          fields:
            pdf_example:
              property: PdfExample.FileContent
              options:
                type: text

Additional documentation

Majority of documentation is provided by the Silverstripe Forager module. A couple in particular that might be useful to you are:

Searching

Support for searching is provided through the discoverer module:

Credits

This module has taken inspiration from the following modules: