nyeholt / silverstripe-extensible-elastic
可扩展搜索的弹性搜索适配器
- dev-master / 3.0.x-dev
- 3.0.1
- 3.0.0
- 2.11.4
- 2.11.3
- 2.11.2
- 2.11.1
- 2.11.0
- 2.10.2
- 2.10.1
- 2.10.0
- 2.9.1
- 2.9.0
- 2.8.0
- 2.7.1
- 2.7.0
- 2.6.0
- 2.5.0
- 2.4.1
- 2.4.0
- 2.2.2
- 2.2.1
- 2.2.0
- 2.1.0
- 2.0.3
- 2.0.2
- 2.0.1
- 2.0.0
- 1.2.x-dev
- 1.2.1
- 1.2.0
- 1.1.x-dev
- 1.1.0
- dev-feature-upgrade-v7
- dev-fix-unboost-partials
- dev-feature-ss4-upgrade
This package is auto-updated.
Last update: 2024-09-16 02:02:06 UTC
README
Elastic Search 的可扩展搜索实现。
安装
composer require nyeholt/silverstripe-extensible-elastic
注意:如果在搜索页面使用过滤器或在结果中输出得分,则需要以下补丁
https://gist.github.com/nyeholt/47be9e689b069375215c96f8ee3f865f
配置
将以下内容添加到您的项目配置中
---
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
为了在可扩展搜索页面配置中添加额外的选择类型,请注意命名空间是支持的。
---
Name: search_page_config
---
Symbiote\ElasticSearch\ElasticaSearch:
additional_search_types:
My\Namespaced\Class: Friendly Label
运行 /dev/tasks/Symbiote-ElasticSearch-VersionedReindexTask
注意:重新索引将 仅 重新索引应用了 Searchable 扩展的项目。还有 DataDiscovery 扩展,如果可用,将获取分类术语。
---
Name: elastic_data_config
---
SilverStripe\CMS\Model\SiteTree:
extensions:
- Symbiote\ElasticSearch\ElasticaSearchable
# for extra boosting options - Symbiote\ElasticSearch\DataDiscovery
API
要定义自己的自定义字段结构在弹性索引中,您需要
- 定义 '重建' 阶段的字段映射
- 在索引阶段添加这些字段的数据
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);
}
详细信息
如何使用 BoostTerms 字段?
BoostTerms 用于后续查询,无论是通过构建器直接查询,还是通过可扩展搜索页面上的“提升值”和“提升匹配字段/值”选项。
字段提示表示在此字段中使用“重要”一词来提升记录在结果集中的排名。这需要您将“提升匹配字段/值”设置为以下条目
BoostTerms:important
: 10
在搜索页面中提升具有该设置的记录。此外,将 BoostTerms 的“提升值”设置为高于所有其他字段,以便任何匹配都高度贡献。
为什么有独立的 ElasticaSearchable 扩展?
Heyday Elastic 模块的基础不直接处理版本化内容的索引;ElasticaSearchable 提供了一些考虑版本化内容的覆盖。
我可以移除过时的结果吗?
您可以通过创建 PruneStaleResultsJob 来修剪旧结果;该任务接受以下参数
- 要使用的字段:值过滤器;通常类似于 ClassName:MyDataClass。如果您不想应用过滤器,请传递字符串 'null'
- 某个内容被认为是 '旧' 的时间长度,以 strtotime 格式表示
- 以秒为单位的运行作业的频率,例如 86400 每天运行一次
- 每个批次要删除的数量,通常约为 1000
ClassName:My\Data\Class
-1 month
86400
1000