groovy - CrafterCMS:如何输出由 solr 索引的 html 正文?
问题描述
我在我的 RTE 中使用后缀 _html 来实现 solr 的索引功能。但是,当我显示我的搜索结果时,我需要 html 标签而不是纯文本。有解决办法吗?
编辑:我使用地图 ,matches = [:]
来存储我的 solr 查询的结果。我需要content_html
从每个文档中获取结果并显示它们。这是我到目前为止的进展:
时髦的:
def contents = [:]
def index = 0
// solr search results are stored in matches.faqs
for (item in matches.faqs) {
// with a solr result document
def aResult = executedQuery.response.documents[index]
// look up the item
def myContentItem = siteItemService.getSiteItem(aResult.localId)
// get the markup you want
contents.put('contentHtml', myContentItem.queryValue("content_html"))
index++
}
解决方案
一种方法是使用 siteItemService 从结果中简单地查找所需的 HTML:
时髦的:
// with a solr result document
def aResult = executedQuery.response.documents[0]
// look up the item
def myContentItem = siteItemService.getSiteItem(aResult.localId)
// get the markup you want
def rteHtml = myContentItem.queryValue("theRTEField_html")
推荐阅读
- flutter - 尝试在 Flutter 中创建一个新的文本文件
- c++ - C++ 向量在取消引用后没有打印正确的值?
- google-apps-script - 是否有某种方法使用 Google Apps 脚本可以直接打开 Google Doc 中的所有链接,而无需再次单击 URL?
- python-3.x - 如何检查一个值与两个值的相等性?
- wordpress - 为wordpress rest api公开acf的所有字段
- google-cloud-dataflow - Apache Beam / Dataflow 转换建议
- c# - 为什么选择两页滚动选项时,devExpress 会为单个文档提供绑定错误?
- database - 如何在 MongoDB 的 rs.conf() 中获取当前成员索引?
- git - Git 如何处理拼写错误的命令?
- eslint - 删除 `(` eslint (prettier/prettier)