silverstripe/silverstripe-forager-bifrost

A Silverstripe Search add-on for silverstripe/silverstripe-forager

1.0.5 2024-11-06 01:21 UTC

This package is auto-updated.

Last update: 2024-12-09 22:26:00 UTC


README

This module provides the ability to index content for a Silverstripe Search engine through the 🌈 Bifröst - the API for Silverstripe's Search service.

This module does not provide any method for performing searches on your engines. See the Searching section below for some suggestions.

Installation

composer require silverstripe/silverstripe-forager-bifrost

Activating the service

To integrate with Silverstripe Search, define environment variables containing your endpoint, engine prefix, and management API key.

BIFROST_ENDPOINT="https://abc.provided.domain"
BIFROST_ENGINE_PREFIX="engine-name-excluding-variant"
BIFROST_MANAGEMENT_API_KEY="abc.123.xyz"

Configuration

The most notable configuration surface is the schema, which determines how data is stored in your index. There are five types of data supported:

  • text (default)
  • date
  • number
  • geolocation
  • binary (only supported for the _attachment field - see below)

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

File attachments for content extraction

Firstly, you will need to set this environment variable. This will apply an extension to the File class, and allow you to use the _attachment field (detailed below).

SEARCH_INDEX_FILES=1

Silverstripe Search supports content extraction for many different file types. These can be attached to your Documents using an _attachment field of type binary.

This field needs to contain a base 64 encoded string of binary for the file you wish to process.

SilverStripe\Forager\Service\IndexConfiguration:
  indexes:
    myindex:
      includeClasses:
        SilverStripe\Assets\File:
          fields:
            title: true
            _attachment:
              property: getBase64String
              options:
                type: binary

Where getBase64String is a method in our FileExtension - which is applied to the File class by default as part of this module.

Additional documentation

Majority of documentation is provided by the Forager module. A couple in particular that might be useful to you are:

Searching

Silverstripe Search provides support for searching through its PHP SDK: