obj63mc / silverstripe-forager-elasticsearch
Elasticsearch provider for silverstripe/silverstripe-forager, using the official Elasticsearch PHP client.
Package info
github.com/obj63mc/silverstripe-forager-elasticsearch
Type:silverstripe-vendormodule
pkg:composer/obj63mc/silverstripe-forager-elasticsearch
Requires
- php: ^8.3
- elasticsearch/elasticsearch: ^9.2
- silverstripe/framework: ^6
- silverstripe/silverstripe-forager: ^2.0
Requires (Dev)
None
Suggests
- silverstripe/silverstripe-forager-fluent: One index per locale when using tractorcow/silverstripe-fluent
Provides
None
Conflicts
None
Replaces
None
README
An Elasticsearch provider for silverstripe/silverstripe-forager, built on the official Elasticsearch PHP client.
It replaces silverstripe-forager-elastic-enterprise, whose App Search / Enterprise Search backend has been retired by Elastic, and talks to plain Elasticsearch indexes instead. It works with Elastic Cloud (hosted and serverless) and self-managed clusters.
Requirements
- PHP ^8.3
- Silverstripe ^6
- silverstripe/silverstripe-forager ^2
- elasticsearch/elasticsearch ^9.2
Forager and the Elasticsearch client are installed with this module.
Installation
composer require obj63mc/silverstripe-forager-elasticsearch
Add the endpoint and an API key which can manage and write to your indexes to the environment:
ELASTICSEARCH_ENDPOINT="https://my-project.es.eu-central-1.aws.elastic.cloud:443" ELASTICSEARCH_APIKEY="..."
The module only registers itself as the Forager indexing service when ELASTICSEARCH_ENDPOINT is set, so
environments without it keep Forager's default (which does nothing).
Quick start
-
Describe your indexes with the usual Forager configuration:
SilverStripe\Forager\Service\IndexConfiguration: indexes: main: includeClasses: Page: fields: title: true content: true summary: property: MetaDescription published: property: LastEdited options: type: date
-
Flush, then create the indexes and their mappings:
vendor/bin/sake tasks:SearchConfigure --flush
-
Index your content, and run the queued jobs:
vendor/bin/sake tasks:SearchReindex vendor/bin/sake tasks:ProcessJobQueueTask
After that, records are added and removed as they are published and unpublished.
Documentation
- Configuration: index names, field types, analyzers, changing a mapping
- Fluent: one index per locale with silverstripe-forager-fluent
- Searching: querying the indexes, and content which is not public
See the Forager documentation for everything which is not specific to Elasticsearch.
License
MIT, see LICENSE.