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.3
- elasticsearch/elasticsearch: ^9
- silverstripe/framework: ^6
- silverstripe/silverstripe-forager: ^2
Requires (Dev)
- phpunit/phpunit: ^11
- slevomat/coding-standard: ^8.8
Suggests
None
Provides
None
Conflicts
None
Replaces
None
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)aliasbinarybooleandatefloatgeo_pointintegerkeywordlongpointobjectnestedsemantic_textdense_vectorsearch_as_you_type
The following additional options are available:
fieldsformatignore_aboveignore_malformedindexmetapathpropertiesstoreterm_vectorsimilarityindex_optionsanalyzersearch_analyzernormalizerdimsscaling_factorinference_idsearch_inference_idchunking_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: