PHPackages                             haunt-jonathan/heyday-silverstripe-elastica - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Search &amp; Filtering](/categories/search)
4. /
5. haunt-jonathan/heyday-silverstripe-elastica

ActiveSilverstripe-vendormodule[Search &amp; Filtering](/categories/search)

haunt-jonathan/heyday-silverstripe-elastica
===========================================

Provides Elastic Search integration for SilverStripe DataObjects using Elastica

4.1(3y ago)0332BSD-3-ClausePHPPHP &gt;=7.4

Since Nov 13Pushed 3y agoCompare

[ Source](https://github.com/haunt-jonathan/silverstripe-elastica)[ Packagist](https://packagist.org/packages/haunt-jonathan/heyday-silverstripe-elastica)[ Docs](http://github.com/heyday/silverstripe-elastica)[ RSS](/packages/haunt-jonathan-heyday-silverstripe-elastica/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (5)Versions (2)Used By (0)

Heyday's SilverStripe Elastica Module
=====================================

[](#heydays-silverstripe-elastica-module)

Facilitates searching and indexing of SilverStripe CMS using ElasticSearch. We use Elastica to do all the heavy lifting in terms of communication with the elastic search server.

This module makes it easy to use ElasticSearch with SilverStripe without limiting any of the functionality found in Elastica. Basically anything that can be done with Elastica alone can be done in conjunction with this module.

This module supercedes [Symbiote's Elastica Module](https://github.com/symbiote-library/silverstripe-elastica), which was only supported up to SilverStripe 3.

Features
--------

[](#features)

- Uses [Elastica](https://github.com/ruflin/Elastica) to communicate with the ElasticSearch Server
- Uses [PSR/Log](https://github.com/php-fig/log) interface for logging purposes (optional)
- Uses YAML configuration to index Data Objects and Pages
- Can handle has\_many, many\_many, and has\_one relationships in the indexed ElasticSearch document
- Can handle invalidation and reindexing of related data objects
- Can handle custom fields that are not in the database but only exist as part of an object instance
- Infers ElasticSearch document field type from the database field type defined in the corresponding SilverStripe model

Compatibility
-------------

[](#compatibility)

This release should be compatible with all ElasticSearch 7.0 and above versions. May work with elasticsearch 6. This release requires SilverStripe 4.x

If you need to work with an earlier version of elasticsearch (2.x) and SS (3.x), please try the 1.0 release of this module

Installation
------------

[](#installation)

```
$ composer require heyday/silverstripe-elastica
```

Usage
-----

[](#usage)

### Elastica Service configuration example:

[](#elastica-service-configuration-example)

mysite/\_config/search.yml

```
Heyday\Elastica\ElasticaService: # Example of customising the index config on the elastic search server (completely optional).
  index_config:
    settings:
      analysis:
        analyzer:
          default:
            type: custom
            tokenizer: standard
            filter:
              - lowercase
              - stemming_filter
        filter:
          stemming_filter:
            type: snowball
            language: English

---
Only:
  environment: dev
---
SilverStripe\Core\Injector\Injector:
  Elastica\Client:
    constructor:
      - host: localhost # hostname of the elastic search server
        port: 9200 # port number of the elastic search server

  Heyday\Elastica\ElasticaService:
    constructor:
      - "%$Elastica\Client"
      - "name-of-index"  # name of the index on the elastic search server
      - "%$Logger"  # your error logger (must implement psr/log interface)
      - "64MB"      # increases memory limit while indexing
```

### Index configuration example:

[](#index-configuration-example)

mysite/\_config/search.yml

```
# PageTypes

Your\Namespace\Page:
  extensions:
    - Heyday\Elastica\Searchable
  indexed_fields: &page_defaults
    - Title
    - MenuTitle
    - Content
    - MetaDescription

Your\Namespace\SpecialPageWithAdditionalFields:
  extensions:
    - Heyday\Elastica\Searchable # only needed if this page does not extend the 'Page' configured above
  indexed_fields:
