silverstripe/silverstripe-forager-bifrost

一个为 silverstripe/silverstripe-forager 提供的 Silverstripe 搜索插件

1.0.4 2024-09-12 22:02 UTC

This package is auto-updated.

Last update: 2024-09-13 00:12:51 UTC


README

本模块通过 🌈 Bifröst - Silverstripe 搜索服务的 API,提供对 Silverstripe 搜索引擎内容的索引功能。

本模块 提供执行搜索的方法。有关建议,请参阅下方的 搜索 部分。

安装

composer require silverstripe/silverstripe-forager-bifrost

激活服务

要集成 Silverstripe 搜索,请定义包含您的端点、引擎前缀和管理 API 密钥的环境变量。

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

配置

最显著的配置界面是模式,它决定了数据如何在您的索引中存储。支持五种类型的数据

  • text(默认)
  • 日期
  • 数字
  • 地理位置
  • binary(仅支持 _attachment 字段 - 见下文)

您可以在字段的 options 节中指定这些数据类型。

SilverStripe\Forager\Service\IndexConfiguration:
  indexes:
    myindex:
      includeClasses:
        SilverStripe\CMS\Model\SiteTree:
          fields:
            title: true
            summary_field:
              property: SummaryField
              options:
                type: text

内容提取的文件附件

Silverstripe 搜索支持许多不同文件类型的内容提取。这些可以通过 _attachment 字段(类型为 binary)附加到您的文档上。

该字段需要包含要处理的文件的 base 64 编码的二进制字符串。

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

其中 getBase64String 是我们 FileExtension 中的一个方法 - 该方法默认应用于本模块中的 File 类。

附加文档

大部分文档由 Forager 模块提供。其中一些可能对您有用的包括

搜索

Silverstripe Search 通过其 PHP SDK 提供搜索支持