为自适应表单引用创建自定义索引 create-custom-index-for-adaptive-forms-references
创建带标记的Lucene索引以避免在Adobe Experience Manager (AEM) Forms解析自适应表单引用时遍历查询。 如果没有合适的索引,发布包含自适应表单引用的体验片段可能会在日志中生成Traversal query (query without index)警告。
在AEM Forms 6.5.24.0及更高版本中,引用查询使用aemformsAFReferences索引标记。 这些发行版本包括查询更改,但必须使用该标记创建自定义索引。 本文介绍了如何定义和部署索引。
对于AEM Forms 6.5 LTS,请参阅在AEM Forms 6.5 LTS中为自适应表单引用创建自定义索引。
先决条件 prerequisites
在开始之前,请确保您具有:
- AEM Forms 6.5.24.0或更高版本,并安装了相应的Forms加载项。
- 在创作实例的
/oak:index下创建索引的访问权限。 - 具有
ui.apps模块的AEM项目(如果您通过内容包部署索引),或者访问CRXDE Lite作为开发替代方案。
在将索引部署到生产环境之前,请在开发或暂存环境中测试该索引。 在大型存储库上生成索引可能需要一些时间。
定义自定义索引 define-the-custom-index
在/oak:index/customAFReferenceLuceneIndex-1处创建索引。 您可以选择其他索引节点名称,但请保持aemformsAFReferences标记不变,以便Forms引用查询可以选择该索引。
使用以下定义。 它在/content下的nt:unstructured节点上索引sling:resourceType。
{
"jcr:primaryType": "oak:QueryIndexDefinition",
"selectionPolicy": "tag",
"compatVersion": 2,
"includedPaths": ["/content"],
"queryPaths": ["/content"],
"tags": ["aemformsAFReferences"],
"type": "lucene",
"async": ["async"],
"evaluatePathRestrictions": true,
"reindex": false,
"indexRules": {
"jcr:primaryType": "nt:unstructured",
"nt:unstructured": {
"jcr:primaryType": "nt:unstructured",
"properties": {
"jcr:primaryType": "nt:unstructured",
"resourceType": {
"jcr:primaryType": "nt:unstructured",
"propertyIndex": true,
"name": "sling:resourceType"
}
}
}
}
}
不添加analyzed=true。 引用查询使用属性限制而不是全文contains条件,因此不需要设置。
使用内容包部署索引 deploy-the-index-with-a-content-package
使用内容包进行生产部署。
-
在您的AEM项目的
ui.apps模块中,创建ui.apps/src/main/content/jcr_root/_oak_index/customAFReferenceLuceneIndex-1/。 -
在该目录中使用以下定义创建
.content.xml:code language-xml <?xml version="1.0" encoding="UTF-8"?> <jcr:root xmlns:oak="http://jackrabbit.apache.org/oak/ns/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:nt="http://www.jcp.org/jcr/nt/1.0" jcr:primaryType="oak:QueryIndexDefinition" async="[async]" compatVersion="{Long}2" evaluatePathRestrictions="{Boolean}true" includedPaths="[/content]" queryPaths="[/content]" reindex="{Boolean}false" selectionPolicy="tag" tags="[aemformsAFReferences]" type="lucene"> <indexRules jcr:primaryType="nt:unstructured"> <nt:unstructured jcr:primaryType="nt:unstructured"> <properties jcr:primaryType="nt:unstructured"> <resourceType jcr:primaryType="nt:unstructured" name="sling:resourceType" propertyIndex="{Boolean}true"/> </properties> </nt:unstructured> </indexRules> </jcr:root> -
在
ui.apps/src/main/content/META-INF/vault/filter.xml中的现有workspaceFilter元素中添加以下筛选器。 保持项目的其他筛选器不变。code language-xml <filter root="/oak:index/customAFReferenceLuceneIndex-1"/> -
使用现有的生成配置生成项目,并在创作实例上安装生成的内容包。 有关包上载和安装说明,请参阅包管理器。
-
确认
/oak:index/customAFReferenceLuceneIndex-1存在。 在检查查询计划之前,允许完成异步索引。
如果选择不同的索引名称,请在目录、筛选器和存储库路径中一致地使用该名称。
使用CRXDE Lite创建索引 create-the-index-with-crxde-lite
在开发环境中使用此替代方法,而不是内容包方法。
创建索引节点时,请使用以下属性:
selectionPolicytagcompatVersion2includedPathsString[]/contentqueryPathsString[]/contenttagsString[]aemformsAFReferencestypeluceneasyncString[]asyncevaluatePathRestrictionstruereindexfalseString[]表示多值字符串属性,即使它只包含一个值。
-
打开
http://localhost:4502/crx/de/index.jsp。 将主机和端口替换为创作实例的主机和端口。 -
导航到
/oak:index。 右键单击该节点并选择创建 > 创建节点。 -
创建类型为
oak:QueryIndexDefinition的customAFReferenceLuceneIndex-1。 -
将上表中的属性添加到索引节点。
-
在索引节点下,创建以下子节点层次结构。 将每个子节点的类型设置为
nt:unstructured:code language-text indexRules nt:unstructured properties resourceType -
在
resourceType上,添加值为sling:resourceType的name(字符串)和值为true的propertyIndex(布尔值)。 -
选择全部保存并允许异步索引完成。
验证查询是否使用索引 verify-that-the-query-uses-the-index
检查查询计划,确认参考查询选择您的自定义索引。
-
确认异步索引已完成。 使用索引管理器检查索引状态。
-
打开工具 > 操作 > 诊断 > 查询性能并选择说明查询。 选择XPath查询语言并输入:
code language-text /jcr:root/content//element(*, nt:unstructured)[ (@sling:resourceType = 'fd/af/components/aemform' or jcr:like(@sling:resourceType, '%components/aemformscontainer%') or jcr:like(@sling:resourceType, '%components/adaptiveForm/fragment%'))] option (index tag aemformsAFReferences) -
选择说明。 确认计划使用
lucene:customAFReferenceLuceneIndex-1和/oak:index/customAFReferenceLuceneIndex-1或您选择的索引名称作为查询的分支而不是遍历计划。 有关详细信息,请参阅说明查询。 -
重复产生警告的体验片段发布操作。 检查
error.log以了解来自com.adobe.aem.formsndocuments.publish.AssetReferenceProvider.resolvePathsToFindReferences的新遍历警告。
如果计划未选择自定义索引,请根据以上示例检查标记、indexRules层次结构和sling:resourceType属性定义。 有关进一步的诊断,请参阅Oak索引疑难解答。