1

How to perform the following using sql2 query:

Requirement:

path: /content/consumer

  1. go one node level, for example : /content/consumer/en-us
  2. search for String authored in a pathfield like "/content/consumer/en-us"
  3. if (current Node != Pathfield) then display it.

repeat the step from 1 to 3 all other locales(en-ca, fr-fr, de-de etc).

Here is what I have tried:

    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.

If I run:

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

This will display all paths irrespective of local. What I am looking for is: /content/consumer/[^en-us]% (i.e not like en-us).

Here is what I have done so far:

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());
                }
            }

        }

The problem is in the query builder, the number of hits I am getting is far less than bare xpath query in crxde:

/jcr:root/content/consumer/en-us//element(*, nt:base)
[
(jcr:contains(., ‘/content/consumer/en-us’))
]
Ajay
  • 421
  • 3
  • 17
  • What do you intend by `currentNode != Pathfield`? Nodes would always be `nt:unstructured` unless it is page or page content. Second, any `pathfield` in the dialog would save the dialog value as a `String` under `/content`. Can you elaborate your requirement a bit more? – rakhi4110 Jun 14 '18 at 01:33
  • in AEM, this is to make sure that, I have a popup page which is authored and mapped from a page through a pathfield to the same locale. Could be very handy in production, before we send each page for translations, i.e : post rollout, the referrer and referring page should in in same locale. – Ajay Jun 14 '18 at 03:41

0 Answers0