silverstripe / silverstripe-search-service-elastic
为 Silverstripe 搜索服务提供 Elastic 企业搜索功能
Requires
- php: ^8.1
- elastic/enterprise-search: ^8.6
- guzzlehttp/guzzle: ^7
- silverstripe/framework: ^5
- silverstripe/silverstripe-search-service: ^3
Requires (Dev)
This package is auto-updated.
Last update: 2024-09-06 02:41:24 UTC
README
Elastic 服务提供者,用于 Silverstripe 搜索服务。
此模块使用 Elastic 的 Enterprise Search PHP 库 提供为 Elastic App Search 引擎索引内容的可能性。此模块 不 提供在任何引擎上执行搜索的方法 - 我们已经添加了一些 建议。
要求
- php: ^8.1
- silverstripe/framework: ^5
- silverstripe/silverstripe-search-service: ^3
- elastic/enterprise-search: ^8.3
- guzzlehttp/guzzle: ^7
安装
composer require silverstripe/silverstripe-search-service-elastic
激活 EnterpriseSearch
要开始使用 EnterpriseSearch,定义包含您的私有 API 密钥、端点和前缀的环境变量。
ENTERPRISE_SEARCH_ENDPOINT="https://abc123.app-search.ap-southeast-2.aws.found.io"
ENTERPRISE_SEARCH_API_KEY="private-abc123"
ENTERPRISE_SEARCH_ENGINE_PREFIX="value-excluding-index-name"
配置 EnterpriseSearch
EnterpriseSearch 最显著的配置界面是架构,它决定了数据如何存储在您的 EnterpriseSearch 索引(引擎)中。EnterpriseSearch 中有四种类型的数据
text
(默认)date
number
geolocation
您可以在字段的 options
节点中指定这些数据类型。
SilverStripe\SearchService\Service\IndexConfiguration: indexes: myindex: includeClasses: SilverStripe\CMS\Model\SiteTree: fields: title: true summary_field: property: SummaryField options: type: text
注意:请小心随意更改架构。如果您更改字段的 数据类型,EnterpriseSearch 可能需要完全重新索引。
其他文档
大多数文档由 Silverstripe 搜索服务模块提供。其中一些可能对您有帮助的是
搜索
Elastic 本身提供了一个无头 Search UI JS 库,它可以与纯 JS 或任何框架(如 React、Vue 等)一起使用。
有两个主要的库
- @elastic/search-ui-app-search-connector
- 提供一个类,帮助您连接到您的 Elastic App Search API。
- @elastic/search-ui
- 提供一个类,允许您执行搜索并管理您的搜索状态。
如果您使用 React,那么还有 @elastic/react-search-ui,它提供界面组件。
如果您不使用 React,则视图的创建将由您自己完成。