Aem CQ5查询生成器:获取没有jcr:content节点的页面列表

Aem CQ5查询生成器:获取没有jcr:content节点的页面列表,aem,Aem,使用查询生成器(http://localhost:4502/libs/cq/search/content/querydebug.html),我想得到一个没有jcr:content子节点的页面列表 我尝试使用节点、项目名称等,但找不到正确的查询。谢谢你的帮助 path=/content/products type=cq:Page node=jcr:content node.operation=exists node.operation=not p.l

使用查询生成器(
http://localhost:4502/libs/cq/search/content/querydebug.html
),我想得到一个没有
jcr:content
子节点的页面列表

我尝试使用节点、项目名称等,但找不到正确的查询。谢谢你的帮助

    path=/content/products
    type=cq:Page
    node=jcr:content
    node.operation=exists
    node.operation=not
    p.limit=-1

CQ5查询生成器将提供的查询转换为Jackrabbit XPath查询。后者不支持测试孩子的存在。以下XPath理论上应该有效:

/jcr:root/content//element(*, cq:Page)[not(jcr:content)]
但结果是空的。有一种方法可以添加这样的功能,但它看起来被放弃了

因此,我们必须手动检查它。由于CQ谓词不提供此类功能(您在查询中没有使用
节点
谓词),因此我们需要编写一个新的谓词:

@Component(metatype = false, factory = "com.day.cq.search.eval.PredicateEvaluator/child")
public class ChildrenPredicateEvaluator extends AbstractPredicateEvaluator {

    public boolean includes(Predicate p, Row row, EvaluationContext context) {
        final Resource resource = context.getResource(row);

        final String name = p.get("name", "");
        final boolean childExists;
        if (name.isEmpty()) {
            childExists = resource.hasChildren();
        } else {
            childExists = resource.getChild(name) != null;
        }

        final String operator = p.get("operator", "exists");
        if ("not_exists".equals(operator)) {
            return !childExists;
        } else {
            return childExists;
        }
    }

    public boolean canXpath(Predicate predicate, EvaluationContext context) {
        return false;
    }

    public boolean canFilter(Predicate predicate, EvaluationContext context) {
        return true;
    }
}
我们可以按如下方式使用它:

child.name=wantedChild
child.operator=exists

// or

child.name=unwantedChild
child.operator=not_exists
您也可以跳过
child.name
行以检查是否存在子项

因此,使用此谓词的查询如下所示:

path=/content/products
type=cq:Page
child.name=jcr:content
child.operator=not_exists
p.limit=-1

您提供的URL无法从外部访问。如果该URL中的信息很重要,请在您的问题中添加该URL的屏幕截图,以便人们可以看到。@MarianoD'Ascanio在本例中,这是CQ中查询生成器调试控制台的URL,因此是标准功能。我认为这个问题是正确的