建立最適化表單參考的自訂索引 create-custom-index-for-adaptive-forms-references
建立標籤Lucene索引以避免在Adobe Experience Manager (AEM) Forms解析最適化表單參考時周遊查詢。 如果沒有適當的索引,發佈包含最適化表單參考的體驗片段可能會在記錄檔中產生Traversal query (query without index)警告。
在AEM Forms 6.5 LTS SP1和更新版本中,參考查詢使用aemformsAFReferences索引標籤。 這些發行版本包含查詢變更,但您必須使用該標籤建立自訂索引。 本文說明如何定義及部署索引。
若為AEM Forms 6.5,請參閱在AEM Forms 6.5中為最適化表單參考建立自訂索引。
先決條件 prerequisites
在開始之前,請確定您已:
- AEM Forms 6.5 LTS SP1或更新版本,已安裝對應的Forms附加元件。
- 存取權以在作者執行個體上的
/oak:index下建立索引。 - 如果您透過內容套件部署索引,或存取開發替代方案的CRXDE Lite,則為具有
ui.apps模組的AEM專案。
在將索引部署到生產環境之前,請先在開發或中繼環境中測試索引。 在大型存放庫上建立索引可能需要一些時間。
定義自訂索引 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[]表示多值String屬性,即使它只包含一個值。
-
開啟
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索引。