如何使用JCR XPath在jcr:content / @ jcr:data中搜索?

时间:2013-04-24 11:57:42

标签: java xpath cq5 jcr aem

我想在CQ 5.6(AEM)实例中搜索包含给定字符串.jsp的所有xxx文件的JCR存储库。作为JCR对XPath(或JCR-SQL2)的解释的新手,我在表达查询方面不太成功。

这将获取所有.jsp个文件:

//*[jcr:contains(., '.jsp')]

我希望限制上面包含.jsp的{​​{1}}个文件列表:

xxx

//*[jcr:contains(., '.jsp')][jcr:contains(jcr:content/@jcr:data, 'xxx')] //*[jcr:contains(., '.jsp') and jcr:contains(jcr:content/@jcr:data, 'xxx')] //*[jcr:contains(., '.jsp')]/jcr:content[jcr:contains(@jcr:data, 'xxx')]/.. 属于@jcr:data类型。以上都不适用。我哪里错了?

1 个答案:

答案 0 :(得分:4)

看起来查询应该在nt:file节点上,而不是在jcr:data节点上。请参阅JCR - Jackrabbit - Xpath expression for search content text of a file contained inside a node的答案。

使用querybuilder进行的快速测试显示来自CQ中JSP文件的结果(在此示例中,它们包含“/foundation/global.jsp”):

http://localhost:4502/bin/querybuilder.json?type=nt:file&nodename=*.jsp&group.1_fulltext=foundation/global.jsp

给出:

{
  success: true,
  results: 10,
  total: 21,
  offset: 0,
  hits: [
    {
      path: "/libs/cq/personalization/components/offerpage/body.jsp",
      excerpt: " --%&gt;&lt;%@include file=&quot;/libs/<strong>foundation/global.jsp</strong>&quot;%&gt;&lt;% I18n i18n = new I18n(slingRequest); String icnCls = ...",
      name: "body.jsp",
      title: "body.jsp",
      lastModified: "2013-04-24 11:45:05",
      created: "2013-04-24 11:32:58",
      size: "3 KB",
      mimeType: "text/plain"
    },
...
}