搜索文档提供者
搜索文档提供者扩展点用于为 Halo 搜索引擎提供可索引的文档数据,例如:文章、页面等。当重建搜索索引时,Halo 会收集所有启用的文档提供者,获取它们提供的文档数据并写入搜索引擎。
public interface HaloDocumentsProvider extends ExtensionPoint {
Flux<HaloDocument> fetchAll();
String getType();
}fetchAll方法用于获取所有文档数据,返回Flux<HaloDocument>。HaloDocument包含标题、内容、分类、标签等字段。getType方法返回文档类型标识,例如post.content.halo.run、singlepage.content.halo.run。
HaloDocumentsProvider 对应的 ExtensionPointDefinition 如下:
apiVersion: plugin.halo.run/v1alpha1
kind: ExtensionPointDefinition
metadata:
name: halo-documents-provider
spec:
className: run.halo.app.search.HaloDocumentsProvider
displayName: "搜索文档提供者"
type: MULTI_INSTANCE
description: "提供用于重建搜索索引的文档数据"即声明 ExtensionDefinition 自定义模型对象时对应的 extensionPointName 为 halo-documents-provider。
使用案例可以参考: