Plone的Solr集成
项目描述
简介
ftw.solr 将 Solr 搜索引擎与 Plone 集成。
ftw.solr 不试图取代 Plone 的门户目录,也不挂钩到目录的搜索功能。相反,它提供了一个必须显式使用的搜索工具。它旨在用于搜索表单中的全文搜索,而门户目录仍然用于诸如导航或文件夹内容之类的操作。目标是消除门户目录中的所有全文索引(例如 ZCTextIndex)。
ftw.solr 需要 Apache Solr 7.0 或更高版本。
安装
添加为依赖项
通过将其添加到您的 buildout 的 eggs 列表或将其添加到您的策略包的依赖项中,安装 ftw.solr。
[instance]
eggs +=
ftw.solr
Solr 安装
要使用 buildout 安装 Solr 服务器,您可以使用 ftw.recipe.solr 脚本。
[solr]
recipe = ftw.recipe.solr
cores = mycore
配置 Solr 连接
Solr 的连接设置可以在 ZCML 中配置,因此可以在 buildout 中配置。示例
[instance] zcml-additional = <configure xmlns:solr="http://namespaces.plone.org/solr"> <solr:connection host="localhost" port="8983" base="/solr/mycore"/> </configure>
默认情况下,ftw.solr 将通过将 blob 的文件系统路径传递给 Solr Cell 提取处理程序来进行全文提取,假设 Solr 在同一台机器上运行并且可以访问 blob 存储器。
对于不需要这种情况的设置,可以将连接选项 upload_blobs 设置为 true,以便通过 HTTP POST 将 blob 直接上传到提取处理程序
[instance] zcml-additional = <configure xmlns:solr="http://namespaces.plone.org/solr"> <solr:connection host="localhost" port="8983" base="/solr/mycore" upload_blobs="true"/> </configure>
运行 buildout
运行 buildout 并重新启动您的实例后,您可以在 Plone 中安装 ftw.solr 插件。
Python 3.8 - Plone 5.2
本地安装和运行测试
python3 -m venv .
./bin/pip install -r requirements.txt
./bin/buildout -c test-plone-5.2.x-py38.cfg
./bin/test
用法
获取 ISolrSearch 工具并调用搜索方法以从 Solr 获取搜索结果。
from ftw.solr.interfaces import ISolrSearch
from zope.component import getUtility
solr = getUtility(ISolrSearch)
resp = solr.search(query=u'SearchableText:foo')
您可以通过适配 IContentListing 来获取类似 plone.app.contentlisting 风格的结果。
from plone.app.contentlisting.interfaces import IContentListing
listing = IContentListing(resp)
Solr 索引维护
对于索引 Plone 内容和其他维护工作,您可以使用 solr Zope 命令。运行 bin/instance solr -h 以获取可用选项。
清除 Solr 索引
bin/instance solr clear
重建完整的 Solr 索引
bin/instance solr reindex
重新索引特定索引
bin/instance solr reindex -i modified created
将 Solr 索引与门户目录同步
bin/instance solr sync
链接
版权
本软件包的版权归 4teamwork 所有。
ftw.solr 在 GNU 通用公共许可证,版本 2 的许可下。
变更日志
2.13.2 (2024-04-04)
修复在运行 Zope2.Startup.zopectl 时 zopectl 命令的参数解析问题。[buchi]
2.13.1 (2023-06-20)
在没有指定 fl 的情况下执行搜索时记录警告。[njohner]
修复 solr 同步维护命令不提交所有批次的错误。[lgraf]
2.13.0 (2023-04-11)
添加对 Plone 5.2 和 Python 3 的支持。[buchi]
添加对 Python 3.8 及更高版本的兼容性。[mathias.leimgruber]
2.12.1 (2022-08-03)
使 updates_in_post_commit_enabled() 辅助函数更健壮。[lgraf]
2.12.0 (2022-07-19)
添加选项以在确定 Solr 中未更新的项目时同时检查 allowedRolesAndUsers。[njohner]
添加选项以在提交后挂钩中执行更新命令。[njohner]
2.11.0 (2022-07-04)
添加对特定语言字段的支持。[buchi]
2.10.0 (2021-09-21)
添加标志以强制清除 solr,即使 solr 未启用。[njohner]
2.9.5 (2021-08-17)
添加无限制搜索方法。 [njohner]
2.9.4 (2021-07-29)
SolrDocument 对于缺失值的现有字段返回 None。 [njohner]
2.9.3 (2021-04-22)
仅对具有主字段的对象进行可搜索文本的索引修复。 [njohner]
2.9.2 (2021-01-13)
在 solr 中索引数据时,不要忽略 None 值。 [njohner]
2.9.1 (2020-12-15)
在发送到 solr 之前清理 extract_commands。 [njohner]
2.9.0 (2020-08-04)
将没有创建字段的文章视为 diff 中的不同步。 [deiferni]
2.8.6 (2020-06-02)
将维护命令记录到专门的日志文件中。 [lgraf]
添加限制 diff 中记录项的选项,默认切换到仅 diff 5 项。 [deiferni]
添加从目录查询创建 Solr 过滤器的辅助工具。 [buchi]
2.8.5 (2020-05-06)
确保维护脚本以系统用户运行。 [njohner]
2.8.4 (2020-04-02)
修复修改索引的更新。 [njohner]
2.8.3 (2020-04-02)
更新修改索引以匹配新的 DateTime 四舍五入。 [njohner]
2.8.2 (2020-03-27)
修复 to_iso8601 以防止 DateTime 毫秒数超过 999500 时的舍入错误。 [deiferni]
修复 DX 项的 blob 提取。 [mbaechtold]
2.8.1 (2020-02-05)
修复 to_iso8601 对于 1900 年前的年份。 [deiferni]
2.8.0 (2019-12-06)
添加将 blob 上传到提取处理器的支持。 [lgraf]
添加对 Plone 5.0 和 5.1 的支持。 [buchi]
2.7.0 (2019-09-16)
添加维护任务的控制台脚本。 [buchi]
添加启用/禁用索引的注册设置。 [buchi]
2.6.2 (2019-09-12)
避免使用 null 文档发送原子更新命令。 [lgraf]
2.6.1 (2019-08-26)
修复当 'path_depth' 不是模式的一部分时的 'path_depth' 索引处理。 [phgross]
2.6.0 (2019-08-19)
仅使用 Solr Cell 进行文本提取。现在 SearchableText 也使用 update handler 进行索引,允许原子更新。也修复了 #137。 [buchi]
修复尝试删除没有唯一键的对象时的错误。 [jone]
2.5.0 (2019-07-02)
确保在 'path' 被重新索引时始终更新 'path_depth'。 [lgraf]
处理 solr 响应中的 facet_counts。 [njohner]
2.4.0 (2019-06-13)
默认执行软提交并等待新的搜索器,以允许近似实时 (NRT) 搜索。 [buchi]
使用更新命令索引文件的元数据,以使它们尽快可见。 [buchi]
刷新优化命令。 [buchi]
添加索引路径深度的支持。 [buchi]
2.3.2 (2019-04-29)
修复对于没有值的字段的部分重新索引(原子更新)。 [buchi]
2.3.1 (2018-11-01)
修复 reindexObjectSecurity 补丁以考虑 allowedRolesAndUsers 索引器中系统角色的特殊处理。 [lgraf]
2.3.0 (2018-10-18)
修补 reindexObjectSecurity 以优化大型树的索引。 [lgraf]
修复具有没有分数秒的修改日期的项的 diff。 [buchi]
在 SolrDocument 中引发 AttributeError 时提供错误消息。 [buchi]
2.2.0 (2018-09-21)
在维护视图中添加选项以同步 Solr 与目录。 [buchi]
2.1.2 (2018-05-15)
为 /update/extract 端点的请求设置 Content-Type 'application/x-www-form-urlencoded' 以确保与 Solr 7.3 的兼容性。 [lgraf]
维护视图:允许在不破坏事务的情况下重新索引。 [lgraf]
2.1.1 (2018-02-20)
确保我们不向 Solr 传递无效的日期。 [buchi]
2.1.0 (2018-02-20)
声明对 plone.namedfile[blobs] 的依赖。 [lgraf]
在维护视图中添加 diff 函数,以比较门户目录中的 UIDs 与 Solr 中的 UIDs。 [buchi]
修复安全过滤器:正确引用包含空格的角色/用户。 [buchi]
添加从目录查询重新索引 Solr 的选项。 [buchi]
2.0.0 (2018-02-15)
完整重写。与以前版本不兼容。 [buchi]