Expand my Community achievements bar.

Submissions are now open for the 2026 Adobe Experience Maker Awards.

How to find link text in bulk editor

Avatar

Level 1

Hello, I would like to understand the query/search configuration using AEM Bulk Editor to pull a list of keywords e.g. 'Pensions basics' that is ONLY link text.

Is this possible? 

Your feedback would be greatly appreciated.

Thank you.

5 Replies

Avatar

Level 5

Hi @Alex9463 ,

If you are trying to find keywords that appear specifically as link text (i.e., inside <a> tags), then based on my understanding, this is not possible using AEM Bulk Editor. This is because AEM Bulk Editor operates on raw JCR properties and does not parse HTML content, so it cannot search specifically within anchor (<a>) tags.

          If this is a requirement, you would need to programmatically traverse the HTML content stored in the relevant JCR properties and extract the anchor text using an HTML parser.



Feel free to correct me if I’m wrong or share any additional insight.
Thanks.

 

 

Avatar

Community Advisor

Hi @Alex9463,

If the link text is stored as a standalone property (eg. linkText, text, buttonText), meaning not embedded inside HTML, then yes, you can query that with Bulk Editor using JCR property filters.

property=linkText
property.value=Pensions basics

If "Pensions basics" is specifically the text inside <a> tags in rich text fields: No, it is not possible with Bulk Editor alone, because it doesn’t parse HTML or extract anchor tag content from a blob of text.

In this case you may consider below two options:

1. Write a custom AEM script
  • Traverse JCR nodes under /content

  • Read HTML properties (like text, body, etc.)

  • Use JSoup or another HTML parser to extract <a> tag text

  • Match against "Pensions basics"

  • Optionally, log or export the results

2. Use Groovy Console (if available)

If your AEM instance has the ACS AEM Commons Groovy Console, you can run a script like:

import org.jsoup.Jsoup

def root = getPage("/content")
def results = []

root.each { page ->
    page.node.traverse { node ->
        def prop = node.get("text")
        if (prop && prop.contains("<a")) {
            def doc = Jsoup.parse(prop)
            def links = doc.select("a")
            links.each { link ->
                if (link.text() == "Pensions basics") {
                    results << node.path
                }
            }
        }
    }
}
results

 Hope that helps!


Santosh Sai

AEM BlogsLinkedIn


Avatar

Community Advisor

Hi @Alex9463 ,

What is possible with AEM Bulk Editor:

You can search for link text using Bulk Editor only if the link text is stored as a plain property (e.g., linkText, buttonLabel, ctaText) like this:

property=linkText
property.value=Pensions basics

This works because Bulk Editor queries JCR properties directly.

What is not possible directly:

If your link text "Pensions basics" is embedded inside a rich text field or HTML string, like:

<div><p>Learn more about <a href="/content/pensions">Pensions basics</a>.</p></div>

Then Bulk Editor cannot isolate or query just the <a> tag text. It treats that whole HTML blob as a string and won’t parse the HTML to find anchor text.


Best Alternatives:

If the link is inside rich text, here are 2 working approaches:

1. Groovy Console + JSoup (recommended for HTML parsing)

If ACS AEM Commons is installed, use Groovy Console:

import org.jsoup.Jsoup
import com.day.cq.wcm.api.Page
import com.day.cq.wcm.api.PageManager

def results = []

def rootPage = getPage("/content")
rootPage.listChildren().each { page ->
    def resource = page.adaptTo(org.apache.sling.api.resource.Resource)
    resource.resourceResolver.getResource(page.path + "/jcr:content").listChildren().each { child ->
        child.valueMap.each { key, value ->
            if (value instanceof String && value.contains("<a")) {
                def doc = Jsoup.parse(value)
                doc.select("a").each { link ->
                    if (link.text() == "Pensions basics") {
                        results << page.path
                    }
                }
            }
        }
    }
}

return results

2. Custom Java Servlet or Sling Model Utility
  - If Groovy Console isn't available:
  - Create a Sling Servlet
  - Use JSoup in Java to parse content HTML fields
  - Extract and match anchor tag text
  - Export matches to CSV or log


Regards,
Amit

Avatar

Level 1

Thank you Amit for providing an explanation, and responding so swiftly.

Regrettably it seems the text is inside <a> tags in rich text so not authorable in Bulk editor and I don't have HTML access to code.

I appreciate your clarification nonetheless, and providing a code based script option that I will share with AEM support we have and see if this will work.

Avatar

Administrator

@Alex9463 Just checking in — were you able to resolve your issue?
We’d love to hear how things worked out. If the suggestions above helped, marking a response as correct can guide others with similar questions. And if you found another solution, feel free to share it — your insights could really benefit the community. Thanks again for being part of the conversation!



Kautuk Sahni