somardigital / silverstripe-forager-elasticsearch
Elasticsearch Search Provider for Silverstripe Forager
Package info
github.com/somardigital/silverstripe-forager-elasticsearch
Type:silverstripe-vendormodule
pkg:composer/somardigital/silverstripe-forager-elasticsearch
Requires
- php: ^8.2
- elasticsearch/elasticsearch: ^8.18
- guzzlehttp/guzzle: ^7
- silverstripe/framework: ^6.1
- silverstripe/silverstripe-forager: ^2
Requires (Dev)
This package is auto-updated.
Last update: 2026-07-30 21:55:18 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
Activating Elasticsearch
To start using Elasticsearch, define environment variables containing your API key, endpoint, and variant.
ELASTIC_SEARCH_ENDPOINT="https://abc123.ap-southeast-2.aws.found.io"
ELASTIC_SEARCH_CLOUD_ID="xxx:abc123==" # Alternative to endpoint
ELASTIC_SEARCH_INDEX_PREFIX="dev"
ELASTIC_SEARCH_API_KEY="abc123"
ELASTIC_SEARCH_API_ID="xxx" # Only required if Api Key does not contain Api ID in base64 encodeed string
ELASTIC_SEARCH_DASHBOARD="https://abc123.ap-southeast-2.aws.found.io:9243"
Configuring Elasticsearch
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)aliasbinarybooleandatefloatgeo_pointintegerkeywordlongpointobjectnested
The following additional options are available:
fieldsformatignore_aboveignore_malformedindexmetapathpropertiesstoreterm_vector
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:
Credits
This module is based on the silverstripe-forager-elastic-enterprise module