2017 © Pedro Peláez
 

silverstripe-vendormodule silverstripe-extensible-elastic

An elastic search adapter for extensible search

image

nyeholt/silverstripe-extensible-elastic

An elastic search adapter for extensible search

  • Monday, July 16, 2018
  • by nyeholt
  • Repository
  • 1 Watchers
  • 0 Stars
  • 1,980 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 3 Forks
  • 1 Open issues
  • 11 Versions
  • 28 % Grown

The README.md

Elastic Extensible Search

An extensible search implementation for Elastic Search., (*1)

Installation

composer require nyeholt/silverstripe-extensible-elastic, (*2)

NOTE: if using filters on your search page, or outputting the Score in results, you'll need the following patch, (*3)

https://gist.github.com/nyeholt/47be9e689b069375215c96f8ee3f865f, (*4)

Configuration

Add the following to your project's config, (*5)

---
Name: elastic_config
---
nglasl\extensible\ExtensibleSearchPage:
  custom_search_engines:
    Symbiote\ElasticSearch\ElasticaSearchEngine: 'Elastic'

PageController:
  extensions:
    - 'nglasl\extensible\ExtensibleSearchExtension'
    - 'Symbiote\ElasticSearch\ElasticaSearchController'

Page:
  extensions:
    - 'Symbiote\ElasticSearch\ElasticaSearchable'

SilverStripe\Core\Injector\Injector:
  ElasticClient:
    class: Elastica\Client
    constructor:
      host_details: 
        host: elastic
        port: 9200
        # transport: AwsAuthV4 - this is needed for AWS search service compatibility; it adds credentials support
  Symbiote\ElasticSearch\ElasticaSearch:
    properties:
      searchService: %$Heyday\Elastica\ElasticaService
  Heyday\Elastica\ElasticaService:
    class: Symbiote\ElasticSearch\ExtensibleElasticService
    constructor:
      client: %$ElasticClient
      index: my-index

To add additional types for selection in an extensible search page config; note namespaces are supported., (*6)

---
Name: search_page_config
---
Symbiote\ElasticSearch\ElasticaSearch:
  additional_search_types:
    My\Namespaced\Class: Friendly Label

Run /dev/tasks/Symbiote-ElasticSearch-VersionedReindexTask, (*7)

Note: Reindex will ONLY reindex items that have the Searchable extension applied. There's also a DataDiscovery extension that will grab taxonomy terms if available., (*8)

---
Name: elastic_data_config
---
SilverStripe\CMS\Model\SiteTree:
  extensions:
    - Symbiote\ElasticSearch\ElasticaSearchable
    # for extra boosting options - Symbiote\ElasticSearch\DataDiscovery

API

To define your own custom field structures in the elastic index, you need to, (*9)

  • define your field mappings for the 'rebuild' phase
  • add data for those fields during the indexing phase
public function updateElasticMappings($mappings = []) {
    $mappings['Identifier'] = ['type' => 'keyword'];
    $mappings['ContentType'] = ['type' => 'keyword'];
}
public function updateElasticDoc(Document $document)
{
    $document->set('Identifier', $this->Identifier);
    $document->set('ContentType', $this->ContentType);
}

Details

How do I use the BoostTerms field?, (*10)

BoostTerms are used for subsequent querying, either direct through the builder or by the "Boost values" and "Boost fields with field/value matches" options on the Extensible Search Page., (*11)

The field hint states to use the word "important" in this field to boost the record super high in result sets. This requires you to set the "Boost fields with field/value matches" to have an entry of, (*12)

BoostTerms:important : 10, (*13)

in the search page to boost records with that set. Additionally, set the "Boost values" for BoostTerms to be higher than all other fields for any match to contribute highly., (*14)

Why the separate ElasticaSearchable extension?, (*15)

The base Heyday Elastic module doesn't handle indexing of Versioned content directly; ElasticaSearchable provides a few overrides that take into account versioned content., (*16)

Can I get rid of stale results?, (*17)

You can prune old results by creating the PruneStaleResultsJob ; this takes as parameters, (*18)

  • The field:value filter to use; typically something like ClassName:MyDataClass. If you don't want a filter applied, pass the string 'null'
  • How old something should be until it's considered 'old' in strtotime format
  • How frequently to run the job in seconds, ie 86400 for every day
  • How many to delete in each batch, typically around 1000
ClassName:My\Data\Class
-1 month
86400
1000

The Versions

16/07 2018

2.2.1

2.2.1.0 https://github.com/nyeholt/silverstripe-extensible-elastic

An elastic search adapter for extensible search

  Sources   Download

BSD-3-Clause

The Requires

 

search full-text silverstripe elastic search

16/07 2018

dev-master

9999999-dev https://github.com/nyeholt/silverstripe-extensible-elastic

An elastic search adapter for extensible search

  Sources   Download

BSD-3-Clause

The Requires

 

search full-text silverstripe elastic search

18/06 2018

2.2.0

2.2.0.0 https://github.com/nyeholt/silverstripe-extensible-elastic

An elastic search adapter for extensible search

  Sources   Download

BSD-3-Clause

The Requires

 

search full-text silverstripe elastic search

21/03 2018

2.1.0

2.1.0.0 https://github.com/nyeholt/silverstripe-extensible-elastic

An elastic search adapter for extensible search

  Sources   Download

BSD-3-Clause

The Requires

 

search full-text silverstripe elastic search

20/03 2018

2.0.3

2.0.3.0 https://github.com/nyeholt/silverstripe-extensible-elastic

An elastic search adapter for extensible search

  Sources   Download

BSD-3-Clause

The Requires

 

search full-text silverstripe elastic search

07/03 2018

2.0.2

2.0.2.0 https://github.com/nyeholt/silverstripe-extensible-elastic

An elastic search adapter for extensible search

  Sources   Download

BSD-3-Clause

The Requires

 

search full-text silverstripe elastic search

28/02 2018

2.0.1

2.0.1.0 https://github.com/nyeholt/silverstripe-extensible-elastic

An elastic search adapter for extensible search

  Sources   Download

BSD-3-Clause

The Requires

 

search full-text silverstripe elastic search

27/02 2018

2.0.0

2.0.0.0 https://github.com/nyeholt/silverstripe-extensible-elastic

An elastic search adapter for extensible search

  Sources   Download

BSD-3-Clause

The Requires

 

search full-text silverstripe elastic search

27/02 2018

1.1.x-dev

1.1.9999999.9999999-dev https://github.com/nyeholt/silverstripe-extensible-elastic

An elastic search adapter for extensible search

  Sources   Download

BSD-3-Clause

The Requires

 

search full-text silverstripe elastic search

27/02 2018

1.1.0

1.1.0.0 https://github.com/nyeholt/silverstripe-extensible-elastic

An elastic search adapter for extensible search

  Sources   Download

BSD-3-Clause

The Requires

 

search full-text silverstripe elastic search

22/02 2018

dev-feature-ss4-upgrade

dev-feature-ss4-upgrade https://github.com/nyeholt/silverstripe-extensible-elastic

An elastic search adapter for extensible search

  Sources   Download

BSD-3-Clause

The Requires

 

search full-text silverstripe elastic search