用于在路径

时间:2018-06-13 16:47:36

标签: aem cq5 jcr-sql2 aem-6

如何使用sql2查询执行以下操作:

要求:

路径:/content/consumer

  1. 转到一个节点级别,例如:/ content / consumer / en-us
  2. 搜索在" / content / consumer / en-us"等路径字段中创作的字符串。
  3. if (current Node != Pathfield)然后显示它。
  4. 重复步骤1到3所有其他语言环境(en-ca,fr-fr,de-de等)。

    以下是我的尝试:

        SELECT parent.* FROM [nt:unstructured] AS parent INNER JOIN [nt:unstructured] AS child ON ISDESCENDANTNODE(child,parent) WHERE ISDESCENDANTNODE(parent, [/content/consumer/en-us/]) AND child.[*] = '/content/consumer/%'
    
    The query read or traversed more than 100000 nodes. To avoid affecting other tasks, processing was stopped.
    

    如果我跑:

    SELECT * FROM [nt:unstructured] AS s WHERE ISDESCENDANTNODE('/content/consumer/en-us/ip') and s.* LIKE '/content/consumer/%'
    

    这将显示所有路径,而不考虑本地路径。我在寻找的是: / content / consumer / [^ en-us]%(即不喜欢en-us)。

    这是我到目前为止所做的:

    Resource resource = request.getResourceResolver().getResource(path);
        Node node = resource.adaptTo(Node.class);
    
        ResourceResolver resourceResolver = request.getResourceResolver();
    
        try {
            NodeIterator list = node.getNodes();
    
            while (list.hasNext()) {
                Node currentSubNode = list.nextNode();
                subNodeName = currentSubNode.getPath();
                culture = extractCultureNodeName(subNodeName);
                fullTextPath = path + culture;
    
                Map<String, String> map = new HashMap<String, String>();
                map.put("type", "nt:base");
                map.put("path", subNodeName);
                map.put("fulltext", fullTextPath);
    
                if (StringUtils.isNotBlank(culture)) {
                    Query query = queryBuilder.createQuery(PredicateGroup.create(map),
                            resourceResolver.adaptTo(Session.class));
                    SearchResult result = query.getResult();
    
                    for (Hit hit : result.getHits()) {
                             String output = hit.getPath();
                            LOG.info("HITs: " + hit.getPath());
                    }
                }
    
            }
    

    问题出在查询构建器中,我得到的命中数远远少于crxde中的裸xpath查询:

    /jcr:root/content/consumer/en-us//element(*, nt:base)
    [
    (jcr:contains(., ‘/content/consumer/en-us’))
    ]
    

0 个答案:

没有答案